Improvements for new 'deploy' stage
This commit is contained in:
parent
788aeb161a
commit
21a73abd16
|
@ -42,6 +42,12 @@ test:
|
|||
grunt:
|
||||
task: "build"
|
||||
|
||||
deploy:
|
||||
deployer:
|
||||
webhook_url: "http://deployer.local/deploy/QZaF1bMIUqbMFTmKDmgytUuykRN0cjCgW9SooTnwkIGETAYhDTTYoR8C431t"
|
||||
reason: "PHP Censor Build #%BUILD% - %COMMIT_MESSAGE%"
|
||||
update_only: true
|
||||
|
||||
complete:
|
||||
mysql:
|
||||
host: "localhost"
|
||||
|
@ -62,6 +68,8 @@ As mentioned earlier, PHP Censor is powered by plugins, there are several phases
|
|||
|
||||
* `test` - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build.
|
||||
|
||||
* `deploy` - The deploy that should be run after the build. Plugins run during this phase will contribute to the success or failure of the build.
|
||||
|
||||
* `complete` - Always called when the `test` phase completes, regardless of success or failure. **Note** that is you do any DB stuff here, you will need to add the DB credentials to this section as well, as it runs in a separate instance.
|
||||
|
||||
* `success` - Called upon success of the `test` phase.
|
||||
|
|
|
@ -190,7 +190,7 @@ class Builder implements LoggerAwareInterface
|
|||
$this->setupBuild();
|
||||
|
||||
// Run the core plugin stages:
|
||||
foreach (['setup', 'test', 'deploy'] as $stage) {
|
||||
foreach ([Build::STAGE_SETUP, Build::STAGE_TEST, Build::STAGE_DEPLOY] as $stage) {
|
||||
$success &= $this->pluginExecutor->executePlugins($this->config, $stage);
|
||||
}
|
||||
|
||||
|
@ -204,16 +204,16 @@ class Builder implements LoggerAwareInterface
|
|||
|
||||
|
||||
if ($success) {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'success');
|
||||
$this->pluginExecutor->executePlugins($this->config, Build::STAGE_SUCCESS);
|
||||
|
||||
if ($previous_state == Build::STATUS_FAILED) {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'fixed');
|
||||
$this->pluginExecutor->executePlugins($this->config, Build::STAGE_FIXED);
|
||||
}
|
||||
} else {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'failure');
|
||||
$this->pluginExecutor->executePlugins($this->config, Build::STAGE_FAILURE);
|
||||
|
||||
if ($previous_state == Build::STATUS_SUCCESS || $previous_state == Build::STATUS_PENDING) {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'broken');
|
||||
$this->pluginExecutor->executePlugins($this->config, Build::STAGE_BROKEN);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
|
@ -229,7 +229,7 @@ class Builder implements LoggerAwareInterface
|
|||
|
||||
try {
|
||||
// Complete stage plugins are always run
|
||||
$this->pluginExecutor->executePlugins($this->config, 'complete');
|
||||
$this->pluginExecutor->executePlugins($this->config, Build::STAGE_COMPLETE);
|
||||
} catch (\Exception $ex) {
|
||||
$this->buildLogger->logFailure('Exception: ' . $ex->getMessage());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,15 @@ use b8\Store\Factory;
|
|||
*/
|
||||
class Build extends Model
|
||||
{
|
||||
const STAGE_SETUP = 'setup';
|
||||
const STAGE_TEST = 'test';
|
||||
const STAGE_DEPLOY = 'deploy';
|
||||
const STAGE_COMPLETE = 'complete';
|
||||
const STAGE_SUCCESS = 'success';
|
||||
const STAGE_FAILURE = 'failure';
|
||||
const STAGE_FIXED = 'fixed';
|
||||
const STAGE_BROKEN = 'broken';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -739,7 +748,7 @@ class Build extends Model
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach (['setup', 'test', 'complete', 'success', 'failure'] as $stage) {
|
||||
foreach ([Build::STAGE_SETUP, Build::STAGE_TEST] as $stage) {
|
||||
if ($className::canExecute($stage, $builder, $this)) {
|
||||
$config[$stage][$className::pluginName()] = [
|
||||
'zero_config' => true
|
||||
|
|
|
@ -72,7 +72,7 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
return $stage == 'test' && !is_null(self::findConfigFile($builder->buildPath));
|
||||
return $stage == Build::STAGE_TEST && !is_null(self::findConfigFile($builder->buildPath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -82,7 +82,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
|||
{
|
||||
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';
|
||||
|
||||
if (file_exists($path) && $stage == 'setup') {
|
||||
if (file_exists($path) && $stage == Build::STAGE_SETUP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class PhpCpd extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class PhpLoc extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class PhpParallelLint extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test' && !is_null(PhpUnitOptions::findConfigFile($build->getBuildPath()))) {
|
||||
if ($stage == Build::STAGE_TEST && !is_null(PhpUnitOptions::findConfigFile($build->getBuildPath()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
|||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
if ($stage == Build::STAGE_TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,18 +149,18 @@ class Executor
|
|||
// Execution failed
|
||||
$this->setPluginStatus($stage, $plugin, Build::STATUS_FAILED);
|
||||
|
||||
if ($stage === 'setup') {
|
||||
if ($stage === Build::STAGE_SETUP) {
|
||||
$this->logger->logFailure('PLUGIN: FAILED');
|
||||
// If we're in the "setup" stage, execution should not continue after
|
||||
// a plugin has failed:
|
||||
throw new Exception('Plugin failed: ' . $plugin);
|
||||
} elseif ($stage === 'deploy') {
|
||||
} elseif ($stage === Build::STAGE_DEPLOY) {
|
||||
$this->logger->logFailure('PLUGIN: FAILED');
|
||||
$success = false;
|
||||
} else {
|
||||
// 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']) && $stage === 'test') {
|
||||
if (empty($options['allow_failures']) && $stage === Build::STAGE_TEST) {
|
||||
$this->logger->logFailure('PLUGIN: FAILED');
|
||||
$success = false;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue