diff --git a/PHPCI/Controller/BuildStatusController.php b/PHPCI/Controller/BuildStatusController.php index 54132401..f7304413 100644 --- a/PHPCI/Controller/BuildStatusController.php +++ b/PHPCI/Controller/BuildStatusController.php @@ -37,31 +37,56 @@ class BuildStatusController extends \PHPCI\Controller $this->projectStore = Store\Factory::getStore('Project'); } + /** + * Returns status of the last build + * @param $projectId + * @return string + */ + protected function getStatus($projectId) + { + $branch = $this->getParam('branch', 'master'); + try { + $project = $this->projectStore->getById($projectId); + $status = 'passing'; + + if (!$project->getAllowPublicStatus()) { + die(); + } + + if (isset($project) && $project instanceof Project) { + $build = $project->getLatestBuild($branch, array(2,3)); + + if (isset($build) && $build instanceof Build && $build->getStatus() != 2) { + $status = 'failed'; + } + } + } catch (\Exception $e) { + $status = 'error'; + } + + return $status; + } + /** * Returns the appropriate build status image for a given project. */ public function image($projectId) { - $branch = $this->getParam('branch', 'master'); - $project = $this->projectStore->getById($projectId); - $status = 'ok'; - - if (!$project->getAllowPublicStatus()) { - die(); - } - - if (isset($project) && $project instanceof Project) { - $build = $project->getLatestBuild($branch, array(2,3)); - - if (isset($build) && $build instanceof Build && $build->getStatus() != 2) { - $status = 'failed'; - } - } - + $status = $this->getStatus($projectId); header('Content-Type: image/png'); die(file_get_contents(APPLICATION_PATH . 'public/assets/img/build-' . $status . '.png')); } + /** + * Returns the appropriate build status image in SVG format for a given project. + */ + public function svg($projectId) + { + $status = $this->getStatus($projectId); + header('Content-Type: image/svg+xml'); + die(file_get_contents(APPLICATION_PATH . 'public/assets/img/build-' . $status . '.svg')); + } + public function view($projectId) { $project = $this->projectStore->getById($projectId); diff --git a/PHPCI/Helper/MailerFactory.php b/PHPCI/Helper/MailerFactory.php index 8c7b46e7..81d37831 100644 --- a/PHPCI/Helper/MailerFactory.php +++ b/PHPCI/Helper/MailerFactory.php @@ -19,7 +19,7 @@ class MailerFactory public function __construct($config = null) { - $this->emailConfig = isset($config['email_settings']) ?: array(); + $this->emailConfig = isset($config['email_settings']) ? $config['email_settings'] : array(); } /** diff --git a/PHPCI/Migrations/20140513143726_initial_migration.php b/PHPCI/Migrations/20140513143726_initial_migration.php index 8aad60b6..5fca43bf 100644 --- a/PHPCI/Migrations/20140513143726_initial_migration.php +++ b/PHPCI/Migrations/20140513143726_initial_migration.php @@ -52,6 +52,10 @@ class InitialMigration extends AbstractMigration { $table = $this->table('build'); + if (!$this->hasTable('build')) { + $table->create(); + } + if (!$table->hasColumn('project_id')) { $table->addColumn('project_id', 'integer'); } @@ -115,6 +119,10 @@ class InitialMigration extends AbstractMigration { $table = $this->table('build_meta'); + if (!$this->hasTable('build_meta')) { + $table->create(); + } + if (!$table->hasColumn('project_id')) { $table->addColumn('project_id', 'integer'); } @@ -142,6 +150,10 @@ class InitialMigration extends AbstractMigration { $table = $this->table('project'); + if (!$this->hasTable('project')) { + $table->create(); + } + if (!$table->hasColumn('title')) { $table->addColumn('title', 'string', array('limit' => 250)); } @@ -193,6 +205,10 @@ class InitialMigration extends AbstractMigration { $table = $this->table('user'); + if (!$this->hasTable('user')) { + $table->create(); + } + if (!$table->hasColumn('email')) { $table->addColumn('email', 'string', array('limit' => 250)); } @@ -215,4 +231,4 @@ class InitialMigration extends AbstractMigration $table->save(); } -} \ No newline at end of file +} diff --git a/PHPCI/Plugin/Behat.php b/PHPCI/Plugin/Behat.php index 014cff8a..679d9c28 100644 --- a/PHPCI/Plugin/Behat.php +++ b/PHPCI/Plugin/Behat.php @@ -26,14 +26,14 @@ class Behat implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; - $this->build = $build; + $this->phpci = $phpci; + $this->build = $build; $this->features = ''; if (isset($options['executable'])) { $this->executable = $options['executable']; } else { - $this->executable = $this->phpci->findBinary('atoum'); + $this->executable = $this->phpci->findBinary('behat'); } if (!empty($options['features'])) { diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index 48866e5c..bc89e9d8 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -51,9 +51,11 @@ getSshPublicKey()): ?> -
diff --git a/public/assets/css/phpci.css b/public/assets/css/phpci.css index ce98017a..7113ad1c 100644 --- a/public/assets/css/phpci.css +++ b/public/assets/css/phpci.css @@ -82,6 +82,6 @@ h1 { width: 200px; } -.panel-body { - overflow: auto; +.word-wrap { + word-wrap: break-word; } \ No newline at end of file diff --git a/public/assets/img/build-error.svg b/public/assets/img/build-error.svg new file mode 100644 index 00000000..a6567a32 --- /dev/null +++ b/public/assets/img/build-error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/img/build-failed.svg b/public/assets/img/build-failed.svg new file mode 100644 index 00000000..c7afed21 --- /dev/null +++ b/public/assets/img/build-failed.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/img/build-ok.png b/public/assets/img/build-passing.png similarity index 100% rename from public/assets/img/build-ok.png rename to public/assets/img/build-passing.png diff --git a/public/assets/img/build-passing.svg b/public/assets/img/build-passing.svg new file mode 100644 index 00000000..42f797eb --- /dev/null +++ b/public/assets/img/build-passing.svg @@ -0,0 +1 @@ + \ No newline at end of file