diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index d10f34b7..318871a5 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -16,6 +16,7 @@ use b8\Config; use b8\Store\Factory; use PHPCI\Helper\Lang; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\DialogHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -46,6 +47,9 @@ class InstallCommand extends Command ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass')) ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email')) ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath) + ->addOption('queue-disabled', null, InputOption::VALUE_NONE, 'Don\'t ask for queue details') + ->addOption('queue-server', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') + ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') ->setDescription(Lang::get('install_phpci')); } @@ -229,10 +233,37 @@ class InstallCommand extends Command } $phpci['url'] = $url; + $phpci['worker'] = $this->getQueueInformation($input, $output, $dialog); return $phpci; } + /** + * If the user wants to use a queue, get the necessary details. + * @param InputInterface $input + * @param OutputInterface $output + * @param DialogHelper $dialog + * @return array + */ + protected function getQueueInformation(InputInterface $input, OutputInterface $output, DialogHelper $dialog) + { + if ($input->getOption('queue-disabled')) { + return null; + } + + $rtn = []; + + if (!$rtn['host'] = $input->getOption('queue-server')) { + $rtn['host'] = $dialog->ask($output, 'Enter your beanstalkd hostname [localhost]: ', 'localhost'); + } + + if (!$rtn['queue'] = $input->getOption('queue-name')) { + $rtn['queue'] = $dialog->ask($output, 'Enter the queue (tube) name to use [phpci]: ', 'phpci'); + } + + return $rtn; + } + /** * Load configuration for DB form CLI options or ask info to user. * diff --git a/PHPCI/Command/RebuildQueueCommand.php b/PHPCI/Command/RebuildQueueCommand.php new file mode 100644 index 00000000..4b0af6d8 --- /dev/null +++ b/PHPCI/Command/RebuildQueueCommand.php @@ -0,0 +1,85 @@ + +* @package PHPCI +* @subpackage Console +*/ +class RebuildQueueCommand extends Command +{ + /** + * @var OutputInterface + */ + protected $output; + + /** + * @var Logger + */ + protected $logger; + + /** + * @param \Monolog\Logger $logger + * @param string $name + */ + public function __construct(Logger $logger, $name = null) + { + parent::__construct($name); + $this->logger = $logger; + } + + protected function configure() + { + $this + ->setName('phpci:rebuild-queue') + ->setDescription('Rebuilds the PHPCI worker queue.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->output = $output; + + // For verbose mode we want to output all informational and above + // messages to the symphony output interface. + if ($input->hasOption('verbose') && $input->getOption('verbose')) { + $this->logger->pushHandler( + new OutputLogHandler($this->output, Logger::INFO) + ); + } + + $store = Factory::getStore('Build'); + $result = $store->getByStatus(0); + + $this->logger->addInfo(Lang::get('found_n_builds', count($result['items']))); + + $buildService = new BuildService($store); + + while (count($result['items'])) { + $build = array_shift($result['items']); + $build = BuildFactory::getBuild($build); + + $this->logger->addInfo('Added build #' . $build->getId() . ' to queue.'); + $buildService->addBuildToQueue($build); + } + } +} diff --git a/PHPCI/Model/Build.php b/PHPCI/Model/Build.php index bf8d9379..a8bfd683 100644 --- a/PHPCI/Model/Build.php +++ b/PHPCI/Model/Build.php @@ -258,7 +258,7 @@ class Build extends BuildBase if (empty($this->currentBuildPath)) { $buildDirectory = $this->getId() . '_' . substr(md5(microtime(true)), 0, 5); - $this->currentBuildPath = PHPCI_BUILD_ROOT_DIR . $buildDirectory . '/'; + $this->currentBuildPath = PHPCI_BUILD_ROOT_DIR . $buildDirectory . DIRECTORY_SEPARATOR; } return $this->currentBuildPath; diff --git a/PHPCI/Plugin/Campfire.php b/PHPCI/Plugin/Campfire.php index 325e6e40..59ab9128 100644 --- a/PHPCI/Plugin/Campfire.php +++ b/PHPCI/Plugin/Campfire.php @@ -38,19 +38,19 @@ class Campfire implements \PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; - $this->build = $build; - - $this->message = $options['message']; + $this->phpci = $phpci; + $this->build = $build; + $this->message = $options['message']; $this->userAgent = "PHPCI/1.0 (+http://www.phptesting.org/)"; - $this->cookie = "phpcicookie"; + $this->cookie = "phpcicookie"; $buildSettings = $phpci->getConfig('build_settings'); + if (isset($buildSettings['campfire'])) { - $campfire = $buildSettings['campfire']; - $this->url = $campfire['url']; + $campfire = $buildSettings['campfire']; + $this->url = $campfire['url']; $this->authToken = $campfire['authToken']; - $this->roomId = $campfire['roomId']; + $this->roomId = $campfire['roomId']; } else { throw new \Exception(Lang::get('no_campfire_settings')); } @@ -63,7 +63,7 @@ class Campfire implements \PHPCI\Plugin */ public function execute() { - $url = PHPCI_URL."build/view/".$this->build->getId(); + $url = PHPCI_URL . "build/view/" . $this->build->getId(); $message = str_replace("%buildurl%", $url, $this->message); $this->joinRoom($this->roomId); $status = $this->speak($message, $this->roomId); @@ -101,6 +101,7 @@ class Campfire implements \PHPCI\Plugin public function speak($message, $roomId, $isPaste = false) { $page = '/room/'.$roomId.'/speak.json'; + if ($isPaste) { $type = 'PasteMessage'; } else { @@ -143,10 +144,12 @@ class Campfire implements \PHPCI\Plugin // We tend to get one space with an otherwise blank response $output = trim($output); + if (strlen($output)) { /* Responses are JSON. Decode it to a data structure */ return json_decode($output); } + // Simple 200 OK response (such as for joining a room) return true; } diff --git a/PHPCI/Plugin/CleanBuild.php b/PHPCI/Plugin/CleanBuild.php index 2d33aee4..684e8e7a 100644 --- a/PHPCI/Plugin/CleanBuild.php +++ b/PHPCI/Plugin/CleanBuild.php @@ -39,9 +39,9 @@ class CleanBuild implements \PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; - $this->build = $build; - $this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : array(); + $this->phpci = $phpci; + $this->build = $build; + $this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : array(); } /** @@ -57,7 +57,7 @@ class CleanBuild implements \PHPCI\Plugin $this->phpci->executeCommand($cmd, $this->phpci->buildPath . 'composer.lock'); $success = true; - + foreach ($this->remove as $file) { $ok = $this->phpci->executeCommand($cmd, $this->phpci->buildPath . $file); diff --git a/PHPCI/Plugin/Codeception.php b/PHPCI/Plugin/Codeception.php index 79f05cdf..c28e3a48 100644 --- a/PHPCI/Plugin/Codeception.php +++ b/PHPCI/Plugin/Codeception.php @@ -83,7 +83,7 @@ class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin { $this->phpci = $phpci; $this->build = $build; - $this->path = 'tests/_output/'; + $this->path = 'tests' . DIRECTORY_SEPARATOR . '_output' . DIRECTORY_SEPARATOR; if (empty($options['config'])) { $this->ymlConfigFile = self::findConfigFile($this->phpci->buildPath); @@ -148,9 +148,9 @@ class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin $output = $parser->parse(); $meta = array( - 'tests' => $parser->getTotalTests(), + 'tests' => $parser->getTotalTests(), 'timetaken' => $parser->getTotalTimeTaken(), - 'failures' => $parser->getTotalFailures() + 'failures' => $parser->getTotalFailures() ); $this->build->storeMeta('codeception-meta', $meta); diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index 38cf4d0e..bd5f6658 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -38,7 +38,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin */ public static function canExecute($stage, Builder $builder, Build $build) { - $path = $builder->buildPath . '/composer.json'; + $path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json'; if (file_exists($path) && $stage == 'setup') { return true; @@ -55,16 +55,16 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $path = $phpci->buildPath; - $this->phpci = $phpci; - $this->build = $build; - $this->directory = $path; - $this->action = 'install'; + $path = $phpci->buildPath; + $this->phpci = $phpci; + $this->build = $build; + $this->directory = $path; + $this->action = 'install'; $this->preferDist = false; - $this->nodev = false; + $this->nodev = false; if (array_key_exists('directory', $options)) { - $this->directory = $path . '/' . $options['directory']; + $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; } if (array_key_exists('action', $options)) { diff --git a/PHPCI/Plugin/CopyBuild.php b/PHPCI/Plugin/CopyBuild.php index 7f447291..f9646cac 100644 --- a/PHPCI/Plugin/CopyBuild.php +++ b/PHPCI/Plugin/CopyBuild.php @@ -35,12 +35,12 @@ class CopyBuild implements \PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $path = $phpci->buildPath; - $this->phpci = $phpci; - $this->build = $build; - $this->directory = isset($options['directory']) ? $options['directory'] : $path; - $this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false; - $this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; + $path = $phpci->buildPath; + $this->phpci = $phpci; + $this->build = $build; + $this->directory = isset($options['directory']) ? $options['directory'] : $path; + $this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false; + $this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; } /** diff --git a/PHPCI/Plugin/Email.php b/PHPCI/Plugin/Email.php index 8faa5bb7..17e235e2 100644 --- a/PHPCI/Plugin/Email.php +++ b/PHPCI/Plugin/Email.php @@ -52,9 +52,9 @@ class Email implements \PHPCI\Plugin Build $build, array $options = array() ) { - $this->phpci = $phpci; - $this->build = $build; - $this->options = $options; + $this->phpci = $phpci; + $this->build = $build; + $this->options = $options; } /** diff --git a/PHPCI/Plugin/Env.php b/PHPCI/Plugin/Env.php index 4e4b6563..b89bf67d 100644 --- a/PHPCI/Plugin/Env.php +++ b/PHPCI/Plugin/Env.php @@ -52,7 +52,7 @@ class Env implements \PHPCI\Plugin // This allows the standard syntax: "FOO: bar" $env_var = "$key=$value"; } - + if (!putenv($this->phpci->interpolate($env_var))) { $success = false; $this->phpci->logFailure(Lang::get('unable_to_set_env')); diff --git a/PHPCI/Plugin/Grunt.php b/PHPCI/Plugin/Grunt.php index 1ad0ceec..4d62ffd8 100644 --- a/PHPCI/Plugin/Grunt.php +++ b/PHPCI/Plugin/Grunt.php @@ -52,7 +52,7 @@ class Grunt implements \PHPCI\Plugin // Handle options: if (isset($options['directory'])) { - $this->directory = $path . '/' . $options['directory']; + $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; } if (isset($options['task'])) { diff --git a/PHPCI/Plugin/Gulp.php b/PHPCI/Plugin/Gulp.php index 97ad9246..b6c6cab4 100644 --- a/PHPCI/Plugin/Gulp.php +++ b/PHPCI/Plugin/Gulp.php @@ -52,7 +52,7 @@ class Gulp implements \PHPCI\Plugin // Handle options: if (isset($options['directory'])) { - $this->directory = $path . '/' . $options['directory']; + $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; } if (isset($options['task'])) { diff --git a/PHPCI/Plugin/Lint.php b/PHPCI/Plugin/Lint.php index 90436d70..a7ddc55c 100644 --- a/PHPCI/Plugin/Lint.php +++ b/PHPCI/Plugin/Lint.php @@ -41,9 +41,9 @@ class Lint implements PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; + $this->phpci = $phpci; $this->build = $build; - $this->directories = array(''); + $this->directories = array(''); $this->ignore = $phpci->ignore; if (!empty($options['directory'])) { @@ -93,7 +93,7 @@ class Lint implements PHPCI\Plugin if ($item->isFile() && $item->getExtension() == 'php' && !$this->lintFile($php, $itemPath)) { $success = false; - } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($php, $itemPath . '/')) { + } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($php, $itemPath . DIRECTORY_SEPARATOR)) { $success = false; } diff --git a/PHPCI/Plugin/PackageBuild.php b/PHPCI/Plugin/PackageBuild.php index 09e4de0d..fb116640 100644 --- a/PHPCI/Plugin/PackageBuild.php +++ b/PHPCI/Plugin/PackageBuild.php @@ -33,12 +33,12 @@ class PackageBuild implements \PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $path = $phpci->buildPath; - $this->build = $build; - $this->phpci = $phpci; - $this->directory = isset($options['directory']) ? $options['directory'] : $path; - $this->filename = isset($options['filename']) ? $options['filename'] : 'build'; - $this->format = isset($options['format']) ? $options['format'] : 'zip'; + $path = $phpci->buildPath; + $this->build = $build; + $this->phpci = $phpci; + $this->directory = isset($options['directory']) ? $options['directory'] : $path; + $this->filename = isset($options['filename']) ? $options['filename'] : 'build'; + $this->format = isset($options['format']) ? $options['format'] : 'zip'; } /** @@ -46,7 +46,7 @@ class PackageBuild implements \PHPCI\Plugin */ public function execute() { - $path = $this->phpci->buildPath; + $path = $this->phpci->buildPath; $build = $this->build; if ($this->directory == $path) { diff --git a/PHPCI/Plugin/Pgsql.php b/PHPCI/Plugin/Pgsql.php index 9d0f924d..60057464 100644 --- a/PHPCI/Plugin/Pgsql.php +++ b/PHPCI/Plugin/Pgsql.php @@ -73,9 +73,9 @@ class Pgsql implements \PHPCI\Plugin } /** - * Connects to PgSQL and runs a specified set of queries. - * @return boolean - */ + * Connects to PgSQL and runs a specified set of queries. + * @return boolean + */ public function execute() { try { diff --git a/PHPCI/Plugin/Phar.php b/PHPCI/Plugin/Phar.php index 0500fddc..c734bb6c 100644 --- a/PHPCI/Plugin/Phar.php +++ b/PHPCI/Plugin/Phar.php @@ -213,7 +213,7 @@ class Phar implements \PHPCI\Plugin $content = ''; $filename = $this->getStub(); if ($filename) { - $content = file_get_contents($this->getPHPCI()->buildPath . '/' . $this->getStub()); + $content = file_get_contents($this->getPHPCI()->buildPath . DIRECTORY_SEPARATOR . $this->getStub()); } return $content; } @@ -227,7 +227,8 @@ class Phar implements \PHPCI\Plugin $success = false; try { - $phar = new PHPPhar($this->getDirectory() . '/' . $this->getFilename(), 0, $this->getFilename()); + $file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename(); + $phar = new PHPPhar($file, 0, $this->getFilename()); $phar->buildFromDirectory($this->getPHPCI()->buildPath, $this->getRegExp()); $stub = $this->getStubContent(); @@ -236,7 +237,6 @@ class Phar implements \PHPCI\Plugin } $success = true; - } catch (Exception $e) { $this->getPHPCI()->log(Lang::get('phar_internal_error')); $this->getPHPCI()->log($e->getMessage()); diff --git a/PHPCI/Plugin/Phing.php b/PHPCI/Plugin/Phing.php index 3a5bd834..e322b72e 100644 --- a/PHPCI/Plugin/Phing.php +++ b/PHPCI/Plugin/Phing.php @@ -47,7 +47,7 @@ class Phing implements \PHPCI\Plugin * Set working directory */ if (isset($options['directory'])) { - $directory = $phpci->buildPath . '/' . $options['directory']; + $directory = $phpci->buildPath . DIRECTORY_SEPARATOR . $options['directory']; } else { $directory = $phpci->buildPath; } @@ -255,7 +255,7 @@ class Phing implements \PHPCI\Plugin */ public function setPropertyFile($propertyFile) { - if (!file_exists($this->getDirectory() . '/' . $propertyFile)) { + if (!file_exists($this->getDirectory() . DIRECTORY_SEPARATOR . $propertyFile)) { throw new \Exception(Lang::get('property_file_missing')); } diff --git a/PHPCI/Plugin/PhpCpd.php b/PHPCI/Plugin/PhpCpd.php index ae497ab6..2424d41e 100644 --- a/PHPCI/Plugin/PhpCpd.php +++ b/PHPCI/Plugin/PhpCpd.php @@ -75,9 +75,9 @@ class PhpCpd implements \PHPCI\Plugin if (count($this->ignore)) { $map = function ($item) { // remove the trailing slash - $item = rtrim($item, '/'); + $item = rtrim($item, DIRECTORY_SEPARATOR); - if (is_file($this->path . '/' . $item)) { + if (is_file(rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item)) { return ' --names-exclude ' . $item; } else { return ' --exclude ' . $item; diff --git a/PHPCI/Plugin/PhpCsFixer.php b/PHPCI/Plugin/PhpCsFixer.php index 817f3efc..9aa0d33f 100644 --- a/PHPCI/Plugin/PhpCsFixer.php +++ b/PHPCI/Plugin/PhpCsFixer.php @@ -32,10 +32,10 @@ class PhpCsFixer implements \PHPCI\Plugin protected $build; protected $workingDir = ''; - protected $level = ' --level=psr2'; - protected $verbose = ''; - protected $diff = ''; - protected $levels = array('psr0', 'psr1', 'psr2', 'symfony'); + protected $level = ' --level=psr2'; + protected $verbose = ''; + protected $diff = ''; + protected $levels = array('psr0', 'psr1', 'psr2', 'symfony'); /** * Standard Constructor diff --git a/PHPCI/Plugin/PhpLoc.php b/PHPCI/Plugin/PhpLoc.php index eb5af6ff..c8dedb91 100644 --- a/PHPCI/Plugin/PhpLoc.php +++ b/PHPCI/Plugin/PhpLoc.php @@ -69,19 +69,20 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin public function execute() { $ignore = ''; - if (count($this->phpci->ignore)) { - $map = function ($item) { - return ' --exclude ' . rtrim($item, '/'); - }; - $ignore = array_map($map, $this->phpci->ignore); + if (count($this->phpci->ignore)) { + $map = function ($item) { + return ' --exclude ' . rtrim($item, DIRECTORY_SEPARATOR); + }; + + $ignore = array_map($map, $this->phpci->ignore); $ignore = implode('', $ignore); } $phploc = $this->phpci->findBinary('phploc'); $success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory); - $output = $this->phpci->getLastOutput(); + $output = $this->phpci->getLastOutput(); if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches)) { $data = array(); diff --git a/PHPCI/Plugin/PhpParallelLint.php b/PHPCI/Plugin/PhpParallelLint.php index 8b7528de..febed528 100644 --- a/PHPCI/Plugin/PhpParallelLint.php +++ b/PHPCI/Plugin/PhpParallelLint.php @@ -55,10 +55,10 @@ class PhpParallelLint implements \PHPCI\Plugin */ public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; - $this->build = $build; - $this->directory = $phpci->buildPath; - $this->ignore = $this->phpci->ignore; + $this->phpci = $phpci; + $this->build = $build; + $this->directory = $phpci->buildPath; + $this->ignore = $this->phpci->ignore; if (isset($options['directory'])) { $this->directory = $phpci->buildPath.$options['directory']; diff --git a/PHPCI/Plugin/PhpTalLint.php b/PHPCI/Plugin/PhpTalLint.php index e12b6c34..8513ec36 100644 --- a/PHPCI/Plugin/PhpTalLint.php +++ b/PHPCI/Plugin/PhpTalLint.php @@ -155,7 +155,7 @@ class PhpTalLint implements PHPCI\Plugin if (!$this->lintFile($itemPath)) { $success = false; } - } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($itemPath . '/')) { + } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($itemPath . DIRECTORY_SEPARATOR)) { $success = false; } @@ -202,7 +202,9 @@ class PhpTalLint implements PHPCI\Plugin list($suffixes, $tales) = $this->getFlags(); - $lint = dirname(__FILE__) . '/../../vendor/phptal/phptal/tools/phptal_lint.php'; + $lint = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; + $lint .= 'vendor' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR; + $lint .= 'tools' . DIRECTORY_SEPARATOR . 'phptal_lint.php'; $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"'; $this->phpci->executeCommand($cmd, $suffixes, $tales, $this->phpci->buildPath . $path); @@ -222,7 +224,7 @@ class PhpTalLint implements PHPCI\Plugin $row = str_replace('(use -i to include your custom modifier functions)', '', $row); $message = str_replace($name . ': ', '', $row); - + $parts = explode(' (line ', $message); $message = trim($parts[0]); diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index 9b8aeccc..f716f079 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -76,8 +76,8 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin return 'phpunit.xml'; } - if (file_exists($buildPath . 'tests/phpunit.xml')) { - return 'tests/phpunit.xml'; + if (file_exists($buildPath . 'tests' . DIRECTORY_SEPARATOR . 'phpunit.xml')) { + return 'tests' . DIRECTORY_SEPARATOR . 'phpunit.xml'; } if (file_exists($buildPath . 'phpunit.xml.dist')) { @@ -85,7 +85,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin } if (file_exists($buildPath . 'tests/phpunit.xml.dist')) { - return 'tests/phpunit.xml.dist'; + return 'tests' . DIRECTORY_SEPARATOR . 'phpunit.xml.dist'; } return null; @@ -194,7 +194,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin } else { if ($this->runFrom) { $curdir = getcwd(); - chdir($this->phpci->buildPath.'/'.$this->runFrom); + chdir($this->phpci->buildPath . DIRECTORY_SEPARATOR . $this->runFrom); } $phpunit = $this->phpci->findBinary('phpunit'); diff --git a/PHPCI/Plugin/TechnicalDebt.php b/PHPCI/Plugin/TechnicalDebt.php index b7aa5bd8..6d4711b5 100755 --- a/PHPCI/Plugin/TechnicalDebt.php +++ b/PHPCI/Plugin/TechnicalDebt.php @@ -163,7 +163,7 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin } // Ignore hidden files, else .git, .sass_cache, etc. all get looped over - if (stripos($filePath, '/.') !== false) { + if (stripos($filePath, DIRECTORY_SEPARATOR . '.') !== false) { $skipFile = true; } diff --git a/PHPCI/Plugin/Util/Factory.php b/PHPCI/Plugin/Util/Factory.php index 30c68340..b6d11e5e 100644 --- a/PHPCI/Plugin/Util/Factory.php +++ b/PHPCI/Plugin/Util/Factory.php @@ -8,8 +8,8 @@ namespace PHPCI\Plugin\Util; */ class Factory { - const TYPE_ARRAY = "array"; - const TYPE_CALLABLE = "callable"; + const TYPE_ARRAY = "array"; + const TYPE_CALLABLE = "callable"; const INTERFACE_PHPCI_PLUGIN = '\PHPCI\Plugin'; private $currentPluginOptions; diff --git a/PHPCI/Plugin/Util/FilesPluginInformation.php b/PHPCI/Plugin/Util/FilesPluginInformation.php index d5ccebd5..35587283 100644 --- a/PHPCI/Plugin/Util/FilesPluginInformation.php +++ b/PHPCI/Plugin/Util/FilesPluginInformation.php @@ -56,6 +56,7 @@ class FilesPluginInformation implements InstalledPluginInformation if ($this->pluginInfo === null) { $this->loadPluginInfo(); } + return $this->pluginInfo; } @@ -83,7 +84,7 @@ class FilesPluginInformation implements InstalledPluginInformation $this->pluginInfo = array(); foreach ($this->files as $fileInfo) { if ($fileInfo instanceof \SplFileInfo) { - if ($fileInfo->isFile() && $fileInfo->getExtension()=='php') { + if ($fileInfo->isFile() && $fileInfo->getExtension() == 'php') { $this->addPluginFromFile($fileInfo); } } @@ -99,11 +100,11 @@ class FilesPluginInformation implements InstalledPluginInformation $class = $this->getFullClassFromFile($fileInfo); if (!is_null($class)) { - $newPlugin = new \stdClass(); - $newPlugin->class = $class; + $newPlugin = new \stdClass(); + $newPlugin->class = $class; $newPlugin->source = "core"; - $parts = explode('\\', $newPlugin->class); - $newPlugin->name = end($parts); + $parts = explode('\\', $newPlugin->class); + $newPlugin->name = end($parts); $this->pluginInfo[] = $newPlugin; } @@ -123,11 +124,11 @@ class FilesPluginInformation implements InstalledPluginInformation if (isset($matches[1])) { $className = $matches[1]; - + $matches = array(); preg_match('#namespace +([A-Za-z\\\\]+);#i', $contents, $matches); $namespace = $matches[1]; - + return $namespace . '\\' . $className; } else { return null; diff --git a/PHPCI/Plugin/Util/PluginInformationCollection.php b/PHPCI/Plugin/Util/PluginInformationCollection.php index 16341733..906935e5 100644 --- a/PHPCI/Plugin/Util/PluginInformationCollection.php +++ b/PHPCI/Plugin/Util/PluginInformationCollection.php @@ -32,9 +32,11 @@ class PluginInformationCollection implements InstalledPluginInformation public function getInstalledPlugins() { $arr = array(); + foreach ($this->pluginInformations as $single) { $arr = array_merge($arr, $single->getInstalledPlugins()); } + return $arr; } @@ -47,9 +49,11 @@ class PluginInformationCollection implements InstalledPluginInformation public function getPluginClasses() { $arr = array(); + foreach ($this->pluginInformations as $single) { $arr = array_merge($arr, $single->getPluginClasses()); } + return $arr; } } diff --git a/PHPCI/Plugin/Util/TapParser.php b/PHPCI/Plugin/Util/TapParser.php index b48f6f00..86981566 100644 --- a/PHPCI/Plugin/Util/TapParser.php +++ b/PHPCI/Plugin/Util/TapParser.php @@ -235,18 +235,20 @@ class TapParser */ protected function processYamlBlock($indent) { - $startLine = $this->lineNumber+1; - $endLine = $indent.'...'; + $startLine = $this->lineNumber + 1; + $endLine = $indent . '...'; $yamlLines = array(); + do { $line = $this->nextLine(); + if ($line === false) { throw new Exception(Lang::get('tap_error_endless_yaml', $startLine)); } elseif ($line === $endLine) { break; } - $yamlLines[] = substr($line, strlen($indent)); + $yamlLines[] = substr($line, strlen($indent)); } while (true); return Yaml::parse(join("\n", $yamlLines)); diff --git a/PHPCI/Plugin/Xmpp.php b/PHPCI/Plugin/Xmpp.php index 0362aa85..ccfc4399 100644 --- a/PHPCI/Plugin/Xmpp.php +++ b/PHPCI/Plugin/Xmpp.php @@ -132,8 +132,9 @@ class XMPP implements \PHPCI\Plugin */ public function findConfigFile() { - if (file_exists($this->phpci->buildPath . '/.sendxmpprc')) { - if (md5(file_get_contents($this->phpci->buildPath . '/.sendxmpprc')) !== md5($this->getConfigFormat())) { + if (file_exists($this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) { + if (md5(file_get_contents($this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) + !== md5($this->getConfigFormat())) { return null; } @@ -160,7 +161,7 @@ class XMPP implements \PHPCI\Plugin /* * Try to build conf file */ - $config_file = $this->phpci->buildPath . '/.sendxmpprc'; + $config_file = $this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc'; if (is_null($this->findConfigFile())) { file_put_contents($config_file, $this->getConfigFormat()); chmod($config_file, 0600); @@ -174,7 +175,7 @@ class XMPP implements \PHPCI\Plugin $tls = ' -t'; } - $message_file = $this->phpci->buildPath . '/' . uniqid('xmppmessage'); + $message_file = $this->phpci->buildPath . DIRECTORY_SEPARATOR . uniqid('xmppmessage'); if ($this->buildMessage($message_file) === false) { return false; } diff --git a/PHPCI/Store/BuildErrorStore.php b/PHPCI/Store/BuildErrorStore.php index 9ba92310..815a4d18 100644 --- a/PHPCI/Store/BuildErrorStore.php +++ b/PHPCI/Store/BuildErrorStore.php @@ -31,7 +31,7 @@ class BuildErrorStore extends BuildErrorStoreBase $query .= ' AND created_date > :since'; } - $query .= ' LIMIT 5000'; + $query .= ' LIMIT 15000'; $stmt = Database::getConnection('read')->prepare($query); diff --git a/Tests/PHPCI/Command/InstallCommandTest.php b/Tests/PHPCI/Command/InstallCommandTest.php index 040a4803..5d70f31c 100644 --- a/Tests/PHPCI/Command/InstallCommandTest.php +++ b/Tests/PHPCI/Command/InstallCommandTest.php @@ -107,6 +107,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase '--admin-name' => 'phpci4', '--admin-pass' => 'phpci5', '--url' => 'http://test.phpci.org', + '--queue-disabled' => null, ); if (!is_null($exclude)) { diff --git a/console b/console index 412dbbdb..992462e5 100755 --- a/console +++ b/console @@ -22,6 +22,7 @@ use PHPCI\Command\PollCommand; use PHPCI\Command\CreateAdminCommand; use PHPCI\Command\CreateBuildCommand; use PHPCI\Command\WorkerCommand; +use PHPCI\Command\RebuildQueueCommand; use PHPCI\Service\BuildService; use Symfony\Component\Console\Application; use b8\Store\Factory; @@ -38,5 +39,6 @@ $application->add(new PollCommand($loggerConfig->getFor('PollCommand'))); $application->add(new CreateAdminCommand(Factory::getStore('User'))); $application->add(new CreateBuildCommand(Factory::getStore('Project'), new BuildService(Factory::getStore('Build')))); $application->add(new WorkerCommand($loggerConfig->getFor('WorkerCommand'))); +$application->add(new RebuildQueueCommand($loggerConfig->getFor('RebuildQueueCommand'))); $application->run(); diff --git a/public/assets/img/ajax-loader.gif b/public/assets/img/ajax-loader.gif index b8d06f66..e65dcffc 100755 Binary files a/public/assets/img/ajax-loader.gif and b/public/assets/img/ajax-loader.gif differ diff --git a/public/assets/img/ajax-loader1.gif b/public/assets/img/ajax-loader1.gif index cc70a7a8..ff412c92 100755 Binary files a/public/assets/img/ajax-loader1.gif and b/public/assets/img/ajax-loader1.gif differ diff --git a/public/assets/img/avatar.png b/public/assets/img/avatar.png index 0ef6233d..ae1cb7b5 100755 Binary files a/public/assets/img/avatar.png and b/public/assets/img/avatar.png differ diff --git a/public/assets/img/avatar04.png b/public/assets/img/avatar04.png index 63fa709b..10d44d44 100755 Binary files a/public/assets/img/avatar04.png and b/public/assets/img/avatar04.png differ diff --git a/public/assets/img/avatar2.png b/public/assets/img/avatar2.png index 5330c223..65fa3552 100755 Binary files a/public/assets/img/avatar2.png and b/public/assets/img/avatar2.png differ diff --git a/public/assets/img/avatar3.png b/public/assets/img/avatar3.png index b1afb21b..4d65e2c6 100755 Binary files a/public/assets/img/avatar3.png and b/public/assets/img/avatar3.png differ diff --git a/public/assets/img/avatar5.png b/public/assets/img/avatar5.png index 29ce6343..670e6d95 100755 Binary files a/public/assets/img/avatar5.png and b/public/assets/img/avatar5.png differ diff --git a/public/assets/img/blur-background04.jpg b/public/assets/img/blur-background04.jpg index c2ad9ea1..e208d771 100755 Binary files a/public/assets/img/blur-background04.jpg and b/public/assets/img/blur-background04.jpg differ diff --git a/public/assets/img/blur-background08.jpg b/public/assets/img/blur-background08.jpg index de91f6cc..3632e07d 100755 Binary files a/public/assets/img/blur-background08.jpg and b/public/assets/img/blur-background08.jpg differ diff --git a/public/assets/img/blur-background09.jpg b/public/assets/img/blur-background09.jpg index 0da84072..5ee3c17a 100755 Binary files a/public/assets/img/blur-background09.jpg and b/public/assets/img/blur-background09.jpg differ diff --git a/public/assets/img/bootstrap-colorpicker/alpha-horizontal.png b/public/assets/img/bootstrap-colorpicker/alpha-horizontal.png index d0a65c08..7789694f 100755 Binary files a/public/assets/img/bootstrap-colorpicker/alpha-horizontal.png and b/public/assets/img/bootstrap-colorpicker/alpha-horizontal.png differ diff --git a/public/assets/img/bootstrap-colorpicker/alpha.png b/public/assets/img/bootstrap-colorpicker/alpha.png index 38043f1c..a4129735 100755 Binary files a/public/assets/img/bootstrap-colorpicker/alpha.png and b/public/assets/img/bootstrap-colorpicker/alpha.png differ diff --git a/public/assets/img/bootstrap-colorpicker/hue-horizontal.png b/public/assets/img/bootstrap-colorpicker/hue-horizontal.png index a0d9add8..4ad05e78 100755 Binary files a/public/assets/img/bootstrap-colorpicker/hue-horizontal.png and b/public/assets/img/bootstrap-colorpicker/hue-horizontal.png differ diff --git a/public/assets/img/bootstrap-colorpicker/hue.png b/public/assets/img/bootstrap-colorpicker/hue.png index d89560e9..7f5f4749 100755 Binary files a/public/assets/img/bootstrap-colorpicker/hue.png and b/public/assets/img/bootstrap-colorpicker/hue.png differ diff --git a/public/assets/img/bootstrap-colorpicker/saturation.png b/public/assets/img/bootstrap-colorpicker/saturation.png index 594ae50e..a1598af6 100755 Binary files a/public/assets/img/bootstrap-colorpicker/saturation.png and b/public/assets/img/bootstrap-colorpicker/saturation.png differ diff --git a/public/assets/img/credit/american-express.png b/public/assets/img/credit/american-express.png index fbe9ce2c..bd7fcfbe 100755 Binary files a/public/assets/img/credit/american-express.png and b/public/assets/img/credit/american-express.png differ diff --git a/public/assets/img/credit/cirrus.png b/public/assets/img/credit/cirrus.png index 03d2bd6a..18236bef 100755 Binary files a/public/assets/img/credit/cirrus.png and b/public/assets/img/credit/cirrus.png differ diff --git a/public/assets/img/credit/mastercard.png b/public/assets/img/credit/mastercard.png index f709adba..2d7addcf 100755 Binary files a/public/assets/img/credit/mastercard.png and b/public/assets/img/credit/mastercard.png differ diff --git a/public/assets/img/credit/mestro.png b/public/assets/img/credit/mestro.png index c22ddeaf..9b5153a9 100755 Binary files a/public/assets/img/credit/mestro.png and b/public/assets/img/credit/mestro.png differ diff --git a/public/assets/img/credit/paypal.png b/public/assets/img/credit/paypal.png index a7e1458f..1d8e8a24 100755 Binary files a/public/assets/img/credit/paypal.png and b/public/assets/img/credit/paypal.png differ diff --git a/public/assets/img/credit/paypal2.png b/public/assets/img/credit/paypal2.png index b0ca241b..7c2fda42 100755 Binary files a/public/assets/img/credit/paypal2.png and b/public/assets/img/credit/paypal2.png differ diff --git a/public/assets/img/credit/visa.png b/public/assets/img/credit/visa.png index 7099cdf4..9a378542 100755 Binary files a/public/assets/img/credit/visa.png and b/public/assets/img/credit/visa.png differ diff --git a/public/assets/img/favicon.png b/public/assets/img/favicon.png index 1e33cffa..0b6f60ec 100644 Binary files a/public/assets/img/favicon.png and b/public/assets/img/favicon.png differ diff --git a/public/assets/img/glyphicons-halflings-white.png b/public/assets/img/glyphicons-halflings-white.png index 3bf6484a..c1ab5815 100644 Binary files a/public/assets/img/glyphicons-halflings-white.png and b/public/assets/img/glyphicons-halflings-white.png differ diff --git a/public/assets/img/glyphicons-halflings.png b/public/assets/img/glyphicons-halflings.png index a9969993..f241c76f 100644 Binary files a/public/assets/img/glyphicons-halflings.png and b/public/assets/img/glyphicons-halflings.png differ diff --git a/public/assets/img/icon-build-failed.png b/public/assets/img/icon-build-failed.png index 9dde31bd..8ddd4b14 100644 Binary files a/public/assets/img/icon-build-failed.png and b/public/assets/img/icon-build-failed.png differ diff --git a/public/assets/img/icon-build-ok.png b/public/assets/img/icon-build-ok.png index 650e5f1f..90e5f35e 100644 Binary files a/public/assets/img/icon-build-ok.png and b/public/assets/img/icon-build-ok.png differ diff --git a/public/assets/img/icon-build-pending.png b/public/assets/img/icon-build-pending.png index f23051c7..2c8d1196 100644 Binary files a/public/assets/img/icon-build-pending.png and b/public/assets/img/icon-build-pending.png differ diff --git a/public/assets/img/icon-build-running.png b/public/assets/img/icon-build-running.png index 593f00b5..3e9b4f71 100644 Binary files a/public/assets/img/icon-build-running.png and b/public/assets/img/icon-build-running.png differ diff --git a/public/assets/img/icons.png b/public/assets/img/icons.png index 1663a0bd..96c1afd3 100755 Binary files a/public/assets/img/icons.png and b/public/assets/img/icons.png differ diff --git a/public/assets/img/logo-icon.png b/public/assets/img/logo-icon.png index eb377672..c3cb1143 100644 Binary files a/public/assets/img/logo-icon.png and b/public/assets/img/logo-icon.png differ diff --git a/public/assets/img/logo-large.png b/public/assets/img/logo-large.png index dd3e1d34..08bb5604 100644 Binary files a/public/assets/img/logo-large.png and b/public/assets/img/logo-large.png differ diff --git a/public/assets/img/logo.png b/public/assets/img/logo.png index 4c56e4a7..61fbbebd 100644 Binary files a/public/assets/img/logo.png and b/public/assets/img/logo.png differ diff --git a/public/assets/img/sprite-skin-flat.png b/public/assets/img/sprite-skin-flat.png index 3055db77..84a36653 100755 Binary files a/public/assets/img/sprite-skin-flat.png and b/public/assets/img/sprite-skin-flat.png differ diff --git a/public/assets/img/sprite-skin-nice.png b/public/assets/img/sprite-skin-nice.png index d62f8188..25e4d509 100755 Binary files a/public/assets/img/sprite-skin-nice.png and b/public/assets/img/sprite-skin-nice.png differ diff --git a/public/assets/img/user-bg.png b/public/assets/img/user-bg.png index 75e1b46c..a491bc0d 100755 Binary files a/public/assets/img/user-bg.png and b/public/assets/img/user-bg.png differ diff --git a/public/assets/img/user.jpg b/public/assets/img/user.jpg index b4f104f2..6eab19ae 100755 Binary files a/public/assets/img/user.jpg and b/public/assets/img/user.jpg differ diff --git a/public/assets/img/user2.jpg b/public/assets/img/user2.jpg index cb2d3639..ce9e457a 100755 Binary files a/public/assets/img/user2.jpg and b/public/assets/img/user2.jpg differ diff --git a/public/assets/js/build-plugins/loc.js b/public/assets/js/build-plugins/loc.js index 2a64f29f..89e703b8 100644 --- a/public/assets/js/build-plugins/loc.js +++ b/public/assets/js/build-plugins/loc.js @@ -89,7 +89,7 @@ var locPlugin = ActiveBuild.UiPlugin.extend({ drawChart: function () { var self = this; - if ($('#information').hasClass('active') && self.chartData) { + if ($('#information').hasClass('active') && self.chartData && self.lastData) { $('#build-lines-chart').show(); var ctx = $("#phploc-lines-chart").get(0).getContext("2d"); diff --git a/public/assets/js/build-plugins/warnings.js b/public/assets/js/build-plugins/warnings.js index 79b7a960..046fb9c6 100644 --- a/public/assets/js/build-plugins/warnings.js +++ b/public/assets/js/build-plugins/warnings.js @@ -101,13 +101,12 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({ var i = 0; for (var key in self.keys) { - self.chartData[i].data.push(parseInt(self.data[build][key])); + + self.chartData.datasets[i].data.push(parseInt(self.data[build][key])); i++; } } - console.log(self.chartData); - self.drawChart(); }, diff --git a/public/assets/js/build.js b/public/assets/js/build.js index f783d8f7..4b9c10a1 100644 --- a/public/assets/js/build.js +++ b/public/assets/js/build.js @@ -73,14 +73,16 @@ var Build = Class.extend({ var uri = 'build/meta/' + self.buildId; var query = query || {}; - if (name == 'build-updated') { - uri = 'build/data/' + self.buildId + '?since=' + self.buildData.since; - } - var cb = function() { + var fullUri = window.PHPCI_URL + uri; + + if (name == 'build-updated') { + fullUri = window.PHPCI_URL + 'build/data/' + self.buildId + '?since=' + self.buildData.since; + } + $.ajax({ dataType: "json", - url: window.PHPCI_URL + uri, + url: fullUri, data: query, success: function(data) { $(window).trigger({type: name, queryData: data});