Compare commits

..

36 commits

Author SHA1 Message Date
Arnout Boks 64b0f60368 Removed unused 'standard' option for PhpCpd plugin (#1249) 2016-08-17 12:35:21 +01:00
Dan Cryer 42ca1c6527 Fix for handling old unserialize mode. 2016-06-29 10:13:27 +01:00
Dan Cryer 4d0911f2a9 Bug fixes
Signed-off-by: Dan Cryer <dan@block8.co.uk>
2016-06-23 11:30:41 +01:00
Dan Cryer 3cdaef8fa9 Update README.md 2016-06-03 17:30:45 +01:00
David Rimbault db93f55427 [FIX] Running Complete stage even on Exception catch. (#1186) 2016-04-27 16:59:29 +01:00
Dan Cryer 49db1a26ba
Make sure we always show the correct error count on the build errors tab. 2016-04-27 16:40:55 +01:00
Dan Cryer 77e9710d09
Testing PHPMD error supression 2016-04-27 15:45:24 +01:00
Dan Cryer 7027055711
Merge branch 'feature/bitbucket-webhooks' 2016-04-27 15:35:10 +01:00
Dan Cryer 21ba39e6ff
Fixes 2016-04-27 15:27:27 +01:00
Dan Cryer 6418fde928 Defaulting to using neither --prefer-source or --prefer-dist for composer. Allow user to specify either. 2016-04-27 15:20:20 +01:00
Dan Cryer 21d5f4954f
Adding a debug mode to the worker so you can see what commands are being run. 2016-04-27 14:56:52 +01:00
Dan Cryer 1f035463e4 Merge branch 'patch-4' of https://github.com/wodka/PHPCI into feature/bitbucket-webhooks 2016-04-27 14:26:44 +01:00
Dan Cryer 5ead42a7c2
README tweaks. 2016-04-27 14:18:40 +01:00
Dan Cryer 1e13538c28
Updating README 2016-04-27 14:13:42 +01:00
Dan Cryer 424f1c5c4b Removing Test from README 2016-04-27 14:08:01 +01:00
Dan Cryer dc9aa195d1 Merge branch 'master' of github.com:Block8/PHPCI 2016-04-27 12:35:17 +01:00
Dan Cryer 1e2cbcaf3d Fixing duplicate error listing in builds.
Closes #1130
2016-04-27 12:33:07 +01:00
David Valdez e567088a00 now take in account the errors in the codeception plugin (#1206) 2016-04-27 12:10:46 +01:00
Dan Cryer ffa593f1a3 Fixing PHPCS errors 2016-04-27 12:02:13 +01:00
Dan Cryer cc6d0f2964 Updating dependencies 2016-04-27 11:43:57 +01:00
Dan Cryer e6b02b6019 Merge remote-tracking branch 'origin/master' into v/1.7 2016-04-27 11:32:50 +01:00
Dan Cryer 81eadcf3f5 Contributing guidelines, issue template and PR template. 2016-04-27 11:29:03 +01:00
Dan Cryer f200bd0411 Fixing MySQL strict-mode install error.
Fixes #977
Fixes #818
2016-04-27 11:06:32 +01:00
Mike Bronner fe9289eda5 Remove whitespace from empty lines, reformatted inline comments 2016-02-08 12:59:15 +01:00
Michael Schramm 66ffea12f0 remove whitespace 2016-02-08 12:59:15 +01:00
Michael Schramm 3c8ed45c46 implement bitbucket webhooks
this fixes issue https://github.com/Block8/PHPCI/issues/1015 and adds support for the new bitbucket webhooks
2016-02-08 12:59:15 +01:00
Dan Cryer 2ddda7711e Update README.md 2016-02-08 11:44:35 +00:00
Dan Cryer 42bea5f876 Merge pull request #1154 from staudenmeir/update-german-translation
Update German translation.
2016-01-08 11:04:54 +00:00
Dan Cryer d3af89a0c5 Merge pull request #1157 from Lechus/patch-2
Update Polish translation
2016-01-08 11:03:35 +00:00
Leszek 9af9e0ec35 Update Polish translation
Contribution Type: improvement
Primary Area: front-end

Description of change: Updated Polish translation.
2016-01-06 22:01:38 +00:00
Jonas Staudenmeir 7f43f94cc0 Updated German translation. 2016-01-06 00:24:42 +01:00
Jonas Staudenmeir 949bfc5376 Added default value in settings language select (current language). 2016-01-05 16:21:21 +01:00
Dan Cryer 992cf767a6 Merge pull request #1128 from Block8/Deployer_branch_update
Added branch and update_only parameters
2015-11-24 11:37:16 +00:00
Stephen Ball 6eeddc9dc6 Added branch and update_only parameters
Fixes #1127
2015-11-14 23:08:22 +00:00
Dan Cryer 6eb180ed5f Merge pull request #1124 from Block8/REBELinBLUE-patch-1
Fixes a issue with a double slash in the path meaning ignore doesn't …
2015-11-12 17:47:16 +00:00
Stephen Ball 148e4414fb Fixes a issue with a double slash in the path meaning ignore doesn't work 2015-11-12 17:42:00 +00:00
79 changed files with 693 additions and 515 deletions

41
.github/CONTRIBUTING.md vendored Normal file
View file

@ -0,0 +1,41 @@
Contributions to PHPCI are very much encouraged, and we do our best to make it as welcoming and simple as possible.
### Before You Start
Before you start, please make sure that you are aware of, and agree to, the following conditions of contribution:
* By making a contribution to PHPCI, you accept that you are granting copyright ownership for that contribution to Block 8 Limited - the company responsible for PHPCI. In countries where copyright reassignment is not permitted, you grant Block 8 Limited a perpetual, non-exclusive licence to use your contribution in any way and for any purpose.
* By making a contribution to PHPCI, you accept that your code will be released under the open-source [BSD 2-Clause Licence](https://github.com/Block8/PHPCI/blob/master/LICENSE.md).
Block 8 are committed to PHPCI being a truly free and open source project, providing easy to use continuous integration and testing to as many developers as possible. We may, at our sole discretion, provide paid services based upon PHPCI - but PHPCI will always remain free (as in cost, and freedom) and open source.
### The Contribution Process
1. If you are thinking of making a large change or feature addition, [open an issue](/Block8/PHPCI/issues) titled "Intent to implement: <Your Feature>". Describe your idea in detail and discuss it with the community. It might be that someone already has a plan, could help you out, or your idea may simply not be suitable for the project at this time.
2. Fork the PHPCI project on Github
3. Add a feature or fix a bug - We recommend that you do this on a branch within your repository.
4. Create a pull request containing just the one change you want to contribute back to PHPCI. If you have more than one feature or bug fix, please create separate branches within your repository, and then submit a separate pull request for each one. Your pull request should use the template detailed below.
5. We'll then review your pull request and give any necessary feedback, this could be:
* Suggestions to improve your implementation
* Questions
* Issues/bugs related to the change
* Coding standards pointers
6. Once everyone is happy with the submission, we'll merge it back into PHPCI. Your change will then be included in the next project release.
### Not sure what to start with?
We maintain two labels within our issue tracker that may be of interest to new contributors:
* [The "Easy Fix" List](https://github.com/Block8/PHPCI/labels/flag:easy-fix)
* [The "Priority" List](https://github.com/Block8/PHPCI/labels/flag:priority)
### Coding Standards
We require that all contributions meet at least the following guidelines:
* PSR-1 & PSR-2 compliance for all code
* Doc-blocks for all classes and methods
* All files must contain the standard file-level docblock, including the copyright, license and link tags.
All pull requests will be checked against these standards. If you're modifying a file as part of your change which does not comply with the above, please make the necessary changes to bring it into compliance prior to submitting the pull request.
### Other Requirements
When you're adding new features or functionality, or you're updating existing functionality, please ensure that the relevant documentation is also either created or updated on the Wiki.

28
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,28 @@
Before submitting your issue, please make sure that you've checked all of the checkboxes below.
- [ ] You're running the [latest release](https://github.com/Block8/PHPCI/releases/latest) version of PHPCI.
- [ ] Ensure that you're running at least PHP 5.3.6, you can check this by running `php -v`
- [ ] You've run `composer install --no-dev -o` from the root of your installation.
- [ ] You have set up either the PHPCI [Worker](https://github.com/Block8/PHPCI/wiki/Run-Builds-Using-a-Worker), [Daemon](https://github.com/Block8/PHPCI/wiki/Run-Builds-Using-a-Daemon) or [Cron Job](https://github.com/Block8/PHPCI/wiki/Run-Builds-Using-Cron) to run builds.
To help us better understand your issue, please answer the following.
### Expected behaviour
*Please describe what you're expecting to see happen.*
### Actual behaviour
*Please describe what you're actually seeing happen.*
### Steps to reproduce
*If your issue requires any specific steps to reproduce, please outline them here.*
### Environment info
Operating System:
PHP Version:
MySQL Version:
### Logs or other output that would be helpful
(If logs are large, please upload as attachment).

23
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,23 @@
Contribution Type: bug fix | new plugin | new feature | refactor | cosmetic
Link to Intent to Implement:
Link to Bug:
This pull request affects the following areas:
* [ ] Front-End
* [ ] Builder
* [ ] Build Plugins
**In raising this pull request, I confirm the following (please check boxes):**
- [ ] I have read and understood the [contributing guidelines](/.github/CONTRIBUTING.md)?
- [ ] I have checked that another pull request for this purpose does not exist.
- [ ] I have considered, and confirmed that this submission will be valuable to others.
- [ ] I have created or updated the relevant documentation for this change on the PHPCI Wiki.
- [ ] Do the PHPCI tests pass?
Detailed description of change:

View file

@ -13,7 +13,6 @@ build_settings:
setup:
composer:
action: "install"
prefer_dist: false
test:
php_parallel_lint:

View file

@ -213,8 +213,6 @@ class Builder implements LoggerAwareInterface
$this->build->setStatus(Build::STATUS_FAILED);
}
// Complete stage plugins are always run
$this->pluginExecutor->executePlugins($this->config, 'complete');
if ($success) {
$this->pluginExecutor->executePlugins($this->config, 'success');
@ -236,6 +234,9 @@ class Builder implements LoggerAwareInterface
} catch (\Exception $ex) {
$this->build->setStatus(Build::STATUS_FAILED);
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
}finally{
// Complete stage plugins are always run
$this->pluginExecutor->executePlugins($this->config, 'complete');
}

View file

@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use PHPCI\Service\UserService;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* Install console command - Installs PHPCI.
@ -253,6 +254,14 @@ class InstallCommand extends Command
$rtn = [];
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', true);
if (!$helper->ask($input, $output, $question)) {
$output->writeln('<error>Skipping beanstalkd configuration.</error>');
return null;
}
if (!$rtn['host'] = $input->getOption('queue-server')) {
$rtn['host'] = $dialog->ask($output, 'Enter your beanstalkd hostname [localhost]: ', 'localhost');
}

View file

@ -50,7 +50,8 @@ class WorkerCommand extends Command
{
$this
->setName('phpci:worker')
->setDescription('Runs the PHPCI build worker.');
->setDescription('Runs the PHPCI build worker.')
->addOption('debug', null, null, 'Run PHPCI in Debug Mode');
}
protected function execute(InputInterface $input, OutputInterface $output)
@ -65,6 +66,12 @@ class WorkerCommand extends Command
);
}
// Allow PHPCI to run in "debug mode"
if ($input->hasOption('debug') && $input->getOption('debug')) {
$output->writeln('<comment>Debug mode enabled.</comment>');
define('PHPCI_DEBUG_MODE', true);
}
$config = Config::getInstance()->get('phpci.worker', []);
if (empty($config['host']) || empty($config['queue'])) {

View file

@ -180,7 +180,7 @@ class BuildController extends \PHPCI\Controller
$errorView->build = $build;
$errorView->errors = $errors;
$data['errors'] = count($errors);
$data['errors'] = $errorStore->getErrorTotalForBuild($build->getId());
$data['error_html'] = $errorView->render();
$data['since'] = (new \DateTime())->format('Y-m-d H:i:s');
@ -200,6 +200,10 @@ class BuildController extends \PHPCI\Controller
$build = $this->buildService->createDuplicateBuild($copy);
if ($this->buildService->queueError) {
$_SESSION['global_error'] = Lang::get('add_to_queue_failed');
}
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'build/view/' . $build->getId());
return $response;

View file

@ -104,7 +104,6 @@ class BuildStatusController extends \PHPCI\Controller
}
}
}
} catch (\Exception $e) {
$xml = new \SimpleXMLElement('<projects/>');
}

View file

@ -116,6 +116,10 @@ class ProjectController extends PHPCI\Controller
$email = $_SESSION['phpci_user']->getEmail();
$build = $this->buildService->createBuild($project, null, urldecode($branch), $email);
if ($this->buildService->queueError) {
$_SESSION['global_error'] = Lang::get('add_to_queue_failed');
}
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'build/view/' . $build->getId());
return $response;

View file

@ -444,7 +444,7 @@ class SettingsController extends Controller
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field->setOptions(Lang::getLanguageOptions());
$field->setValue('en');
$field->setValue(Lang::getLanguage());
$form->addField($field);

View file

@ -27,6 +27,8 @@ use PHPCI\Store\ProjectStore;
* @author Guillaume Perréal <adirelle@gmail.com>
* @package PHPCI
* @subpackage Web
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class WebhookController extends \b8\Controller
{
@ -80,11 +82,64 @@ class WebhookController extends \b8\Controller
}
/**
* Called by Bitbucket POST service.
* Called by Bitbucket.
*/
public function bitbucket($projectId)
{
$project = $this->fetchProject($projectId, 'bitbucket');
// Support both old services and new webhooks
if ($payload = $this->getParam('payload')) {
return $this->bitbucketService(json_decode($payload, true), $project);
}
$payload = json_decode(file_get_contents("php://input"), true);
if (empty($payload['push']['changes'])) {
// Invalid event from bitbucket
return [
'status' => 'failed',
'commits' => []
];
}
return $this->bitbucketWebhook($payload, $project);
}
/**
* Bitbucket webhooks.
*/
protected function bitbucketWebhook($payload, $project)
{
$results = array();
$status = 'failed';
foreach ($payload['push']['changes'] as $commit) {
try {
$email = $commit['new']['target']['author']['raw'];
$email = substr($email, 0, strpos($email, '>'));
$email = substr($email, strpos($email, '<') + 1);
$results[$commit['new']['target']['hash']] = $this->createBuild(
$project,
$commit['new']['target']['hash'],
$commit['new']['name'],
$email,
$commit['new']['target']['message']
);
$status = 'ok';
} catch (Exception $ex) {
$results[$commit['new']['target']['hash']] = array('status' => 'failed', 'error' => $ex->getMessage());
}
}
return array('status' => $status, 'commits' => $results);
}
/**
* Bitbucket POST service.
*/
protected function bitbucketService($payload, $project)
{
$payload = json_decode($this->getParam('payload'), true);
$results = array();

View file

@ -76,6 +76,7 @@ abstract class BaseCommandExecutor implements CommandExecutor
$this->lastOutput = array();
$command = call_user_func_array('sprintf', $args);
$this->logger->logDebug($command);
if ($this->quiet) {
$this->logger->log('Executing: ' . $command);
@ -89,7 +90,6 @@ abstract class BaseCommandExecutor implements CommandExecutor
);
$pipes = array();
$process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);
if (is_resource($process)) {

View file

@ -39,7 +39,7 @@ PHPCI',
'reset_email_title' => 'PHPCI Passwort zurücksetzen für %s',
'reset_invalid' => 'Fehlerhafte Anfrage für das Zurücksetzen eines Passwortes',
'email_address' => 'Emailadresse',
'login' => 'Login / Email Address',
'login' => 'Login / Emailadresse',
'password' => 'Passwort',
'log_in' => 'Einloggen',
@ -103,7 +103,7 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'local' => 'Lokaler Pfad',
'hg' => 'Mercurial',
'svn' => 'Subversion',
'where_hosted' => 'Wo wird Ihr Projekt gehostet?',
'choose_github' => 'Wählen Sie ein GitHub Repository:',
@ -115,8 +115,8 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
(falls Sie Ihrem Projektrepository kein phpci.yml hinzufügen können)',
'default_branch' => 'Name des Standardbranches',
'allow_public_status' => 'Öffentliche Statusseite und -bild für dieses Projekt einschalten?',
'archived' => 'Archived',
'archived_menu' => 'Archived',
'archived' => 'Archiviert',
'archived_menu' => 'Archiviert',
'save_project' => 'Projekt speichern',
'error_mercurial' => 'Mercurial Repository-URL muss mit http://, oder https:// beginnen',
@ -130,7 +130,7 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'all_branches' => 'Alle Branches',
'builds' => 'Builds',
'id' => 'ID',
'date' => 'Date',
'date' => 'Datum',
'project' => 'Projekt',
'commit' => 'Commit',
'branch' => 'Branch',
@ -151,6 +151,9 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'webhooks_help_bitbucket' => 'Um für dieses Projekt automatisch einen Build zu starten, wenn neue Commits gepushed werden, fügen Sie die untenstehende URL als "POST" Service in der <a href="https://bitbucket.org/%s/admin/services">Services</a>-Sektion Ihres Bitbucket Repositories hinzu.',
// View Build
'errors' => 'Fehler',
'information' => 'Information',
'build_x_not_found' => 'Build mit ID %d existiert nicht.',
'build_n' => 'Build %d',
'rebuild_now' => 'Build neu starten',
@ -192,8 +195,8 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'codeception_suite' => 'Suite',
'codeception_time' => 'Zeit',
'codeception_synopsis' => '<strong>%1$d</strong> Tests in <strong>%2$f</strong> Sekunden ausgeführt.
<strong>%3$d</strong> Fehler.',
<strong>%3$d</strong> Fehler.',
'file' => 'Datei',
'line' => 'Zeile',
'class' => 'Klasse',
@ -209,14 +212,14 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'build_created' => 'Build erstellt',
'build_started' => 'Build gestartet',
'build_finished' => 'Build abgeschlossen',
'test_message' => 'Message',
'test_no_message' => 'No message',
'test_success' => 'Successful: %d',
'test_fail' => 'Failures: %d',
'test_skipped' => 'Skipped: %d',
'test_error' => 'Errors: %d',
'test_message' => 'Nachricht',
'test_no_message' => 'Keine Nachricht',
'test_success' => 'Erfolgreich: %d',
'test_fail' => 'Fehlschläge: %d',
'test_skipped' => 'Übersprungen: %d',
'test_error' => 'Fehler: %d',
'test_todo' => 'Todos: %d',
'test_total' => '%d test(s)',
'test_total' => '%d Test(s)',
// Users
'name' => 'Name',
@ -292,6 +295,19 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'search_packagist_for_more' => 'Packagist nach mehr Packages durchsuchen',
'search' => 'Suchen &raquo;',
// Summary plugin
'build-summary' => 'Zusammenfassung',
'stage' => 'Abschnitt',
'duration' => 'Dauer',
'plugin' => 'Plugin',
'stage_setup' => 'Vorbereitung',
'stage_test' => 'Test',
'stage_complete' => 'Vollständig',
'stage_success' => 'Erfolg',
'stage_failure' => 'Fehlschlag',
'stage_broken' => 'Defekt',
'stage_fixed' => 'Behoben',
// Installer
'installation_url' => 'PHPCI Installations-URL',
'db_host' => 'Datenbankserver',
@ -400,5 +416,18 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'build_file_missing' => 'Angegebene Builddatei existiert nicht.',
'property_file_missing' => 'Angegebene Eigenschaftsdatei existiert nicht.',
'could_not_process_report' => 'Konnte den von diesem Tool erstellten Bericht nicht verarbeiten.',
'shell_not_enabled' => 'Das Shell-Plugin ist nicht aktiviert. Bitte aktivieren Sie es via config.yml.'
'shell_not_enabled' => 'Das Shell-Plugin ist nicht aktiviert. Bitte aktivieren Sie es via config.yml.',
// Error Levels:
'critical' => 'Kritisch',
'high' => 'Hoch',
'normal' => 'Normal',
'low' => 'Niedrig',
// Plugins that generate errors:
'php_mess_detector' => 'PHP Mess Detector',
'php_code_sniffer' => 'PHP Code Sniffer',
'php_unit' => 'PHP Unit',
'php_cpd' => 'PHP Copy/Paste Detector',
'php_docblock_checker' => 'PHP Docblock Checker',
);

View file

@ -372,6 +372,9 @@ PHPCI',
'project_id_argument' => 'A project ID',
'commit_id_option' => 'Commit ID to build',
'branch_name_option' => 'Branch to build',
'add_to_queue_failed' => 'Build created successfully, but failed to add to build queue. This usually happens
when PHPCI is set to use a beanstalkd server that does not exist,
or your beanstalkd server has stopped.',
// Run Command
'run_all_pending' => 'Run all pending PHPCI builds.',

View file

@ -130,7 +130,7 @@ od wybranego kodu źródłowego platformy hostingowej.',
'all_branches' => 'Wszystkie Gałęzie',
'builds' => 'Budowania',
'id' => 'ID',
'date' => 'Date',
'date' => 'Data',
'project' => 'Projekt',
'commit' => 'Commit',
'branch' => 'Gałąź',
@ -206,14 +206,14 @@ Services</a> repozytoria Bitbucket.',
'build_created' => 'Budowanie Stworzone',
'build_started' => 'Budowanie Rozpoczęte',
'build_finished' => 'Budowanie Zakończone',
'test_message' => 'Message',
'test_no_message' => 'No message',
'test_success' => 'Successful: %d',
'test_fail' => 'Failures: %d',
'test_skipped' => 'Skipped: %d',
'test_error' => 'Errors: %d',
'test_todo' => 'Todos: %d',
'test_total' => '%d test(s)',
'test_message' => 'Wiadomość',
'test_no_message' => 'Brak wiadomości',
'test_success' => 'Powodzenie: %d',
'test_fail' => 'Niepowodzenia: %d',
'test_skipped' => 'Pominęte: %d',
'test_error' => 'Błędy: %d',
'test_todo' => 'Do zrobienia: %d',
'test_total' => '%d test(ów)',
// Users
'name' => 'Nazwa',
@ -344,10 +344,10 @@ Przejrzyj powyższą listę błędów przed kontynuowaniem.',
'incorrect_format' => 'Niepoprawny format',
// Create Build Command
'create_build_project' => 'Create a build for a project',
'project_id_argument' => 'A project ID',
'commit_id_option' => 'Commit ID to build',
'branch_name_option' => 'Branch to build',
'create_build_project' => 'Utwórz budowanie dla projektu',
'project_id_argument' => 'ID projektu',
'commit_id_option' => 'ID Commita do budowania',
'branch_name_option' => 'Gałąź do budowania',
// Run Command
'run_all_pending' => 'Uruchom wszystkie oczekujące budowy w PHPCI',

View file

@ -67,7 +67,7 @@ class BuildLogger implements LoggerAwareInterface
}
}
/**
/**
* Add a success-coloured message to the log.
* @param string
*/
@ -98,6 +98,17 @@ class BuildLogger implements LoggerAwareInterface
);
}
/**
* Add a debug message to the log.
* @param string
*/
public function logDebug($message)
{
if (defined('PHPCI_DEBUG_MODE') && PHPCI_DEBUG_MODE) {
$this->log("\033[0;33m" . $message . "\033[0m");
}
}
/**
* Sets a logger instance on the object
*

View file

@ -20,7 +20,7 @@ class FixDatabaseColumns extends AbstractMigration
$build->changeColumn('project_id', 'integer', array('null' => false));
$build->changeColumn('commit_id', 'string', array('limit' => 50, 'null' => false));
$build->changeColumn('status', 'integer', array('null' => false));
$build->changeColumn('log', 'text', array('null' => true, 'default' => ''));
$build->changeColumn('log', 'text', array('null' => true));
$build->changeColumn('branch', 'string', array('limit' => 50, 'null' => false, 'default' => 'master'));
$build->changeColumn('created', 'datetime', array('null' => true));
$build->changeColumn('started', 'datetime', array('null' => true));

View file

@ -14,7 +14,6 @@ class FixColumnTypes extends AbstractMigration
$build = $this->table('build');
$build->changeColumn('log', 'text', array(
'null' => true,
'default' => '',
'limit' => MysqlAdapter::TEXT_MEDIUM,
));

View file

@ -0,0 +1,18 @@
<?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class ProjectTableDefaults extends AbstractMigration
{
public function change()
{
$this->table('project')
->changeColumn('build_config', MysqlAdapter::PHINX_TYPE_TEXT, array('null' => true))
->changeColumn('archived', MysqlAdapter::PHINX_TYPE_INTEGER, array(
'length' => MysqlAdapter::INT_TINY,
'default' => 0,
))
->save();
}
}

View file

@ -168,7 +168,7 @@ class Build extends BuildBase
}
foreach (array('setup', 'test', 'complete', 'success', 'failure') as $stage) {
if ($className::canRunZeroConfig($stage, $builder, $this)) {
if ($className::canExecute($stage, $builder, $this)) {
$config[$stage][$className] = array(
'zero_config' => true
);

View file

@ -96,7 +96,7 @@ class Project extends ProjectBase
$info = $this->data['access_information'];
// Handle old-format (serialized) access information first:
if (!empty($info) && substr($info, 0, 1) != '{') {
if (!empty($info) && !in_array(substr($info, 0, 1), array('{', '['))) {
$data = unserialize($info);
} else {
$data = json_decode($info, true);

View file

@ -9,16 +9,11 @@
namespace PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
/**
* PHPCI Plugin Interface - Used by all build plugins.
* @author Dan Cryer <dan@block8.co.uk>
*/
interface Plugin
{
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
public function isAllowedInStage($stage);
public function execute();
}

View file

@ -1,50 +0,0 @@
<?php
namespace PHPCI\Plugin;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin;
/**
* Base for all of the standard PHPCI plugins. Provides the isAllowedInStage() functionality.
* @package PHPCI\Plugin
*/
abstract class AbstractPlugin implements Plugin
{
/**
* Define the stages that this plugin is allowed to run in.
* @see AbstractPlugin::isAllowedInStage()
* @var array
*/
protected $allowedStages = array('setup', 'test', 'complete', 'success', 'failure', 'fixed', 'broken');
/**
* Verify whether or not this plugin is allowed to execute in a given stage.
* @param string $stage
* @return bool
*/
public function isAllowedInStage($stage)
{
return in_array($stage, $this->allowedStages);
}
/**
* Check whether or not this plugin can execute in zero config mode.
* Many plugins will check if their required config files can be found here.
* @param string $stage
* @param Builder $builder
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
return false;
}
/**
* Execute the plugin and return its success or failure.
* @return bool
*/
abstract public function execute();
}

View file

@ -17,13 +17,8 @@ use PHPCI\Model\Build;
* Atoum plugin, runs Atoum tests within a project.
* @package PHPCI\Plugin
*/
class Atoum extends AbstractPlugin
class Atoum implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
private $args;
private $config;
private $directory;

View file

@ -20,13 +20,8 @@ use PHPCI\Model\BuildError;
* @package PHPCI
* @subpackage Plugins
*/
class Behat extends AbstractPlugin
class Behat implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $phpci;
protected $build;
protected $features;

View file

@ -20,13 +20,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Campfire extends AbstractPlugin
class Campfire implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
private $url;
private $authToken;
private $userAgent;

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class CleanBuild extends AbstractPlugin
class CleanBuild implements \PHPCI\Plugin
{
protected $remove;
protected $phpci;

View file

@ -14,7 +14,6 @@ use PHPCI\Helper\Lang;
use PHPCI\Model\Build;
use PHPCI\Plugin\Util\TestResultParsers\Codeception as Parser;
use Psr\Log\LogLevel;
use PHPCI\ZeroConfigPlugin;
/**
* Codeception Plugin - Enables full acceptance, unit, and functional testing.
@ -24,13 +23,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class Codeception extends AbstractPlugin implements ZeroConfigPlugin
class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/** @var string */
protected $args = '';
@ -56,7 +50,7 @@ class Codeception extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
return $stage == 'test' && !is_null(self::findConfigFile($builder->buildPath));
}

View file

@ -13,7 +13,6 @@ use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Helper\Lang;
use PHPCI\ZeroConfigPlugin;
/**
* Composer Plugin - Provides access to Composer functionality.
@ -21,7 +20,7 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class Composer extends AbstractPlugin implements ZeroConfigPlugin
class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
protected $directory;
protected $action;
@ -37,7 +36,7 @@ class Composer extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';
@ -62,6 +61,7 @@ class Composer extends AbstractPlugin implements ZeroConfigPlugin
$this->directory = $path;
$this->action = 'install';
$this->preferDist = false;
$this->preferSource = false;
$this->nodev = false;
if (array_key_exists('directory', $options)) {
@ -76,6 +76,11 @@ class Composer extends AbstractPlugin implements ZeroConfigPlugin
$this->preferDist = (bool)$options['prefer_dist'];
}
if (array_key_exists('prefer_source', $options)) {
$this->preferDist = false;
$this->preferSource = (bool)$options['prefer_source'];
}
if (array_key_exists('no_dev', $options)) {
$this->nodev = (bool)$options['no_dev'];
}
@ -98,10 +103,12 @@ class Composer extends AbstractPlugin implements ZeroConfigPlugin
if ($this->preferDist) {
$this->phpci->log('Using --prefer-dist flag');
$cmd .= '--prefer-dist';
} else {
$cmd .= ' --prefer-dist';
}
if ($this->preferSource) {
$this->phpci->log('Using --prefer-source flag');
$cmd .= '--prefer-source';
$cmd .= ' --prefer-source';
}
if ($this->nodev) {

View file

@ -19,7 +19,7 @@ use PHPCI\Helper\Lang;
* @package PHPCI
* @subpackage Plugins
*/
class CopyBuild extends AbstractPlugin
class CopyBuild implements \PHPCI\Plugin
{
protected $directory;
protected $ignore;

View file

@ -19,15 +19,11 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Deployer extends AbstractPlugin
class Deployer implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
protected $webhookUrl;
protected $reason;
protected $updateOnly;
/**
* Set up the plugin, configure options, etc.
@ -48,6 +44,8 @@ class Deployer extends AbstractPlugin
if (isset($options['reason'])) {
$this->reason = $options['reason'];
}
$this->updateOnly = isset($options['update_only']) ? (bool) $options['update_only'] : true;
}
/**
@ -66,6 +64,8 @@ class Deployer extends AbstractPlugin
'reason' => $this->phpci->interpolate($this->reason),
'source' => 'PHPCI',
'url' => $this->phpci->interpolate('%BUILD_URI%'),
'branch' => $this->phpci->interpolate('%BRANCH%'),
'update_only' => $this->updateOnly
));
return $response['success'];

View file

@ -23,13 +23,8 @@ use Psr\Log\LogLevel;
* @package PHPCI
* @subpackage Plugins
*/
class Email extends AbstractPlugin
class Email implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
/**
* @var \PHPCI\Builder
*/

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Env extends AbstractPlugin
class Env implements \PHPCI\Plugin
{
protected $phpci;
protected $build;

View file

@ -19,13 +19,8 @@ use Mremi\Flowdock\Api\Push\TeamInboxMessage;
* @package PHPCI
* @subpackage Plugins
*/
class FlowdockNotify extends AbstractPlugin
class FlowdockNotify implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
private $api_key;
private $email;
const MESSAGE_DEFAULT = 'Build %BUILD% has finished for commit <a href="%COMMIT_URI%">%SHORT_COMMIT%</a>

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Git extends AbstractPlugin
class Git implements \PHPCI\Plugin
{
protected $phpci;
protected $build;

View file

@ -18,7 +18,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Grunt extends AbstractPlugin
class Grunt implements \PHPCI\Plugin
{
protected $directory;
protected $task;

View file

@ -18,7 +18,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Gulp extends AbstractPlugin
class Gulp implements \PHPCI\Plugin
{
protected $directory;
protected $task;

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class HipchatNotify extends AbstractPlugin
class HipchatNotify implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
protected $authToken;
protected $color;
protected $notify;

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Irc extends AbstractPlugin
class Irc implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
protected $phpci;
protected $build;
protected $message;

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Lint extends AbstractPlugin
class Lint implements PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $directories;
protected $recursive = true;
protected $ignore;
@ -121,8 +116,7 @@ class Lint extends AbstractPlugin
continue;
}
$itemPath = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$itemPath .= ltrim($item->getFilename(), DIRECTORY_SEPARATOR);
$itemPath = $path . $item->getFilename();
if (in_array($itemPath, $this->ignore)) {
continue;

View file

@ -21,7 +21,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Mysql extends AbstractPlugin
class Mysql implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -18,7 +18,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class PackageBuild extends AbstractPlugin
class PackageBuild implements \PHPCI\Plugin
{
protected $directory;
protected $filename;

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Pdepend extends AbstractPlugin
class Pdepend implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $args;
/**
* @var \PHPCI\Builder

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Pgsql extends AbstractPlugin
class Pgsql implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -10,7 +10,7 @@ use Phar as PHPPhar;
/**
* Phar Plugin
*/
class Phar extends AbstractPlugin
class Phar implements \PHPCI\Plugin
{
/**
* PHPCI

View file

@ -20,7 +20,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Phing extends AbstractPlugin
class Phing implements \PHPCI\Plugin
{
private $directory;

View file

@ -13,7 +13,6 @@ use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Model\BuildError;
use PHPCI\ZeroConfigPlugin;
/**
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
@ -21,13 +20,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class PhpCodeSniffer extends AbstractPlugin implements ZeroConfigPlugin
class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/
@ -86,7 +80,7 @@ class PhpCodeSniffer extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

12
PHPCI/Plugin/PhpCpd.php Normal file → Executable file
View file

@ -20,13 +20,8 @@ use PHPCI\Model\BuildError;
* @package PHPCI
* @subpackage Plugins
*/
class PhpCpd extends AbstractPlugin
class PhpCpd implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $directory;
protected $args;
protected $phpci;
@ -55,17 +50,12 @@ class PhpCpd extends AbstractPlugin
$this->build = $build;
$this->path = $phpci->buildPath;
$this->standard = 'PSR1';
$this->ignore = $phpci->ignore;
if (!empty($options['path'])) {
$this->path = $phpci->buildPath . $options['path'];
}
if (!empty($options['standard'])) {
$this->standard = $options['standard'];
}
if (!empty($options['ignore'])) {
$this->ignore = $options['ignore'];
}

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class PhpCsFixer extends AbstractPlugin
class PhpCsFixer implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -12,7 +12,6 @@ namespace PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\ZeroConfigPlugin;
/**
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
@ -20,13 +19,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class PhpDocblockChecker extends AbstractPlugin implements ZeroConfigPlugin
class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/
@ -58,7 +52,7 @@ class PhpDocblockChecker extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -12,7 +12,6 @@ namespace PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\ZeroConfigPlugin;
/**
* PHP Loc - Allows PHP Copy / Lines of Code testing.
@ -20,7 +19,7 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class PhpLoc extends AbstractPlugin implements ZeroConfigPlugin
class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @var string
@ -38,7 +37,7 @@ class PhpLoc extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -12,7 +12,6 @@ namespace PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\ZeroConfigPlugin;
/**
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
@ -20,13 +19,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class PhpMessDetector extends AbstractPlugin implements ZeroConfigPlugin
class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/
@ -68,7 +62,7 @@ class PhpMessDetector extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class PhpParallelLint extends AbstractPlugin
class PhpParallelLint implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class PhpSpec extends AbstractPlugin
class PhpSpec implements PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/

View file

@ -19,13 +19,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class PhpTalLint extends AbstractPlugin
class PhpTalLint implements PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $directories;
protected $recursive = true;
protected $suffixes;

View file

@ -13,7 +13,6 @@ use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin\Util\TapParser;
use PHPCI\ZeroConfigPlugin;
/**
* PHP Unit Plugin - Allows PHP Unit testing.
@ -21,13 +20,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class PhpUnit extends AbstractPlugin implements ZeroConfigPlugin
class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
protected $args;
protected $phpci;
protected $build;
@ -62,7 +56,7 @@ class PhpUnit extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test' && !is_null(self::findConfigFile($builder->buildPath))) {
return true;

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Shell extends AbstractPlugin
class Shell implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -17,13 +17,8 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class SlackNotify extends AbstractPlugin
class SlackNotify implements \PHPCI\Plugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
private $webHook;
private $room;
private $username;

View file

@ -19,7 +19,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Sqlite extends AbstractPlugin
class Sqlite implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -12,7 +12,6 @@ namespace PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\ZeroConfigPlugin;
/**
* Technical Debt Plugin - Checks for existence of "TODO", "FIXME", etc.
@ -21,13 +20,8 @@ use PHPCI\ZeroConfigPlugin;
* @package PHPCI
* @subpackage Plugins
*/
class TechnicalDebt extends AbstractPlugin implements ZeroConfigPlugin
class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @inheritdoc
*/
protected $allowedStages = array('test');
/**
* @var \PHPCI\Builder
*/
@ -73,7 +67,7 @@ class TechnicalDebt extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
public static function canExecute($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -138,7 +138,7 @@ class Executor
$this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING);
// Try and execute it
if ($this->executePlugin($plugin, $options, $stage)) {
if ($this->executePlugin($plugin, $options)) {
// Execution was successful
$this->logger->logSuccess(Lang::get('plugin_success'));
$this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS);
@ -166,12 +166,8 @@ class Executor
/**
* Executes a given plugin, with options and returns the result.
* @param string $plugin Plugin name
* @param array $options Plugin options (from phpci.yml)
* @param string $stage Stage name
* @return bool
*/
public function executePlugin($plugin, $options, $stage)
public function executePlugin($plugin, $options)
{
// Any plugin name without a namespace separator is a PHPCI built in plugin
// if not we assume it's a fully name-spaced class name that implements the plugin interface.
@ -192,12 +188,6 @@ class Executor
try {
// Build and run it
$obj = $this->pluginFactory->buildPlugin($class, $options);
if (!$obj->isAllowedInStage($stage)) {
$this->logger->logFailure('Plugin "' . $plugin . '" cannot be run in stage: ' . $stage);
return false;
}
return $obj->execute();
} catch (\Exception $ex) {
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);

View file

@ -20,6 +20,7 @@ class Codeception implements ParserInterface
protected $totalTests;
protected $totalTimeTaken;
protected $totalFailures;
protected $totalErrors;
/**
* @param Builder $phpci
@ -29,7 +30,6 @@ class Codeception implements ParserInterface
{
$this->phpci = $phpci;
$this->resultsXml = $resultsXml;
$this->totalTests = 0;
}
@ -47,6 +47,7 @@ class Codeception implements ParserInterface
$this->totalTests += (int) $testsuite['tests'];
$this->totalTimeTaken += (float) $testsuite['time'];
$this->totalFailures += (int) $testsuite['failures'];
$this->totalErrors += (int) $testsuite['errors'];
foreach ($testsuite->testcase as $testcase) {
$testresult = array(
@ -67,9 +68,9 @@ class Codeception implements ParserInterface
$testresult['feature'] = sprintf('%s::%s', $testresult['class'], $testresult['name']);
}
if (isset($testcase->failure)) {
if (isset($testcase->failure) || isset($testcase->error)) {
$testresult['pass'] = false;
$testresult['message'] = (string) $testcase->failure;
$testresult['message'] = (string)$testcase->failure . (string)$testcase->error;
} else {
$testresult['pass'] = true;
}
@ -108,6 +109,6 @@ class Codeception implements ParserInterface
*/
public function getTotalFailures()
{
return $this->totalFailures;
return $this->totalFailures + $this->totalErrors;
}
}

View file

@ -18,7 +18,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class Wipe extends AbstractPlugin
class Wipe implements \PHPCI\Plugin
{
/**
* @var \PHPCI\Builder

View file

@ -18,7 +18,7 @@ use PHPCI\Model\Build;
* @package PHPCI
* @subpackage Plugins
*/
class XMPP extends AbstractPlugin
class XMPP implements \PHPCI\Plugin
{
protected $directory;
protected $phpci;

View file

@ -30,6 +30,11 @@ class BuildService
*/
protected $buildStore;
/**
* @var bool
*/
public $queueError = false;
/**
* @param BuildStore $buildStore
*/
@ -155,27 +160,30 @@ class BuildService
}
$config = Config::getInstance();
$settings = $config->get('phpci.worker', []);
if (!empty($settings['host']) && !empty($settings['queue'])) {
$jobData = array(
'type' => 'phpci.build',
'build_id' => $build->getId(),
);
try {
$jobData = array(
'type' => 'phpci.build',
'build_id' => $build->getId(),
);
if ($config->get('using_custom_file')) {
$jobData['config'] = $config->getArray();
if ($config->get('using_custom_file')) {
$jobData['config'] = $config->getArray();
}
$pheanstalk = new Pheanstalk($settings['host']);
$pheanstalk->useTube($settings['queue']);
$pheanstalk->put(
json_encode($jobData),
PheanstalkInterface::DEFAULT_PRIORITY,
PheanstalkInterface::DEFAULT_DELAY,
$config->get('phpci.worker.job_timeout', 600)
);
} catch (\Exception $ex) {
$this->queueError = true;
}
$pheanstalk = new Pheanstalk($settings['host']);
$pheanstalk->useTube($settings['queue']);
$pheanstalk->put(
json_encode($jobData),
PheanstalkInterface::DEFAULT_PRIORITY,
PheanstalkInterface::DEFAULT_DELAY,
$config->get('phpci.worker.job_timeout', 600)
);
}
}
}

View file

@ -54,4 +54,27 @@ class BuildErrorStore extends BuildErrorStoreBase
return array();
}
}
/**
* Gets the total number of errors for a given build.
* @param $buildId
* @param string $since date string
* @return array
*/
public function getErrorTotalForBuild($buildId)
{
$query = 'SELECT COUNT(*) AS total FROM build_error
WHERE build_id = :build';
$stmt = Database::getConnection('read')->prepare($query);
$stmt->bindValue(':build', $buildId, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
return $res['total'];
} else {
return array();
}
}
}

View file

@ -165,6 +165,7 @@ class BuildStore extends BuildStoreBase
$stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
$stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);
$stmt->bindValue(':numResults', (int)$numResults, \PDO::PARAM_INT);
if (!is_null($branch)) {
$stmt->bindValue(':branch', $branch, \PDO::PARAM_STR);
}
@ -183,7 +184,6 @@ class BuildStore extends BuildStoreBase
} else {
return $rtn;
}
} else {
return null;
}

View file

@ -149,7 +149,6 @@
</tr>
</thead>
<tbody>
<?php print $data['error_html']; ?>
</tbody>
</table>
</div>

View file

@ -292,6 +292,14 @@
<!-- Main content -->
<section class="content">
<?php
if (!empty($_SESSION['global_error'])) {
$message = $_SESSION['global_error'];
unset($_SESSION['global_error']);
print '<div class="alert alert-danger">' . $message . '</div>';
}
?>
<?php print $content; ?>
</section><!-- /.content -->
</aside><!-- /.content-wrapper -->

View file

@ -17,5 +17,5 @@ use PHPCI\Model\Build;
*/
interface ZeroConfigPlugin
{
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
public static function canExecute($stage, Builder $builder, Build $build);
}

View file

@ -11,7 +11,13 @@ PHPCI is a free and open source (BSD License) continuous integration tool specif
We have a chat room for discussing PHPCI, you can access it here: [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Block8/PHPCI?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)
##What it does:
**Support the development of PHPCI**
We [now accept donations](https://www.phptesting.org/support) to directly support the ongoing development of PHPCI. There is of course no obligation to donate, nor any commitment if you do.
[Donate](https://www.phptesting.org/support)
## What it does:
* Clones your project from Github, Bitbucket or a local path
* Allows you to set up and tear down test databases.
* Installs your project's Composer dependencies.
@ -19,17 +25,17 @@ We have a chat room for discussing PHPCI, you can access it here: [![Gitter](htt
* You can mark directories for the plugins to ignore.
* You can mark certain plugins as being allowed to fail (but still run.)
##What it doesn't do (yet):
* Virtualised testing. *(In progress)*
* Multiple PHP-version tests. *(In progress)*
### What it doesn't do (yet):
* Virtualised testing.
* Multiple PHP-version tests.
* Install PEAR or PECL extensions.
* [Deployments](http://phpdeployment.org)
* Deployments - We strongly recommend using [Deployer](http://phpdeployment.org)
## Getting Started:
We've got documentation on our website on [installing PHPCI](https://www.phptesting.org/install-phpci) and [adding support for PHPCI to your projects](https://www.phptesting.org/wiki/Adding-PHPCI-Support-to-Your-Projects).
##Contributing
Contributions from others would be very much appreciated! Please read our [guide to contributing](https://www.phptesting.org/wiki/Contributing-to-PHPCI) for more information on how to get involved.
## Contributing
Contributions from others would be very much appreciated! Please read our [guide to contributing](https://github.com/Block8/PHPCI/blob/master/.github/CONTRIBUTING.md) for more information on how to get involved.
##Questions?
Your best place to go is the [mailing list](https://groups.google.com/forum/#!forum/php-ci), if you're already a member of the mailing list, you can simply email php-ci@googlegroups.com.
## Questions?
Your best place to go is the [mailing list](https://groups.google.com/forum/#!forum/php-ci). If you're already a member of the mailing list, you can simply email php-ci@googlegroups.com.

View file

@ -49,7 +49,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
->shouldBeCalledTimes(1)
->willReturn($this->prophesize('PHPCI\Plugin')->reveal());
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
$this->testedExecutor->executePlugin($pluginName, $options);
}
public function testExecutePlugin_KeepsCalledNameSpace()
@ -61,7 +61,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
->shouldBeCalledTimes(1)
->willReturn($this->prophesize('PHPCI\Plugin')->reveal());
$this->testedExecutor->executePlugin($pluginClass, $options, 'test');
$this->testedExecutor->executePlugin($pluginClass, $options);
}
public function testExecutePlugin_CallsExecuteOnFactoryBuildPlugin()
@ -76,7 +76,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
$this->mockFactory->buildPlugin(Argument::any(), Argument::any())->willReturn($mockPlugin->reveal());
$this->mockFactory->getResourceFor('PHPCI\Model\Build')->willReturn($build);
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
$this->testedExecutor->executePlugin($pluginName, $options);
}
public function testExecutePlugin_ReturnsPluginSuccess()
@ -91,7 +91,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
$this->mockFactory->buildPlugin(Argument::any(), Argument::any())->willReturn($mockPlugin->reveal());
$returnValue = $this->testedExecutor->executePlugin($pluginName, $options, 'test');
$returnValue = $this->testedExecutor->executePlugin($pluginName, $options);
$this->assertEquals($expectedReturnValue, $returnValue);
}
@ -103,7 +103,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
$this->mockBuildLogger->logFailure('Plugin does not exist: ' . $pluginName)->shouldBeCalledTimes(1);
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
$this->testedExecutor->executePlugin($pluginName, $options);
}
public function testExecutePlugin_LogsFailureWhenExceptionsAreThrownByPlugin()
@ -121,7 +121,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
$this->mockBuildLogger->logFailure('Exception: ' . $expectedException->getMessage(), $expectedException)
->shouldBeCalledTimes(1);
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
$this->testedExecutor->executePlugin($pluginName, $options);
}
public function testExecutePlugins_CallsEachPluginForStage()

View file

@ -14,7 +14,7 @@ use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin;
class ExamplePluginFull extends Plugin\AbstractPlugin {
class ExamplePluginFull implements Plugin {
/**
* @var array
*/

View file

@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithNoConstructorArgs extends Plugin\AbstractPlugin
class ExamplePluginWithNoConstructorArgs implements Plugin
{
public function execute()
{

View file

@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleOptionalArg extends Plugin\AbstractPlugin
class ExamplePluginWithSingleOptionalArg implements Plugin
{
function __construct($optional = null)
{

View file

@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleRequiredArg extends Plugin\AbstractPlugin
class ExamplePluginWithSingleRequiredArg implements Plugin
{
public $RequiredArgument;

View file

@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
use PHPCI\Plugin;
class ExamplePluginWithSingleTypedRequiredArg extends Plugin\AbstractPlugin
class ExamplePluginWithSingleTypedRequiredArg implements Plugin
{
public $RequiredArgument;

460
composer.lock generated

File diff suppressed because it is too large Load diff