From 9b9d1b1122080806f75a20373e61781661aa0257 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 3 Apr 2017 19:55:21 +0700 Subject: [PATCH 1/4] Russian localization for Environments. PullRequest #41. --- src/PHPCensor/Languages/lang.ru.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index ebc927fe..8eec658d 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -46,6 +46,7 @@ PHP Censor', 'branch_x' => 'Ветка: %s', 'created_x' => 'Создан: %s', 'started_x' => 'Запущен: %s', + 'environment_x' => 'Окружение: %s', // Sidebar 'hello_name' => 'Привет, %s', @@ -114,6 +115,7 @@ PHP Censor', 'archived' => 'Архивный', 'archived_menu' => 'Архив', 'save_project' => 'Сохранить проект', + 'environments_label' => 'Окружения (yaml)', 'error_mercurial' => 'URL репозитория Mercurial должен начинаться с http:// или https://', 'error_remote' => 'URL репозитория должен начинаться с git://, http:// или https://', @@ -124,12 +126,14 @@ PHP Censor', // View Project: 'all_branches' => 'Все ветки', + 'all' => 'Все', 'builds' => 'Сборки', 'id' => 'ID', 'date' => 'Дата', 'project' => 'Проект', 'commit' => 'Коммит', 'branch' => 'Ветка', + 'environment' => 'Окружение', 'status' => 'Статус', 'prev_link' => '« Пред.', 'next_link' => 'След. »', @@ -186,6 +190,7 @@ PHP Censor', 'phpcpd_warnings' => 'Предупреждения PHP Copy/Paste Detector', 'phpdoccheck_warnings' => 'Пропущенные Docblocks', 'issues' => 'Проблемы', + 'merged_branches' => 'Объеденяемые ветки', 'phpcpd' => 'PHP Copy/Paste Detector', 'phpcs' => 'PHP Code Sniffer', From cb4d7a268e4b7b4ccd5aff5c0d78c96fc70e1809 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 3 Apr 2017 20:44:35 +0700 Subject: [PATCH 2/4] Small fixes --- src/PHPCensor/Builder.php | 4 +--- src/PHPCensor/Model/Build.php | 11 +++++------ src/PHPCensor/Service/BuildService.php | 5 +++-- src/PHPCensor/Store/BuildErrorWriter.php | 14 ++++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/PHPCensor/Builder.php b/src/PHPCensor/Builder.php index 72a95155..63113baf 100644 --- a/src/PHPCensor/Builder.php +++ b/src/PHPCensor/Builder.php @@ -15,8 +15,6 @@ use Psr\Log\LogLevel; use PHPCensor\Plugin\Util\Factory as PluginFactory; /** - * PHPCI Build Runner - * * @author Dan Cryer */ class Builder implements LoggerAwareInterface @@ -119,7 +117,7 @@ class Builder implements LoggerAwareInterface $this->verbose ); - $this->interpolator = new BuildInterpolator(); + $this->interpolator = new BuildInterpolator(); $this->buildErrorWriter = new BuildErrorWriter($this->build->getId()); } diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index 18ad7d8f..d63aa043 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -3,7 +3,6 @@ namespace PHPCensor\Model; use PHPCensor\Builder; -use PHPCensor\Store\BuildErrorWriter; use Symfony\Component\Yaml\Parser as YamlParser; use PHPCensor\Model; use b8\Store\Factory; @@ -21,6 +20,11 @@ class Build extends Model const STAGE_FAILURE = 'failure'; const STAGE_FIXED = 'fixed'; const STAGE_BROKEN = 'broken'; + + const STATUS_PENDING = 0; + const STATUS_RUNNING = 1; + const STATUS_SUCCESS = 2; + const STATUS_FAILED = 3; /** * @var array @@ -669,11 +673,6 @@ class Build extends Model return Factory::getStore('BuildMeta', 'PHPCensor')->getByBuildId($this->getId()); } - const STATUS_PENDING = 0; - const STATUS_RUNNING = 1; - const STATUS_SUCCESS = 2; - const STATUS_FAILED = 3; - public $currentBuildPath; /** diff --git a/src/PHPCensor/Service/BuildService.php b/src/PHPCensor/Service/BuildService.php index 38aae3cf..89ac4f15 100644 --- a/src/PHPCensor/Service/BuildService.php +++ b/src/PHPCensor/Service/BuildService.php @@ -56,7 +56,7 @@ class BuildService $build = new Build(); $build->setCreated(new \DateTime()); $build->setProject($project); - $build->setStatus(0); + $build->setStatus(Build::STATUS_PENDING); $build->setEnvironment($environment); $branches = $project->getBranchesByEnvironment($environment); @@ -118,8 +118,9 @@ class BuildService $build = new Build(); $build->setValues($data); $build->setCreated(new \DateTime()); - $build->setStatus(0); + $build->setStatus(Build::STATUS_PENDING); + /** @var Build $build */ $build = $this->buildStore->save($build); $buildId = $build->getId(); diff --git a/src/PHPCensor/Store/BuildErrorWriter.php b/src/PHPCensor/Store/BuildErrorWriter.php index 496cd840..3fef1e57 100644 --- a/src/PHPCensor/Store/BuildErrorWriter.php +++ b/src/PHPCensor/Store/BuildErrorWriter.php @@ -20,6 +20,7 @@ class BuildErrorWriter /** * BuildErrorWriter constructor. + * * @param int $build_id * @param int $buffer_size */ @@ -39,12 +40,13 @@ class BuildErrorWriter /** * Write error - * @param string $plugin - * @param string $message - * @param int $severity - * @param string $file - * @param int $line_start - * @param int $line_end + * + * @param string $plugin + * @param string $message + * @param int $severity + * @param string $file + * @param int $line_start + * @param int $line_end * @param \DateTime $created_date */ public function write($plugin, $message, $severity, $file = null, $line_start = null, $line_end = null, $created_date = null) From d54c1978b96a7a93c9a59799ec65bbeb81662829 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 3 Apr 2017 21:04:27 +0700 Subject: [PATCH 3/4] Added allowed fail status for plugins (See build summary) --- public/assets/js/build-plugins/summary.js | 4 ++-- src/PHPCensor/Languages/lang.en.php | 1 + src/PHPCensor/Languages/lang.ru.php | 1 + src/PHPCensor/Model/Build.php | 9 +++++---- src/PHPCensor/Plugin/Util/Executor.php | 7 +++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/public/assets/js/build-plugins/summary.js b/public/assets/js/build-plugins/summary.js index ecffe894..7522c178 100644 --- a/public/assets/js/build-plugins/summary.js +++ b/public/assets/js/build-plugins/summary.js @@ -3,8 +3,8 @@ var SummaryPlugin = ActiveBuild.UiPlugin.extend({ css: 'col-xs-12', title: Lang.get('build-summary'), box: true, - statusLabels: [ Lang.get('pending'), Lang.get('running'), Lang.get('success'), Lang.get('failed') ], - statusClasses: ['info', 'warning', 'success', 'danger'], + statusLabels: [Lang.get('pending'), Lang.get('running'), Lang.get('success'), Lang.get('failed'), Lang.get('failed_allowed')], + statusClasses: ['info', 'warning', 'success', 'danger', 'danger'], register: function() { var self = this; diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php index d06ec1f7..0fe48d29 100644 --- a/src/PHPCensor/Languages/lang.en.php +++ b/src/PHPCensor/Languages/lang.en.php @@ -83,6 +83,7 @@ PHP Censor', 'running' => 'Running', 'success' => 'Success', 'failed' => 'Failed', + 'failed_allowed' => 'Failed (Allowed)', 'error' => 'Error', 'skipped' => 'Skipped', 'trace' => 'Stack trace', diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index 8eec658d..a518efff 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -81,6 +81,7 @@ PHP Censor', 'running' => 'Запущена', 'success' => 'Успешно', 'failed' => 'Провал', + 'failed_allowed' => 'Провал (Допустим)', 'error' => 'Ошибка', 'skipped' => 'Пропущено', 'trace' => 'Стек вызова', diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index d63aa043..e110475d 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -21,10 +21,11 @@ class Build extends Model const STAGE_FIXED = 'fixed'; const STAGE_BROKEN = 'broken'; - const STATUS_PENDING = 0; - const STATUS_RUNNING = 1; - const STATUS_SUCCESS = 2; - const STATUS_FAILED = 3; + const STATUS_PENDING = 0; + const STATUS_RUNNING = 1; + const STATUS_SUCCESS = 2; + const STATUS_FAILED = 3; + const STATUS_FAILED_ALLOWED = 4; /** * @var array diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 215842a2..3dc6fbdf 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -146,8 +146,7 @@ class Executor $this->logger->logSuccess('PLUGIN: SUCCESS'); $this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS); } else { - // Execution failed - $this->setPluginStatus($stage, $plugin, Build::STATUS_FAILED); + $status = Build::STATUS_FAILED; if ($stage === Build::STAGE_SETUP) { $this->logger->logFailure('PLUGIN: FAILED'); @@ -164,9 +163,13 @@ class Executor $this->logger->logFailure('PLUGIN: FAILED'); $success = false; } else { + $status = Build::STATUS_FAILED_ALLOWED; + $this->logger->logFailure('PLUGIN: FAILED (ALLOWED)'); } } + + $this->setPluginStatus($stage, $plugin, $status); } } From 31beb233e3abd5bfcaf4d802571ee0e79908c194 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 3 Apr 2017 21:19:51 +0700 Subject: [PATCH 4/4] Separated Build status constants and Plugin status constants --- src/PHPCensor/Model/Build.php | 1 - src/PHPCensor/Plugin.php | 5 +++++ src/PHPCensor/Plugin/Util/Executor.php | 13 +++++++------ src/PHPCensor/View/Home/ajax-timeline.phtml | 17 +++++++++++------ src/PHPCensor/View/Home/index.phtml | 17 +++++++++++------ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index e110475d..0847847c 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -25,7 +25,6 @@ class Build extends Model const STATUS_RUNNING = 1; const STATUS_SUCCESS = 2; const STATUS_FAILED = 3; - const STATUS_FAILED_ALLOWED = 4; /** * @var array diff --git a/src/PHPCensor/Plugin.php b/src/PHPCensor/Plugin.php index 4b3088d3..d53f4c8c 100644 --- a/src/PHPCensor/Plugin.php +++ b/src/PHPCensor/Plugin.php @@ -11,6 +11,11 @@ use PHPCensor\Model\Build; */ abstract class Plugin { + const STATUS_PENDING = 0; + const STATUS_RUNNING = 1; + const STATUS_SUCCESS = 2; + const STATUS_FAILED = 3; + const STATUS_FAILED_ALLOWED = 4; /** * @var \PHPCensor\Builder */ diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 3dc6fbdf..a6448783 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -7,6 +7,7 @@ use Exception; use PHPCensor\Helper\Lang; use PHPCensor\Logging\BuildLogger; use PHPCensor\Model\Build; +use PHPCensor\Plugin; use PHPCensor\Store\BuildStore; /** @@ -138,15 +139,15 @@ class Executor 'Stage' . ': ' . ucfirst($stage) . ')' ); - $this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING); + $this->setPluginStatus($stage, $plugin, Plugin::STATUS_RUNNING); // Try and execute it if ($this->executePlugin($plugin, $options)) { // Execution was successful $this->logger->logSuccess('PLUGIN: SUCCESS'); - $this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS); + $this->setPluginStatus($stage, $plugin, Plugin::STATUS_SUCCESS); } else { - $status = Build::STATUS_FAILED; + $status = Plugin::STATUS_FAILED; if ($stage === Build::STAGE_SETUP) { $this->logger->logFailure('PLUGIN: FAILED'); @@ -163,7 +164,7 @@ class Executor $this->logger->logFailure('PLUGIN: FAILED'); $success = false; } else { - $status = Build::STATUS_FAILED_ALLOWED; + $status = Plugin::STATUS_FAILED_ALLOWED; $this->logger->logFailure('PLUGIN: FAILED (ALLOWED)'); } @@ -223,9 +224,9 @@ class Executor $summary[$stage][$plugin]['status'] = $status; - if ($status === Build::STATUS_RUNNING) { + if ($status === Plugin::STATUS_RUNNING) { $summary[$stage][$plugin]['started'] = time(); - } elseif ($status >= Build::STATUS_SUCCESS) { + } elseif ($status >= Plugin::STATUS_SUCCESS) { $summary[$stage][$plugin]['ended'] = time(); } diff --git a/src/PHPCensor/View/Home/ajax-timeline.phtml b/src/PHPCensor/View/Home/ajax-timeline.phtml index 2b3e9a40..07bfc58c 100644 --- a/src/PHPCensor/View/Home/ajax-timeline.phtml +++ b/src/PHPCensor/View/Home/ajax-timeline.phtml @@ -1,4 +1,9 @@ - +
    @@ -8,25 +13,25 @@ $branches = $build->getExtra('branches'); switch ($build->getStatus()) { - case \PHPCensor\Model\Build::STATUS_PENDING: + case Build::STATUS_PENDING: $updated = $build->getCreated(); $label = Lang::get('pending'); $color = 'blue'; break; - case \PHPCensor\Model\Build::STATUS_RUNNING: + case Build::STATUS_RUNNING: $updated = $build->getStarted(); $label = Lang::get('running'); $color = 'yellow'; break; - case \PHPCensor\Model\Build::STATUS_SUCCESS: + case Build::STATUS_SUCCESS: $updated = $build->getFinished(); $label = Lang::get('success'); $color = 'green'; break; - case \PHPCensor\Model\Build::STATUS_FAILED: + case Build::STATUS_FAILED: $updated = $build->getFinished(); $label = Lang::get('failed'); $color = 'red'; @@ -54,7 +59,7 @@ format('H:i:s'); - if ($build->getStatus() != \PHPCensor\Model\Build::STATUS_PENDING) { + if ($build->getStatus() != Build::STATUS_PENDING) { echo ' (' . $build->getPrettyDuration() . ')'; } ?> diff --git a/src/PHPCensor/View/Home/index.phtml b/src/PHPCensor/View/Home/index.phtml index e1c4f228..381292ab 100644 --- a/src/PHPCensor/View/Home/index.phtml +++ b/src/PHPCensor/View/Home/index.phtml @@ -1,4 +1,9 @@ - + @@ -34,25 +39,25 @@ $branches = $build->getExtra('branches'); switch ($build->getStatus()) { - case \PHPCensor\Model\Build::STATUS_PENDING: + case Build::STATUS_PENDING: $updated = $build->getCreated(); $label = Lang::get('pending'); $color = 'blue'; break; - case \PHPCensor\Model\Build::STATUS_RUNNING: + case Build::STATUS_RUNNING: $updated = $build->getStarted(); $label = Lang::get('running'); $color = 'yellow'; break; - case \PHPCensor\Model\Build::STATUS_SUCCESS: + case Build::STATUS_SUCCESS: $updated = $build->getFinished(); $label = Lang::get('success'); $color = 'green'; break; - case \PHPCensor\Model\Build::STATUS_FAILED: + case Build::STATUS_FAILED: $updated = $build->getFinished(); $label = Lang::get('failed'); $color = 'red'; @@ -80,7 +85,7 @@ format('H:i:s'); - if ($build->getStatus() != \PHPCensor\Model\Build::STATUS_PENDING) { + if ($build->getStatus() != Build::STATUS_PENDING) { echo ' (' . $build->getPrettyDuration() . ')'; } ?>