commit
c84a6a35b2
25
PHPCI/Plugin/Mysql.php
Normal file → Executable file
25
PHPCI/Plugin/Mysql.php
Normal file → Executable file
|
@ -20,7 +20,7 @@ use PDO;
|
|||
*/
|
||||
class Mysql implements \PHPCI\Plugin
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ class Mysql implements \PHPCI\Plugin
|
|||
protected $host;
|
||||
protected $user;
|
||||
protected $pass;
|
||||
|
||||
|
||||
/**
|
||||
* Database Connection
|
||||
* @var PDO
|
||||
|
@ -43,7 +43,8 @@ class Mysql implements \PHPCI\Plugin
|
|||
$this->queries = $options;
|
||||
|
||||
$config = \b8\Database::getConnection('write')->getDetails();
|
||||
$this->host = PHPCI_DB_HOST;
|
||||
|
||||
$this->host =(defined('PHPCI_DB_HOST')) ? PHPCI_DB_HOST : null;
|
||||
$this->user = $config['user'];
|
||||
$this->pass = $config['pass'];
|
||||
|
||||
|
@ -63,11 +64,11 @@ class Mysql implements \PHPCI\Plugin
|
|||
public function execute()
|
||||
{
|
||||
$success = true;
|
||||
|
||||
|
||||
try {
|
||||
$opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
||||
$this->pdo = new PDO('mysql:host=' . $this->host, $this->user, $this->pass, $opts);
|
||||
|
||||
|
||||
foreach ($this->queries as $query) {
|
||||
if (!is_array($query)) {
|
||||
// Simple query
|
||||
|
@ -86,28 +87,28 @@ class Mysql implements \PHPCI\Plugin
|
|||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
protected function executeFile($query)
|
||||
{
|
||||
if (!isset($query['file'])) {
|
||||
throw new \Exception("Import statement must contain a 'file' key");
|
||||
}
|
||||
|
||||
|
||||
$import_file = $this->phpci->buildPath . $this->phpci->interpolate($query['file']);
|
||||
if (!is_readable($import_file)) {
|
||||
throw new \Exception("Cannot open SQL import file: $import_file");
|
||||
}
|
||||
|
||||
|
||||
$database = isset($query['database'])? $this->phpci->interpolate($query['database']): null;
|
||||
|
||||
|
||||
$import_command = $this->getImportCommand($import_file, $database);
|
||||
if (!$this->phpci->executeCommand($import_command)) {
|
||||
throw new \Exception("Unable to execute SQL file");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the MySQL import command required to import/execute the specified file
|
||||
* @param string $import_file Path to file, relative to the build root
|
||||
|
@ -119,7 +120,7 @@ class Mysql implements \PHPCI\Plugin
|
|||
'bz2' => '| bzip2 --decompress',
|
||||
'gz' => '| gzip --decompress',
|
||||
);
|
||||
|
||||
|
||||
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
|
||||
$decomp_cmd = '';
|
||||
if (array_key_exists($extension, $decompression)) {
|
||||
|
|
19
PHPCI/Plugin/PhpCodeSniffer.php
Normal file → Executable file
19
PHPCI/Plugin/PhpCodeSniffer.php
Normal file → Executable file
|
@ -47,6 +47,17 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
*/
|
||||
protected $encoding;
|
||||
|
||||
/**
|
||||
* @var string, based on the assumption the root may not hold the code to be
|
||||
* tested, exteds the base path
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var array - paths to ignore
|
||||
*/
|
||||
protected $ignore;
|
||||
|
||||
/**
|
||||
* @param \PHPCI\Builder $phpci
|
||||
* @param array $options
|
||||
|
@ -59,6 +70,8 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
$this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2';
|
||||
$this->tab_width = isset($options['tab_width']) ? $options['tab_width'] : '';
|
||||
$this->encoding = isset($options['encoding']) ? $options['encoding'] : '';
|
||||
$this->path = (isset($options['path'])) ? $options['path'] : '';
|
||||
$this->ignore = (isset($options['ignore'])) ? (array)$options['ignore'] : $this->phpci->ignore;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,8 +80,8 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
if (count($this->phpci->ignore)) {
|
||||
$ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
|
||||
if (count($this->ignore)) {
|
||||
$ignore = ' --ignore=' . implode(',', $this->ignore);
|
||||
}
|
||||
|
||||
if (strpos($this->standard, '/') !== false) {
|
||||
|
@ -93,6 +106,6 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
}
|
||||
|
||||
$cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s %s "%s"';
|
||||
return $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $tab_width, $encoding, $this->phpci->buildPath);
|
||||
return $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $tab_width, $encoding, $this->phpci->buildPath . $this->path);
|
||||
}
|
||||
}
|
||||
|
|
20
PHPCI/Plugin/PhpCpd.php
Normal file → Executable file
20
PHPCI/Plugin/PhpCpd.php
Normal file → Executable file
|
@ -21,11 +21,25 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
protected $args;
|
||||
protected $phpci;
|
||||
|
||||
/**
|
||||
* @var string, based on the assumption the root may not hold the code to be
|
||||
* tested, exteds the base path
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var array - paths to ignore
|
||||
*/
|
||||
protected $ignore;
|
||||
|
||||
public function __construct(\PHPCI\Builder $phpci, array $options = array())
|
||||
{
|
||||
$this->phpci = $phpci;
|
||||
$this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath;
|
||||
$this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2';
|
||||
$this->path = (isset($options['path'])) ? $options['path'] : '';
|
||||
$this->ignore = (isset($options['ignore'])) ? (array)$options['ignore'] : $this->phpci->ignore;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,15 +48,15 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
if (count($this->phpci->ignore)) {
|
||||
if (count($this->ignore)) {
|
||||
$map = function ($item) {
|
||||
return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item);
|
||||
};
|
||||
$ignore = array_map($map, $this->phpci->ignore);
|
||||
$ignore = array_map($map, $this->ignore);
|
||||
|
||||
$ignore = implode('', $ignore);
|
||||
}
|
||||
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd %s "%s"', $ignore, $this->phpci->buildPath);
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd %s "%s"', $ignore, $this->phpci->buildPath.$this->path);
|
||||
}
|
||||
}
|
||||
|
|
21
PHPCI/Plugin/PhpMessDetector.php
Normal file → Executable file
21
PHPCI/Plugin/PhpMessDetector.php
Normal file → Executable file
|
@ -27,6 +27,17 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
*/
|
||||
protected $suffixes;
|
||||
|
||||
/**
|
||||
* @var string, based on the assumption the root may not hold the code to be
|
||||
* tested, exteds the base path
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var array - paths to ignore
|
||||
*/
|
||||
protected $ignore;
|
||||
|
||||
/**
|
||||
* Array of PHPMD rules. Can be one of the builtins (codesize, unusedcode, naming, design, controversial)
|
||||
* or a filenname (detected by checking for a / in it), either absolute or relative to the project root.
|
||||
|
@ -44,6 +55,10 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
|
||||
$this->suffixes = isset($options['suffixes']) ? (array)$options['suffixes'] : array('php');
|
||||
|
||||
$this->ignore = (isset($options['ignore'])) ? (array)$options['ignore'] : $this->phpci->ignore;
|
||||
|
||||
$this->path = (isset($options['path'])) ? $options['path'] : '';
|
||||
|
||||
$this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming');
|
||||
foreach ($this->rules as &$rule) {
|
||||
if ($rule[0] !== '/' && strpos($rule, '/') !== FALSE) {
|
||||
|
@ -58,8 +73,8 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
if (count($this->phpci->ignore)) {
|
||||
$ignore = ' --exclude ' . implode(',', $this->phpci->ignore);
|
||||
if (count($this->ignore)) {
|
||||
$ignore = ' --exclude ' . implode(',', $this->ignore);
|
||||
}
|
||||
|
||||
$suffixes = '';
|
||||
|
@ -68,6 +83,6 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
}
|
||||
|
||||
$cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s %s';
|
||||
return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore, $suffixes);
|
||||
return $this->phpci->executeCommand($cmd, $this->phpci->buildPath . $this->path, implode(',', $this->rules), $ignore, $suffixes);
|
||||
}
|
||||
}
|
||||
|
|
24
PHPCI/Plugin/PhpUnit.php
Normal file → Executable file
24
PHPCI/Plugin/PhpUnit.php
Normal file → Executable file
|
@ -24,12 +24,20 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
* @var string|string[] $directory The directory (or array of dirs) to run PHPUnit on
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
|
||||
/**
|
||||
* @var string $runFrom When running PHPUnit with an XML config, the command is run from this directory
|
||||
*/
|
||||
protected $runFrom;
|
||||
|
||||
/**
|
||||
* @var string, in cases where tests files are in a sub path of the /tests path,
|
||||
* allows this path to be set in the config.
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
protected $coverage = "";
|
||||
|
||||
/**
|
||||
* @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit
|
||||
*/
|
||||
|
@ -54,6 +62,14 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
if (isset($options['args'])) {
|
||||
$this->args = $options['args'];
|
||||
}
|
||||
|
||||
if (isset($options['path'])) {
|
||||
$this->path = $options['path'];
|
||||
}
|
||||
|
||||
if (isset($options['coverage'])) {
|
||||
$this->coverage = " --coverage-html {$options['coverage']} ";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +88,7 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
if ($this->directory !== null) {
|
||||
$success &= $this->runDir($this->directory);
|
||||
}
|
||||
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -86,9 +102,9 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
chdir($this->phpci->buildPath.'/'.$this->runFrom);
|
||||
}
|
||||
|
||||
$cmd = PHPCI_BIN_DIR . 'phpunit %s -c "%s"';
|
||||
$cmd = PHPCI_BIN_DIR . 'phpunit %s -c "%s" ' . $this->coverage . $this->path;
|
||||
$success = $this->phpci->executeCommand($cmd, $this->args, $this->phpci->buildPath . $configPath);
|
||||
|
||||
|
||||
if ($this->runFrom) {
|
||||
chdir($curdir);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<?php endif; ?>
|
||||
|
||||
<?php foreach($builds as $build): ?>
|
||||
|
||||
<?php
|
||||
switch($build->getStatus())
|
||||
{
|
||||
|
@ -37,7 +38,14 @@ switch($build->getStatus())
|
|||
?>
|
||||
<tr class="<?php print $cls; ?>">
|
||||
<td><a href="<?= PHPCI_URL ?>build/view/<?php print $build->getId(); ?>">#<?php print str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
|
||||
<td><a href="<?= PHPCI_URL ?>project/view/<?php print $build->getProjectId(); ?>"><?php print $build->getProject()->getTitle(); ?></a></td>
|
||||
<td><a href="<?= PHPCI_URL ?>project/view/<?php print $build->getProjectId(); ?>">
|
||||
<?php
|
||||
if (is_object($build->getProject())) {
|
||||
print $build->getProject()->getTitle();
|
||||
} else {
|
||||
print ' - ';
|
||||
}
|
||||
?></a></td>
|
||||
<td><a href="<?php print $build->getCommitLink(); ?>"><?php print $build->getCommitId(); ?></a></td>
|
||||
<td><a href="<?php print $build->getBranchLink(); ?>"><?php print $build->getBranch(); ?></a></td>
|
||||
<td>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div id="title">
|
||||
<h1>Project: <?php print $project->getTitle(); ?></h1>
|
||||
<h1>Project: <?php print (is_object($project)) ? $project->getTitle() : ' - '; ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
0
PHPCI/build/.gitignore
vendored
Normal file → Executable file
0
PHPCI/build/.gitignore
vendored
Normal file → Executable file
0
build/.gitignore
vendored
Normal file → Executable file
0
build/.gitignore
vendored
Normal file → Executable file
Loading…
Reference in a new issue