This commit is contained in:
Gabriel Baker 2013-05-14 04:08:26 -07:00
commit 5d7ab2a2d9
7 changed files with 149 additions and 147 deletions

View file

@ -121,29 +121,43 @@ class Builder
$commitId = $this->build->getCommitId(); $commitId = $this->build->getCommitId();
$url = $this->build->getProject()->getGitUrl(); $url = $this->build->getProject()->getGitUrl();
$key = $this->build->getProject()->getGitKey(); $key = $this->build->getProject()->getGitKey();
$type = $this->build->getProject()->getType();
$buildId = 'project' . $this->build->getProject()->getId() . '-build' . $this->build->getId(); $buildId = 'project' . $this->build->getProject()->getId() . '-build' . $this->build->getId();
$this->ciDir = realpath(dirname(__FILE__) . '/../') . '/'; $this->ciDir = realpath(dirname(__FILE__) . '/../') . '/';
$this->buildPath = $this->ciDir . 'build/' . $buildId . '/'; $this->buildPath = $this->ciDir . 'build/' . $buildId . '/';
mkdir($this->buildPath, 0777, true);
if(!empty($key)) switch ($type) {
{ case 'local':
// Do an SSH clone: $reference = $this->build->getProject()->getReference();
$keyFile = $this->ciDir . 'build/' . $buildId . '.key'; $this->buildPath = $this->ciDir . 'build/' . $buildId;
file_put_contents($keyFile, $key); if(is_link($this->buildPath) && is_file($this->buildPath)) {
chmod($keyFile, 0600); } else {
$this->executeCommand('ssh-agent ssh-add '.$keyFile.' && git clone -b ' .$this->build->getBranch() . ' ' .$url.' '.$this->buildPath.' && ssh-agent -k'); symlink($reference, $this->buildPath);
unlink($keyFile); }
$this->buildPath .= '/';
break;
default:
mkdir($this->buildPath, 0777, true);
if(!empty($key))
{
// Do an SSH clone:
$keyFile = $this->ciDir . 'build/' . $buildId . '.key';
file_put_contents($keyFile, $key);
chmod($keyFile, 0600);
$this->executeCommand('ssh-agent ssh-add '.$keyFile.' && git clone -b ' .$this->build->getBranch() . ' ' .$url.' '.$this->buildPath.' && ssh-agent -k');
unlink($keyFile);
}
else
{
// Do an HTTP clone:
$this->executeCommand('git clone -b ' .$this->build->getBranch() . ' ' .$url.' '.$this->buildPath);
}
break;
} }
else
{
// Do an HTTP clone:
$this->executeCommand('git clone -b ' .$this->build->getBranch() . ' ' .$url.' '.$this->buildPath);
}
if(!is_file($this->buildPath . 'phpci.yml')) if(!is_file($this->buildPath . 'phpci.yml'))
{ {
$this->logFailure('Project does not contain a phpci.yml file.'); $this->logFailure('Project does not contain a phpci.yml file.');
@ -179,6 +193,11 @@ class Builder
protected function executePlugins($stage) protected function executePlugins($stage)
{ {
if ( !array_key_exists($stage, $this->config) || !is_array($this->config[$stage]) )
{
return;
}
foreach($this->config[$stage] as $plugin => $options) foreach($this->config[$stage] as $plugin => $options)
{ {
$this->log(''); $this->log('');
@ -202,7 +221,7 @@ class Builder
{ {
$this->success = false; $this->success = false;
} }
continue; continue;
} }
@ -216,7 +235,7 @@ class Builder
{ {
$this->success = false; $this->success = false;
} }
$this->logFailure('PLUGIN STATUS: FAILED'); $this->logFailure('PLUGIN STATUS: FAILED');
continue; continue;
} }

View file

@ -128,7 +128,7 @@ class ProjectController extends b8\Controller
{ {
throw new \Exception('You do not have permission to do that.'); throw new \Exception('You do not have permission to do that.');
} }
$method = Registry::getInstance()->get('requestMethod'); $method = Registry::getInstance()->get('requestMethod');
$project = $this->_projectStore->getById($id); $project = $this->_projectStore->getById($id);
@ -180,15 +180,15 @@ class ProjectController extends b8\Controller
$field = new Form\Element\Select('type'); $field = new Form\Element\Select('type');
$field->setRequired(true); $field->setRequired(true);
$field->setOptions(array('github' => 'Github', 'bitbucket' => 'Bitbucket')); $field->setOptions(array('github' => 'Github', 'bitbucket' => 'Bitbucket', 'local' => 'Local FS'));
$field->setLabel('Where is your project hosted?'); $field->setLabel('Where is your project hosted?');
$field->setClass('span4'); $field->setClass('span4');
$form->addField($field); $form->addField($field);
$field = new Form\Element\Text('reference'); $field = new Form\Element\Text('reference');
$field->setRequired(true); $field->setRequired(true);
$field->setPattern('[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+'); // $field->setPattern('[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+');
$field->setLabel('Repository Name on Github / Bitbucket (e.g. block8/phpci)'); $field->setLabel('Repository Name on Github / Bitbucket (e.g. block8/phpci) or directory location');
$field->setClass('span4'); $field->setClass('span4');
$form->addField($field); $form->addField($field);

View file

@ -16,126 +16,104 @@ class BuildBase extends Model
protected $_tableName = 'build'; protected $_tableName = 'build';
protected $_modelName = 'Build'; protected $_modelName = 'Build';
protected $_data = array( protected $_data = array(
'id' => null, 'id' => null,
'project_id' => null, 'project_id' => null,
'commit_id' => null, 'commit_id' => null,
'status' => null, 'status' => null,
'log' => null, 'log' => null,
'branch' => null, 'branch' => null,
'created' => null, 'created' => null,
'started' => null, 'started' => null,
'finished' => null, 'finished' => null,
); );
protected $_getters = array( protected $_getters = array(
'id' => 'getId', 'id' => 'getId',
'project_id' => 'getProjectId', 'project_id' => 'getProjectId',
'commit_id' => 'getCommitId', 'commit_id' => 'getCommitId',
'status' => 'getStatus', 'status' => 'getStatus',
'log' => 'getLog', 'log' => 'getLog',
'branch' => 'getBranch', 'branch' => 'getBranch',
'created' => 'getCreated', 'created' => 'getCreated',
'started' => 'getStarted', 'started' => 'getStarted',
'finished' => 'getFinished', 'finished' => 'getFinished',
'Project' => 'getProject', 'Project' => 'getProject',
); );
protected $_setters = array( protected $_setters = array(
'id' => 'setId', 'id' => 'setId',
'project_id' => 'setProjectId', 'project_id' => 'setProjectId',
'commit_id' => 'setCommitId', 'commit_id' => 'setCommitId',
'status' => 'setStatus', 'status' => 'setStatus',
'log' => 'setLog', 'log' => 'setLog',
'branch' => 'setBranch', 'branch' => 'setBranch',
'created' => 'setCreated', 'created' => 'setCreated',
'started' => 'setStarted', 'started' => 'setStarted',
'finished' => 'setFinished', 'finished' => 'setFinished',
'Project' => 'setProject', 'Project' => 'setProject',
); );
public $columns = array( public $columns = array(
'id' => array( 'id' => array(
'type' => 'int', 'type' => 'int',
'length' => '11', 'length' => '11',
'primary_key' => true, 'primary_key' => true,
'auto_increment' => true, 'auto_increment' => true,
), ),
'project_id' => array( 'project_id' => array(
'type' => 'int', 'type' => 'int',
'length' => '11', 'length' => '11',
),
'commit_id' => array(
'type' => 'varchar',
'length' => '50',
),
'status' => array(
'type' => 'tinyint',
'length' => '4',
),
'log' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
), ),
'commit_id' => array( 'branch' => array(
'type' => 'varchar', 'type' => 'varchar',
'length' => '50', 'length' => '50',
),
'created' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'started' => array(
), 'type' => 'datetime',
'status' => array( 'length' => '',
'type' => 'tinyint', 'nullable' => true,
'length' => '4', ),
'finished' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
), ),
'log' => array( );
'type' => 'text',
'length' => '',
'nullable' => true,
),
'branch' => array(
'type' => 'varchar',
'length' => '50',
),
'created' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'started' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'finished' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
);
public $indexes = array( public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'), 'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'), 'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'), 'idx_status' => array('columns' => 'status'),
); );
public $foreignKeys = array( public $foreignKeys = array(
'build_ibfk_1' => array('local_col' => 'project_id', 'update' => 'CASCADE', 'delete' => 'CASCADE', 'table' => 'project', 'col' => 'id'), 'build_ibfk_1' => array('local_col' => 'project_id', 'update' => 'CASCADE', 'delete' => 'CASCADE', 'table' => 'project', 'col' => 'id'),
); );
@ -143,7 +121,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['id']; $rtn = $this->_data['id'];
return $rtn; return $rtn;
} }
@ -151,7 +129,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['project_id']; $rtn = $this->_data['project_id'];
return $rtn; return $rtn;
} }
@ -159,7 +137,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['commit_id']; $rtn = $this->_data['commit_id'];
return $rtn; return $rtn;
} }
@ -167,7 +145,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['status']; $rtn = $this->_data['status'];
return $rtn; return $rtn;
} }
@ -175,7 +153,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['log']; $rtn = $this->_data['log'];
return $rtn; return $rtn;
} }
@ -183,7 +161,7 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['branch']; $rtn = $this->_data['branch'];
return $rtn; return $rtn;
} }
@ -191,13 +169,13 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['created']; $rtn = $this->_data['created'];
if(!empty($rtn)) if(!empty($rtn))
{ {
$rtn = new \DateTime($rtn); $rtn = new \DateTime($rtn);
} }
return $rtn; return $rtn;
} }
@ -205,13 +183,13 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['started']; $rtn = $this->_data['started'];
if(!empty($rtn)) if(!empty($rtn))
{ {
$rtn = new \DateTime($rtn); $rtn = new \DateTime($rtn);
} }
return $rtn; return $rtn;
} }
@ -219,13 +197,13 @@ class BuildBase extends Model
{ {
$rtn = $this->_data['finished']; $rtn = $this->_data['finished'];
if(!empty($rtn)) if(!empty($rtn))
{ {
$rtn = new \DateTime($rtn); $rtn = new \DateTime($rtn);
} }
return $rtn; return $rtn;
} }
@ -277,7 +255,7 @@ class BuildBase extends Model
{ {
$this->_validateNotNull('Status', $value); $this->_validateNotNull('Status', $value);
$this->_validateInt('Status', $value); $this->_validateInt('Status', $value);
if($this->_data['status'] == $value) if($this->_data['status'] === $value)
{ {
return; return;
} }

View file

@ -94,7 +94,7 @@ class ProjectBase extends Model
{ {
$rtn = $this->_data['id']; $rtn = $this->_data['id'];
return $rtn; return $rtn;
} }
@ -102,7 +102,7 @@ class ProjectBase extends Model
{ {
$rtn = $this->_data['title']; $rtn = $this->_data['title'];
return $rtn; return $rtn;
} }
@ -110,7 +110,7 @@ class ProjectBase extends Model
{ {
$rtn = $this->_data['reference']; $rtn = $this->_data['reference'];
return $rtn; return $rtn;
} }
@ -118,7 +118,7 @@ class ProjectBase extends Model
{ {
$rtn = $this->_data['git_key']; $rtn = $this->_data['git_key'];
return $rtn; return $rtn;
} }
@ -126,7 +126,7 @@ class ProjectBase extends Model
{ {
$rtn = $this->_data['type']; $rtn = $this->_data['type'];
return $rtn; return $rtn;
} }
@ -150,7 +150,7 @@ class ProjectBase extends Model
{ {
$this->_validateNotNull('Title', $value); $this->_validateNotNull('Title', $value);
$this->_validateString('Title', $value); $this->_validateString('Title', $value);
if($this->_data['title'] == $value) if($this->_data['title'] === $value)
{ {
return; return;
} }
@ -164,7 +164,7 @@ class ProjectBase extends Model
{ {
$this->_validateNotNull('Reference', $value); $this->_validateNotNull('Reference', $value);
$this->_validateString('Reference', $value); $this->_validateString('Reference', $value);
if($this->_data['reference'] == $value) if($this->_data['reference'] === $value)
{ {
return; return;
} }
@ -178,7 +178,7 @@ class ProjectBase extends Model
{ {
$this->_validateNotNull('GitKey', $value); $this->_validateNotNull('GitKey', $value);
$this->_validateString('GitKey', $value); $this->_validateString('GitKey', $value);
if($this->_data['git_key'] == $value) if($this->_data['git_key'] === $value)
{ {
return; return;
} }
@ -192,7 +192,7 @@ class ProjectBase extends Model
{ {
$this->_validateNotNull('Type', $value); $this->_validateNotNull('Type', $value);
$this->_validateString('Type', $value); $this->_validateString('Type', $value);
if($this->_data['type'] == $value) if($this->_data['type'] === $value)
{ {
return; return;
} }

View file

@ -17,6 +17,10 @@ class PhpUnit implements \PHPCI\Plugin
public function execute() public function execute()
{ {
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory); $curdir = getcwd();
chdir($this->phpci->buildPath);
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory);
chdir($curdir);
return $success;
} }
} }

View file

@ -25,6 +25,7 @@
"require": { "require": {
"block8/b8framework": "dev-master", "block8/b8framework": "dev-master",
"phpunit/phpunit": "3.*", "phpunit/phpunit": "3.*",
"phpunit/php-code-coverage": "1.2.x",
"phpmd/phpmd" : "1.*", "phpmd/phpmd" : "1.*",
"sebastian/phpcpd": "1.*", "sebastian/phpcpd": "1.*",
"squizlabs/php_codesniffer": "1.*", "squizlabs/php_codesniffer": "1.*",

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B