/** * Execute a the appropriate set of plugins for a given build stage. * @param array $config PHPCI configuration * @param string $stage * @return bool */ public function executePlugins(&$config, $stage) { $success = true; // Ignore any stages for which we don't have plugins set: if (!array_key_exists($stage, $config) || !is_array($config[$stage])) { return $success; } foreach ($config[$stage] as $plugin => $options) { $this->logger->log(Lang::get('running_plugin', $plugin)); // Try and execute it: if ($this->executePlugin($plugin, $options)) { // Execution was successful: $this->logger->logSuccess(Lang::get('plugin_success')); } elseif ($stage == 'setup') { // If we're in the "setup" stage, execution should not continue after // a plugin has failed: throw new \Exception('Plugin failed: ' . $plugin); } else { // If we're in the "test" stage and the plugin is not allowed to fail, // then mark the build as failed: if ($stage == 'test' && (!isset($options['allow_failures']) || !$options['allow_failures'])) { $success = false; } $this->logger->logFailure(Lang::get('plugin_failed')); } } return $success; }
/** * Execute a the appropriate set of plugins for a given build stage. * @param array $config PHPCI configuration * @param string $stage * @return bool */ public function executePlugins(&$config, $stage) { $success = true; // Ignore any stages for which we don't have plugins set: if (!array_key_exists($stage, $config) || !is_array($config[$stage])) { return $success; } foreach ($config[$stage] as $plugin => $options) { $this->logger->log('RUNNING PLUGIN: ' . $plugin); // Is this plugin allowed to fail? if ($stage == 'test' && !isset($options['allow_failures'])) { $options['allow_failures'] = false; } // Try and execute it: if ($this->executePlugin($plugin, $options)) { // Execution was successful: $this->logger->logSuccess('PLUGIN STATUS: SUCCESS!'); } else { // If we're in the "test" stage and the plugin is not allowed to fail, // then mark the build as failed: if ($stage == 'test' && !$options['allow_failures']) { $success = false; } $this->logger->logFailure('PLUGIN STATUS: FAILED'); } } return $success; }
/** * Execute the list of plugins found for a given testing stage. * @param $plugins * @param $stage * @return bool * @throws \Exception */ protected function doExecutePlugins(&$plugins, $stage) { $success = true; foreach ($plugins as $plugin => $options) { $this->logger->log(Lang::get('running_plugin', $plugin)); $this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING); // Try and execute it if ($this->executePlugin($plugin, $options)) { // Execution was successful $this->logger->logSuccess(Lang::get('plugin_success')); $this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS); } else { // Execution failed $this->logger->logFailure(Lang::get('plugin_failed')); $this->setPluginStatus($stage, $plugin, Build::STATUS_FAILED); if ($stage === 'setup') { // If we're in the "setup" stage, execution should not continue after // a plugin has failed: throw new Exception('Plugin failed: ' . $plugin); } elseif ($stage === 'test') { // If we're in the "test" stage and the plugin is not allowed to fail, // then mark the build as failed: if (empty($options['allow_failures'])) { $success = false; } } } } return $success; }
/** * Add a success-coloured message to the log. * @param string */ public function logSuccess($message) { $this->buildLogger->logSuccess($message); }