Merge branch 'master' of github.com:Block8/PHPCI

This commit is contained in:
Dan Cryer 2014-05-22 10:54:15 +01:00
commit 97889b3449
10 changed files with 72 additions and 26 deletions

View file

@ -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);

View file

@ -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();
}
/**

View file

@ -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();
}
}
}

View file

@ -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'])) {

View file

@ -51,9 +51,11 @@
<?php endif; ?>
<?php if ($project->getSshPublicKey()): ?>
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Public Key</h3></div>
<div class="panel-body"><?php print $project->getSshPublicKey(); ?></div>
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#publicCollapse">Public Key</a></h3></div>
<div id="publicCollapse" class="panel-collapse collapse out">
<div class="panel-body word-wrap"><?php print $project->getSshPublicKey(); ?></div>
</div>
</div>
<?php endif; ?>
</div>

View file

@ -82,6 +82,6 @@ h1 {
width: 200px;
}
.panel-body {
overflow: auto;
.word-wrap {
word-wrap: break-word;
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="76" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="76" height="18" fill="#555"/><rect rx="4" x="37" width="39" height="18" fill="#fe7d37"/><path fill="#fe7d37" d="M37 0h4v18h-4z"/><rect rx="4" width="76" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="55.5" y="13" fill="#010101" fill-opacity=".3">error</text><text x="55.5" y="12">error</text></g></svg>

After

Width:  |  Height:  |  Size: 818 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="78" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="78" height="18" fill="#555"/><rect rx="4" x="37" width="41" height="18" fill="#e05d44"/><path fill="#e05d44" d="M37 0h4v18h-4z"/><rect rx="4" width="78" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="56.5" y="13" fill="#010101" fill-opacity=".3">failed</text><text x="56.5" y="12">failed</text></g></svg>

After

Width:  |  Height:  |  Size: 820 B

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="90" height="18" fill="#555"/><rect rx="4" x="37" width="53" height="18" fill="#97CA00"/><path fill="#97CA00" d="M37 0h4v18h-4z"/><rect rx="4" width="90" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="62.5" y="13" fill="#010101" fill-opacity=".3">passing</text><text x="62.5" y="12">passing</text></g></svg>

After

Width:  |  Height:  |  Size: 822 B