Cleanup of new executor changes.
This commit is contained in:
parent
4375c524a9
commit
68249d2f5d
|
@ -50,10 +50,6 @@ class Executor
|
||||||
public function executePlugins(&$config, $stage)
|
public function executePlugins(&$config, $stage)
|
||||||
{
|
{
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
/** @var \PHPCI\Model\Build $build */
|
|
||||||
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
|
|
||||||
$branch = $build->getBranch();
|
|
||||||
$pluginsToExecute = array();
|
$pluginsToExecute = array();
|
||||||
|
|
||||||
// If we have global plugins to execute for this stage, add them to the list to be executed:
|
// If we have global plugins to execute for this stage, add them to the list to be executed:
|
||||||
|
@ -61,31 +57,7 @@ class Executor
|
||||||
$pluginsToExecute[] = $config[$stage];
|
$pluginsToExecute[] = $config[$stage];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have branch-specific plugins to execute, add them to the list to be executed:
|
$pluginsToExecute = $this->getBranchSpecificPlugins($config, $stage, $pluginsToExecute);
|
||||||
if (isset($config['branch-' . $branch][$stage]) && is_array($config['branch-' . $branch][$stage])) {
|
|
||||||
$branchConfig = $config['branch-' . $branch];
|
|
||||||
$runOption = isset($branchConfig['run-option']) ? $branchConfig['run-option'] : 'after';
|
|
||||||
$plugins = $config['branch-' . $branch][$stage];
|
|
||||||
|
|
||||||
switch ($runOption) {
|
|
||||||
case 'replace':
|
|
||||||
$pluginsToExecute = array();
|
|
||||||
$pluginsToExecute[] = $plugins;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'before':
|
|
||||||
array_unshift($pluginsToExecute, $plugins);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'after':
|
|
||||||
array_push($pluginsToExecute, $plugins);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
array_push($pluginsToExecute, $plugins);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($pluginsToExecute as $pluginSet) {
|
foreach ($pluginsToExecute as $pluginSet) {
|
||||||
if (!$this->doExecutePlugins($pluginSet, $stage)) {
|
if (!$this->doExecutePlugins($pluginSet, $stage)) {
|
||||||
|
@ -96,6 +68,66 @@ class Executor
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the config for any plugins specific to the branch we're currently building.
|
||||||
|
* @param $config
|
||||||
|
* @param $stage
|
||||||
|
* @param $pluginsToExecute
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getBranchSpecificPlugins(&$config, $stage, $pluginsToExecute)
|
||||||
|
{
|
||||||
|
/** @var \PHPCI\Model\Build $build */
|
||||||
|
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
|
||||||
|
$branch = $build->getBranch();
|
||||||
|
|
||||||
|
// If we don't have any branch-specific plugins:
|
||||||
|
if (!isset($config['branch-' . $branch][$stage]) || !is_array($config['branch-' . $branch][$stage])) {
|
||||||
|
return $pluginsToExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have branch-specific plugins to execute, add them to the list to be executed:
|
||||||
|
$branchConfig = $config['branch-' . $branch];
|
||||||
|
$plugins = $branchConfig[$stage];
|
||||||
|
|
||||||
|
$runOption = 'after';
|
||||||
|
|
||||||
|
if (!empty($branchConfig['run-option'])) {
|
||||||
|
$runOption = $branchConfig['run-option'];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($runOption) {
|
||||||
|
// Replace standard plugin set for this stage with just the branch-specific ones:
|
||||||
|
case 'replace':
|
||||||
|
$pluginsToExecute = array();
|
||||||
|
$pluginsToExecute[] = $plugins;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Run branch-specific plugins before standard plugins:
|
||||||
|
case 'before':
|
||||||
|
array_unshift($pluginsToExecute, $plugins);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Run branch-specific plugins after standard plugins:
|
||||||
|
case 'after':
|
||||||
|
array_push($pluginsToExecute, $plugins);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
array_push($pluginsToExecute, $plugins);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pluginsToExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the list of plugins found for a given testing stage.
|
||||||
|
* @param $plugins
|
||||||
|
* @param $stage
|
||||||
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
protected function doExecutePlugins(&$plugins, $stage)
|
protected function doExecutePlugins(&$plugins, $stage)
|
||||||
{
|
{
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
Loading…
Reference in a new issue