Adding a status indicator for each plugin on the build page, fixing ignores for PHPCPD
This commit is contained in:
parent
6053f0f748
commit
4037964d4c
|
@ -14,6 +14,7 @@ class Builder
|
|||
protected $success = true;
|
||||
protected $log = '';
|
||||
protected $verbose = false;
|
||||
protected $plugins = array();
|
||||
protected $build;
|
||||
|
||||
public function __construct(Build $build)
|
||||
|
@ -61,6 +62,7 @@ class Builder
|
|||
|
||||
$this->build->setFinished(new \DateTime());
|
||||
$this->build->setLog($this->log);
|
||||
$this->build->setPlugins(json_encode($this->plugins));
|
||||
$this->store->save($this->build);
|
||||
}
|
||||
|
||||
|
@ -103,6 +105,7 @@ class Builder
|
|||
}
|
||||
|
||||
$this->build->setLog($this->log);
|
||||
$this->build->setPlugins(json_encode($this->plugins));
|
||||
$this->build = $this->store->save($this->build);
|
||||
}
|
||||
|
||||
|
@ -198,9 +201,14 @@ class Builder
|
|||
{
|
||||
$this->logFailure('Plugin does not exist: ' . $plugin);
|
||||
|
||||
if($stage == 'test' && !$options['allow_failures'])
|
||||
if($stage == 'test')
|
||||
{
|
||||
$this->success = false;
|
||||
$this->plugins[$plugin] = false;
|
||||
|
||||
if(!$options['allow_failures'])
|
||||
{
|
||||
$this->success = false;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -208,13 +216,18 @@ class Builder
|
|||
|
||||
try
|
||||
{
|
||||
$plugin = new $class($this, $options);
|
||||
$obj = new $class($this, $options);
|
||||
|
||||
if(!$plugin->execute())
|
||||
if(!$obj->execute())
|
||||
{
|
||||
if($stage == 'test' && !$options['allow_failures'])
|
||||
if($stage == 'test')
|
||||
{
|
||||
$this->success = false;
|
||||
$this->plugins[$plugin] = false;
|
||||
|
||||
if(!$options['allow_failures'])
|
||||
{
|
||||
$this->success = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->logFailure('PLUGIN STATUS: FAILED');
|
||||
|
@ -225,13 +238,25 @@ class Builder
|
|||
{
|
||||
$this->logFailure('EXCEPTION: ' . $ex->getMessage());
|
||||
|
||||
if($stage == 'test' && !$options['allow_failures'])
|
||||
if($stage == 'test')
|
||||
{
|
||||
$this->success = false;
|
||||
continue;
|
||||
$this->plugins[$plugin] = false;
|
||||
|
||||
if(!$options['allow_failures'])
|
||||
{
|
||||
$this->success = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->logFailure('PLUGIN STATUS: FAILED');
|
||||
continue;
|
||||
}
|
||||
|
||||
if($stage == 'test')
|
||||
{
|
||||
$this->plugins[$plugin] = true;
|
||||
}
|
||||
|
||||
$this->logSuccess('PLUGIN STATUS: SUCCESS!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class BuildController extends b8\Controller
|
|||
$data = array();
|
||||
$data['status'] = (int)$build->getStatus();
|
||||
$data['log'] = $this->cleanLog($build->getLog());
|
||||
$data['plugins'] = json_decode($build->getPlugins(), true);
|
||||
$data['created'] = !is_null($build->getCreated()) ? $build->getCreated()->format('Y-m-d H:i:s') : null;
|
||||
$data['started'] = !is_null($build->getStarted()) ? $build->getStarted()->format('Y-m-d H:i:s') : null;
|
||||
$data['finished'] = !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : null;
|
||||
|
|
|
@ -25,6 +25,7 @@ class BuildBase extends Model
|
|||
'created' => null,
|
||||
'started' => null,
|
||||
'finished' => null,
|
||||
'plugins' => null,
|
||||
);
|
||||
protected $_getters = array(
|
||||
'id' => 'getId',
|
||||
|
@ -36,6 +37,7 @@ class BuildBase extends Model
|
|||
'created' => 'getCreated',
|
||||
'started' => 'getStarted',
|
||||
'finished' => 'getFinished',
|
||||
'plugins' => 'getPlugins',
|
||||
|
||||
'Project' => 'getProject',
|
||||
|
||||
|
@ -51,6 +53,7 @@ class BuildBase extends Model
|
|||
'created' => 'setCreated',
|
||||
'started' => 'setStarted',
|
||||
'finished' => 'setFinished',
|
||||
'plugins' => 'setPlugins',
|
||||
|
||||
'Project' => 'setProject',
|
||||
);
|
||||
|
@ -126,6 +129,14 @@ class BuildBase extends Model
|
|||
|
||||
|
||||
|
||||
),
|
||||
'plugins' => array(
|
||||
'type' => 'text',
|
||||
'length' => '',
|
||||
'nullable' => true,
|
||||
|
||||
|
||||
|
||||
),
|
||||
);
|
||||
public $indexes = array(
|
||||
|
@ -229,6 +240,14 @@ class BuildBase extends Model
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
public function getPlugins()
|
||||
{
|
||||
$rtn = $this->_data['plugins'];
|
||||
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setId($value)
|
||||
|
@ -357,6 +376,20 @@ class BuildBase extends Model
|
|||
$this->_setModified('finished');
|
||||
}
|
||||
|
||||
public function setPlugins($value)
|
||||
{
|
||||
|
||||
$this->_validateString('Plugins', $value);
|
||||
if($this->_data['plugins'] == $value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_data['plugins'] = $value;
|
||||
|
||||
$this->_setModified('plugins');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,12 +21,12 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
{
|
||||
$ignore = array_map(function($item)
|
||||
{
|
||||
return ' --exclude ' . (substr($item, -1) == '/' ? $item . '' : $item . '/');
|
||||
return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item);
|
||||
}, $this->phpci->ignore);
|
||||
|
||||
$ignore = ' ' . implode('', $ignore);
|
||||
$ignore = implode('', $ignore);
|
||||
}
|
||||
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd ' . $ignore . ' ' . $this->phpci->buildPath);
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd' . $ignore . ' ' . $this->phpci->buildPath);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,17 @@
|
|||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Plugin Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="plugins">
|
||||
<?= $plugins; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div id="status"></div>
|
||||
|
@ -125,6 +136,30 @@ setInterval(function()
|
|||
$('#finished').text('Not finished yet.');
|
||||
}
|
||||
|
||||
if(data.plugins)
|
||||
{
|
||||
$('#plugins').empty();
|
||||
|
||||
for(var plugin in data.plugins)
|
||||
{
|
||||
var row = $('<tr>').addClass(data.plugins[plugin] ? 'success' : 'error');
|
||||
var name = $('<td>').html('<strong>' + plugin + '</strong>');
|
||||
var status = $('<td>').text(data.plugins[plugin] ? 'OK' : 'Failed');
|
||||
|
||||
row.append(name);
|
||||
row.append(status);
|
||||
$('#plugins').append(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var row = $('<tr>');
|
||||
var col = $('<td>').attr('colspan', 2).text('No plugins have run yet.');
|
||||
|
||||
row.append(col);
|
||||
$('#plugins').empty().append(row);
|
||||
}
|
||||
|
||||
$('#log').html(data.log);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue