Builder, build plugins
This commit is contained in:
parent
6e469b01ec
commit
5dd42da9a0
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI;
|
||||
|
||||
use PHPCI\Helper\BuildInterpolator;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Helper\MailerFactory;
|
||||
use PHPCI\Logging\BuildLogger;
|
||||
use PHPCI\Model\Build;
|
||||
|
@ -135,7 +136,7 @@ class Builder implements LoggerAwareInterface
|
|||
public function setConfigArray($config)
|
||||
{
|
||||
if (is_null($config) || !is_array($config)) {
|
||||
throw new \Exception('This project does not contain a phpci.yml file, or it is empty.');
|
||||
throw new \Exception(Lang::get('missing_phpci_yml'));
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
|
@ -209,14 +210,14 @@ class Builder implements LoggerAwareInterface
|
|||
|
||||
if ($success) {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'success');
|
||||
$this->buildLogger->logSuccess('BUILD SUCCESSFUL!');
|
||||
$this->buildLogger->logSuccess(Lang::get('build_success'));
|
||||
} else {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'failure');
|
||||
$this->buildLogger->logFailure("BUILD FAILURE");
|
||||
$this->buildLogger->logFailure(Lang::get('build_failed'));
|
||||
}
|
||||
|
||||
// Clean up:
|
||||
$this->buildLogger->log('Removing build.');
|
||||
$this->buildLogger->log(Lang::get('removing_build'));
|
||||
|
||||
$cmd = 'rm -Rf "%s"';
|
||||
if (IS_WIN) {
|
||||
|
@ -225,7 +226,7 @@ class Builder implements LoggerAwareInterface
|
|||
$this->executeCommand($cmd, $this->buildPath);
|
||||
} catch (\Exception $ex) {
|
||||
$this->build->setStatus(Build::STATUS_FAILED);
|
||||
$this->buildLogger->logFailure('Exception: ' . $ex->getMessage());
|
||||
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -293,7 +294,7 @@ class Builder implements LoggerAwareInterface
|
|||
|
||||
// Create a working copy of the project:
|
||||
if (!$this->build->createWorkingCopy($this, $this->buildPath)) {
|
||||
throw new \Exception('Could not create a working copy.');
|
||||
throw new \Exception(Lang::get('could_not_create_working'));
|
||||
}
|
||||
|
||||
// Does the project's phpci.yml request verbose mode?
|
||||
|
@ -306,7 +307,7 @@ class Builder implements LoggerAwareInterface
|
|||
$this->ignore = $this->config['build_settings']['ignore'];
|
||||
}
|
||||
|
||||
$this->buildLogger->logSuccess('Working copy created: ' . $this->buildPath);
|
||||
$this->buildLogger->logSuccess(Lang::get('working_copy_created', $this->buildPath));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace PHPCI\Command;
|
||||
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Service\UserService;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
@ -30,7 +31,7 @@ class CreateAdminCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('phpci:create-admin')
|
||||
->setDescription('Create an admin user');
|
||||
->setDescription(Lang::get('create_admin_user'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,20 +45,20 @@ class CreateAdminCommand extends Command
|
|||
require(PHPCI_DIR . 'bootstrap.php');
|
||||
|
||||
// Try to create a user account:
|
||||
$adminEmail = $this->ask('Admin email address: ', true, FILTER_VALIDATE_EMAIL);
|
||||
$adminEmail = $this->ask(Lang::get('enter_email'), true, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if (empty($adminEmail)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$adminPass = $this->ask('Admin password: ');
|
||||
$adminName = $this->ask('Admin name: ');
|
||||
$adminPass = $this->ask(Lang::get('enter_pass'));
|
||||
$adminName = $this->ask(Lang::get('enter_name'));
|
||||
|
||||
try {
|
||||
$userService->createUser($adminName, $adminEmail, $adminPass, 1);
|
||||
print 'User account created!' . PHP_EOL;
|
||||
print Lang::get('user_created') . PHP_EOL;
|
||||
} catch (\Exception $ex) {
|
||||
print 'There was a problem creating your account. :(' . PHP_EOL;
|
||||
print Lang::get('failed_to_create') . PHP_EOL;
|
||||
print $ex->getMessage();
|
||||
print PHP_EOL;
|
||||
}
|
||||
|
@ -108,13 +109,13 @@ class CreateAdminCommand extends Command
|
|||
switch ($filter)
|
||||
{
|
||||
case FILTER_VALIDATE_URL:
|
||||
$statusMessage = 'Incorrect url format.' . PHP_EOL;
|
||||
$statusMessage = Lang::get('must_be_valid_url') . PHP_EOL;
|
||||
break;
|
||||
case FILTER_VALIDATE_EMAIL:
|
||||
$statusMessage = 'Incorrect e-mail format.' . PHP_EOL;
|
||||
$statusMessage = Lang::get('must_be_valid_email') . PHP_EOL;
|
||||
break;
|
||||
case FILTER_VALIDATE_REGEXP:
|
||||
$statusMessage = 'Incorrect format.' . PHP_EOL;
|
||||
$statusMessage = Lang::get('incorrect_format') . PHP_EOL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Command;
|
|||
use b8\Store\Factory;
|
||||
use b8\HttpClient;
|
||||
use Monolog\Logger;
|
||||
use PHPCI\Helper\Lang;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -43,7 +44,7 @@ class PollCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('phpci:poll-github')
|
||||
->setDescription('Poll github to check if we need to start a build.');
|
||||
->setDescription(Lang::get('poll_github'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,16 +59,16 @@ class PollCommand extends Command
|
|||
$token = $this->settings['phpci']['github']['token'];
|
||||
|
||||
if (!$token) {
|
||||
$this->logger->error("No github token found");
|
||||
$this->logger->error(Lang::get('no_token'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$buildStore = Factory::getStore('Build');
|
||||
|
||||
$this->logger->addInfo("Finding projects to poll");
|
||||
$this->logger->addInfo(Lang::get('finding_projects'));
|
||||
$projectStore = Factory::getStore('Project');
|
||||
$result = $projectStore->getWhere();
|
||||
$this->logger->addInfo(sprintf("Found %d projects", count($result['items'])));
|
||||
$this->logger->addInfo(Lang::get('found_n_projects', count($result['items'])));
|
||||
|
||||
foreach ($result['items'] as $project) {
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
|
@ -77,11 +78,11 @@ class PollCommand extends Command
|
|||
$last_committer = $commits['body'][0]['commit']['committer']['email'];
|
||||
$message = $commits['body'][0]['commit']['message'];
|
||||
|
||||
$this->logger->info("Last commit to github for " . $project->getTitle() . " is " . $last_commit);
|
||||
$this->logger->info(Lang::get('last_commit_is', $project->getTitle(), $last_commit));
|
||||
|
||||
if ($project->getLastCommit() != $last_commit && $last_commit != "") {
|
||||
$this->logger->info(
|
||||
"Last commit is different from database, adding new build for " . $project->getTitle()
|
||||
Lang::get('adding_new_build')
|
||||
);
|
||||
|
||||
$build = new Build();
|
||||
|
@ -101,6 +102,6 @@ class PollCommand extends Command
|
|||
}
|
||||
}
|
||||
|
||||
$this->logger->addInfo("Finished processing builds");
|
||||
$this->logger->addInfo(Lang::get('finished_processing_builds'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace PHPCI\Command;
|
|||
|
||||
use b8\Config;
|
||||
use Monolog\Logger;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Logging\BuildDBLogHandler;
|
||||
use PHPCI\Logging\LoggedBuildContextTidier;
|
||||
use PHPCI\Logging\OutputLogHandler;
|
||||
|
@ -67,7 +68,7 @@ class RunCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('phpci:run-builds')
|
||||
->setDescription('Run all pending PHPCI builds.');
|
||||
->setDescription(Lang::get('run_all_pending'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,10 +89,10 @@ class RunCommand extends Command
|
|||
$running = $this->validateRunningBuilds();
|
||||
|
||||
$this->logger->pushProcessor(new LoggedBuildContextTidier());
|
||||
$this->logger->addInfo("Finding builds to process");
|
||||
$this->logger->addInfo(Lang::get('finding_builds'));
|
||||
$store = Factory::getStore('Build');
|
||||
$result = $store->getByStatus(0, $this->maxBuilds);
|
||||
$this->logger->addInfo(sprintf("Found %d builds", count($result['items'])));
|
||||
$this->logger->addInfo(Lang::get('found_n_builds', count($result['items'])));
|
||||
|
||||
$builds = 0;
|
||||
|
||||
|
@ -101,7 +102,7 @@ class RunCommand extends Command
|
|||
|
||||
// Skip build (for now) if there's already a build running in that project:
|
||||
if (!$this->isFromDaemon && in_array($build->getProjectId(), $running)) {
|
||||
$this->logger->addInfo('Skipping Build #'.$build->getId() . ' - Project build already in progress.');
|
||||
$this->logger->addInfo(Lang::get('skipping_build', $build->getId()));
|
||||
$result['items'][] = $build;
|
||||
|
||||
// Re-run build validator:
|
||||
|
@ -132,7 +133,7 @@ class RunCommand extends Command
|
|||
|
||||
}
|
||||
|
||||
$this->logger->addInfo("Finished processing builds");
|
||||
$this->logger->addInfo(Lang::get('finished_processing_builds'));
|
||||
|
||||
return $builds;
|
||||
}
|
||||
|
@ -164,7 +165,7 @@ class RunCommand extends Command
|
|||
$start = $build->getStarted()->getTimestamp();
|
||||
|
||||
if (($now - $start) > $timeout) {
|
||||
$this->logger->addInfo('Build #'.$build->getId().' marked as failed due to timeout.');
|
||||
$this->logger->addInfo(Lang::get('marked_as_failed', $build->getId()));
|
||||
$build->setStatus(Build::STATUS_FAILED);
|
||||
$build->setFinished(new \DateTime());
|
||||
$store->save($build);
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace PHPCI\Helper;
|
|||
|
||||
use \PHPCI\Logging\BuildLogger;
|
||||
use Psr\Log\LogLevel;
|
||||
use PHPCI\Helper\Lang;
|
||||
|
||||
abstract class BaseCommandExecutor implements CommandExecutor
|
||||
{
|
||||
|
@ -154,29 +155,30 @@ abstract class BaseCommandExecutor implements CommandExecutor
|
|||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
$this->logger->log("Looking for binary: " . $bin, LogLevel::DEBUG);
|
||||
$this->logger->log(Lang::get('looking_for_binary', $bin), LogLevel::DEBUG);
|
||||
|
||||
if (is_dir($composerBin) && is_file($composerBin.'/'.$bin)) {
|
||||
$this->logger->log("Found in ".$composerBin.": " . $bin, LogLevel::DEBUG);
|
||||
|
||||
$this->logger->log(Lang::get('found_in_path', $composerBin, $bin), LogLevel::DEBUG);
|
||||
$binaryPath = $composerBin . '/' . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_file($this->rootDir . $bin)) {
|
||||
$this->logger->log("Found in root: " . $bin, LogLevel::DEBUG);
|
||||
$this->logger->log(Lang::get('found_in_path', 'root', $bin), LogLevel::DEBUG);
|
||||
$binaryPath = $this->rootDir . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_file($this->rootDir . 'vendor/bin/' . $bin)) {
|
||||
$this->logger->log("Found in vendor/bin: " . $bin, LogLevel::DEBUG);
|
||||
$this->logger->log(Lang::get('found_in_path', 'vendor/bin', $bin), LogLevel::DEBUG);
|
||||
$binaryPath = $this->rootDir . 'vendor/bin/' . $bin;
|
||||
break;
|
||||
}
|
||||
|
||||
$findCmdResult = $this->findGlobalBinary($bin);
|
||||
if (is_file($findCmdResult)) {
|
||||
$this->logger->log("Found in " . $findCmdResult, LogLevel::DEBUG);
|
||||
$this->logger->log(Lang::get('found_in_path', '', $bin), LogLevel::DEBUG);
|
||||
$binaryPath = $findCmdResult;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -315,4 +315,66 @@ PHPCI',
|
|||
'updating_phpci' => 'Updating PHPCI database: ',
|
||||
'not_installed' => 'PHPCI does not appear to be installed.',
|
||||
'install_instead' => 'Please install PHPCI via phpci:install instead.',
|
||||
|
||||
// Poll Command
|
||||
'poll_github' => 'Poll github to check if we need to start a build.',
|
||||
'no_token' => 'No github token found',
|
||||
'finding_projects' => 'Finding projects to poll',
|
||||
'found_n_projects' => 'Found %d projects',
|
||||
'last_commit_is' => 'Last commit to github for %s is %s',
|
||||
'adding_new_build' => 'Last commit is different to database, adding new build.',
|
||||
'finished_processing_builds' => 'Finished processing builds.',
|
||||
|
||||
// Create Admin
|
||||
'create_admin_user' => 'Create an admin user',
|
||||
'incorrect_format' => 'Incorrect format',
|
||||
|
||||
// Run Command
|
||||
'run_all_pending' => 'Run all pending PHPCI builds.',
|
||||
'finding_builds' => 'Finding builds to process',
|
||||
'found_n_builds' => 'Found %d builds',
|
||||
'skipping_build' => 'Skipping Build %d - Project build already in progress.',
|
||||
'marked_as_failed' => 'Build %d marked as failed due to timeout.',
|
||||
|
||||
// Builder
|
||||
'missing_phpci_yml' => 'This project does not contain a phpci.yml file, or it is empty.',
|
||||
'build_success' => 'BUILD SUCCESS',
|
||||
'build_failed' => 'BUILD FAILED',
|
||||
'removing_build' => 'Removing Build.',
|
||||
'exception' => 'Exception: ',
|
||||
'could_not_create_working' => 'Could not create a working copy.',
|
||||
'working_copy_created' => 'Working copy created: %s',
|
||||
'looking_for_binary' => 'Looking for binary: %s',
|
||||
'found_in_path' => 'Found in %s: %s',
|
||||
'running_plugin' => 'RUNNING PLUGIN: %s',
|
||||
'plugin_success' => 'PLUGIN: SUCCESS',
|
||||
'plugin_failed' => 'PLUGIN: FAILED',
|
||||
'plugin_missing' => 'Plugin does not exist: %s',
|
||||
'tap_version' => 'TapParser only supports TAP version 13',
|
||||
'tap_error' => 'Invalid TAP string, number of tests does not match specified test count.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'No tests have been performed.',
|
||||
'could_not_find' => 'Could not find %s',
|
||||
'no_campfire_settings' => 'No connection parameters given for Campfire plugin',
|
||||
'failed_to_wipe' => 'Failed to wipe existing directory %s before copy',
|
||||
'passing_build' => 'Passing Build',
|
||||
'failing_build' => 'Failing Build',
|
||||
'log_output' => 'Log Output: ',
|
||||
'n_emails_sent' => '%d emails sent.',
|
||||
'n_emails_failed' => '%d emails failed to send.',
|
||||
'unable_to_set_env' => 'Unable to set environment variable',
|
||||
'tag_created' => 'Tag created by PHPCI: %s',
|
||||
'x_built_at_x' => '%PROJECT_TITLE% built at %BUILD_URI%',
|
||||
'hipchat_settings' => 'Please define room and authToken for hipchat_notify plugin',
|
||||
'irc_settings' => 'You must configure a server, room and nick.',
|
||||
'invalid_command' => 'Invalid command',
|
||||
'import_file_key' => 'Import statement must contain a \'file\' key',
|
||||
'cannot_open_import' => 'Cannot open SQL import file: %s',
|
||||
'unable_to_execute' => 'Unable to execute SQL file',
|
||||
'phar_internal_error' => 'Phar Plugin Internal Error',
|
||||
'build_file_missing' => 'Specified build file does not exist.',
|
||||
'property_file_missing' => 'Specified property file does not exist.',
|
||||
'could_not_process_report' => 'Could not process the report generated by this tool.',
|
||||
'shell_not_enabled' => 'The shell plugin is not enabled. Please enable it via config.yml.'
|
||||
);
|
||||
|
|
|
@ -67,7 +67,7 @@ class Atoum implements \PHPCI\Plugin
|
|||
}
|
||||
if (count($output) == 0) {
|
||||
$status = false;
|
||||
$this->phpci->log("No test have been performed!");
|
||||
$this->phpci->log(Lang::get('no_tests_performed'));
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +53,7 @@ class Behat implements \PHPCI\Plugin
|
|||
$behat = $this->executable;
|
||||
|
||||
if (!$behat) {
|
||||
$this->phpci->logFailure('Could not find behat.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'behat'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,7 @@ class Campfire implements \PHPCI\Plugin
|
|||
$this->authToken = $campfire['authToken'];
|
||||
$this->roomId = $campfire['roomId'];
|
||||
} else {
|
||||
throw new \Exception("No connection parameters given for Campfire plugin");
|
||||
throw new \Exception(Lang::get('no_campfire_settings'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -74,7 +75,7 @@ class Codeception implements \PHPCI\Plugin
|
|||
$codecept = $this->phpci->findBinary('codecept');
|
||||
|
||||
if (!$codecept) {
|
||||
$this->phpci->logFailure('Could not find codeception.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Plugin;
|
|||
use PHPCI;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Helper\Lang;
|
||||
|
||||
/**
|
||||
* Composer Plugin - Provides access to Composer functionality.
|
||||
|
@ -68,7 +69,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$composerLocation = $this->phpci->findBinary(array('composer', 'composer.phar'));
|
||||
|
||||
if (!$composerLocation) {
|
||||
$this->phpci->logFailure('Could not find Composer.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'composer'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace PHPCI\Plugin;
|
|||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Helper\Lang;
|
||||
|
||||
/**
|
||||
* Copy Build Plugin - Copies the entire build to another directory.
|
||||
|
@ -66,8 +67,9 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
if ($this->wipe == true && $this->directory != '/' && is_dir($this->directory)) {
|
||||
$cmd = 'rm -Rf "%s*"';
|
||||
$success = $this->phpci->executeCommand($cmd, $this->directory);
|
||||
|
||||
if (!$success) {
|
||||
throw new \Exception('Failed to wipe existing directory ' . $this->directory . ' before copy');
|
||||
throw new \Exception(Lang::get('failed_to_wipe', $this->directory));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace PHPCI\Plugin;
|
|||
|
||||
use b8\View;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -80,8 +81,8 @@ class Email implements \PHPCI\Plugin
|
|||
if ($this->build->isSuccessful()) {
|
||||
$sendFailures = $this->sendSeparateEmails(
|
||||
$addresses,
|
||||
sprintf($subjectTemplate, $projectName, "Passing Build"),
|
||||
sprintf("Log Output: <br><pre>%s</pre>", $logText)
|
||||
sprintf($subjectTemplate, $projectName, Lang::get('passing_build')),
|
||||
sprintf(Lang::get('log_output')."<br><pre>%s</pre>", $logText)
|
||||
);
|
||||
} else {
|
||||
$view = new View('Email/failed');
|
||||
|
@ -92,14 +93,15 @@ class Email implements \PHPCI\Plugin
|
|||
|
||||
$sendFailures = $this->sendSeparateEmails(
|
||||
$addresses,
|
||||
sprintf($subjectTemplate, $projectName, "Failing Build"),
|
||||
sprintf($subjectTemplate, $projectName, Lang::get('failing_build')),
|
||||
$emailHtml
|
||||
);
|
||||
}
|
||||
|
||||
// This is a success if we've not failed to send anything.
|
||||
$this->phpci->log(sprintf("%d emails sent", (count($addresses) - count($sendFailures))));
|
||||
$this->phpci->log(sprintf("%d emails failed to send", count($sendFailures)));
|
||||
|
||||
$this->phpci->log(Lang::get('n_emails_sent', (count($addresses) - count($sendFailures))));
|
||||
$this->phpci->log(Lang::get('n_emails_failed', count($sendFailures)));
|
||||
|
||||
return (count($sendFailures) == 0);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +49,7 @@ class Env implements \PHPCI\Plugin
|
|||
|
||||
if (!putenv($this->phpci->interpolate($env_var))) {
|
||||
$success = false;
|
||||
$this->phpci->logFailure("Unable to set environment variable");
|
||||
$this->phpci->logFailure(Lang::get('unable_to_set_env'));
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +90,7 @@ class Git implements \PHPCI\Plugin
|
|||
protected function runTagAction($options)
|
||||
{
|
||||
$tagName = date('Ymd-His');
|
||||
$message = 'Tag created by PHPCI: ' . date('Y-m-d H:i:s');
|
||||
$message = Lang::get('tag_created', date('Y-m-d H:i:s'));
|
||||
|
||||
if (array_key_exists('name', $options)) {
|
||||
$tagName = $this->phpci->interpolate($options['name']);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,7 @@ class HipchatNotify implements \PHPCI\Plugin
|
|||
if (isset($options['message'])) {
|
||||
$this->message = $options['message'];
|
||||
} else {
|
||||
$this->message = '%PROJECT_TITLE% built at %BUILD_URI%';
|
||||
$this->message = Lang::get('x_built_at_x');
|
||||
}
|
||||
|
||||
if (isset($options['color'])) {
|
||||
|
@ -56,7 +57,7 @@ class HipchatNotify implements \PHPCI\Plugin
|
|||
$this->notify = false;
|
||||
}
|
||||
} else {
|
||||
throw new \Exception('Please define room and authToken for hipchat_notify plugin!');
|
||||
throw new \Exception(Lang::get('hipchat_settings'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +53,7 @@ class Irc implements \PHPCI\Plugin
|
|||
$msg = $this->phpci->interpolate($this->message);
|
||||
|
||||
if (empty($this->server) || empty($this->room) || empty($this->nick)) {
|
||||
$this->phpci->logFailure('You must configure a server, room and nick.');
|
||||
$this->phpci->logFailure(Lang::get('irc_settings'));
|
||||
}
|
||||
|
||||
if (empty($this->port)) {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace PHPCI\Plugin;
|
|||
|
||||
use PDO;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -107,7 +108,7 @@ class Mysql implements \PHPCI\Plugin
|
|||
// SQL file execution
|
||||
$this->executeFile($query['import']);
|
||||
} else {
|
||||
throw new \Exception("Invalid command");
|
||||
throw new \Exception(Lang::get('invalid_command'));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
|
@ -125,19 +126,19 @@ class Mysql implements \PHPCI\Plugin
|
|||
protected function executeFile($query)
|
||||
{
|
||||
if (!isset($query['file'])) {
|
||||
throw new \Exception("Import statement must contain a 'file' key");
|
||||
throw new \Exception(Lang::get('import_file_key'));
|
||||
}
|
||||
|
||||
$import_file = $this->phpci->buildPath . $this->phpci->interpolate($query['file']);
|
||||
if (!is_readable($import_file)) {
|
||||
throw new \Exception("Cannot open SQL import file: $import_file");
|
||||
throw new \Exception(Lang::get('cannot_open_import', $import_file));
|
||||
}
|
||||
|
||||
$database = isset($query['database']) ? $this->phpci->interpolate($query['database']) : null;
|
||||
|
||||
$import_command = $this->getImportCommand($import_file, $database);
|
||||
if (!$this->phpci->executeCommand($import_command)) {
|
||||
throw new \Exception("Unable to execute SQL file");
|
||||
throw new \Exception(Lang::get('unable_to_execute'));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class Pdepend implements \PHPCI\Plugin
|
|||
$pdepend = $this->phpci->findBinary('pdepend');
|
||||
|
||||
if (!$pdepend) {
|
||||
$this->phpci->logFailure('Could not find pdepend.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'pdepend'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,11 +111,8 @@ class Pdepend implements \PHPCI\Plugin
|
|||
$config['url'] . '/build/pdepend/' . $this->pyramid
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->phpci->logFailure(sprintf("The function '%s' failed"));
|
||||
}
|
||||
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace PHPCI\Plugin;
|
|||
|
||||
use Exception;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
use Phar as PHPPhar;
|
||||
|
||||
|
@ -231,7 +232,7 @@ class Phar implements \PHPCI\Plugin
|
|||
$success = true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->getPHPCI()->log('Phar Plugin Internal Error');
|
||||
$this->getPHPCI()->log(Lang::get('phar_internal_error'));
|
||||
$this->getPHPCI()->log($e->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -75,7 +76,7 @@ class Phing implements \PHPCI\Plugin
|
|||
$phingExecutable = $this->phpci->findBinary('phing');
|
||||
|
||||
if (!$phingExecutable) {
|
||||
$this->phpci->logFailure('Could not find Phing executable.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'phing'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -174,7 +175,7 @@ class Phing implements \PHPCI\Plugin
|
|||
public function setBuildFile($buildFile)
|
||||
{
|
||||
if (!file_exists($this->getDirectory() . $buildFile)) {
|
||||
throw new \Exception('Specified build file does not exists.');
|
||||
throw new \Exception(Lang::get('build_file_missing'));
|
||||
}
|
||||
|
||||
$this->buildFile = $buildFile;
|
||||
|
@ -242,7 +243,7 @@ class Phing implements \PHPCI\Plugin
|
|||
public function setPropertyFile($propertyFile)
|
||||
{
|
||||
if (!file_exists($this->getDirectory() . '/' . $propertyFile)) {
|
||||
throw new \Exception('Specified property file does not exists.');
|
||||
throw new \Exception(Lang::get('property_file_missing'));
|
||||
}
|
||||
|
||||
$this->propertyFile = $propertyFile;
|
||||
|
|
|
@ -139,7 +139,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$phpcs = $this->phpci->findBinary('phpcs');
|
||||
|
||||
if (!$phpcs) {
|
||||
$this->phpci->logFailure('Could not find phpcs.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpcs'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
|
||||
if (!is_array($data)) {
|
||||
$this->phpci->log($output);
|
||||
throw new \Exception('Could not process PHPCS report JSON.');
|
||||
throw new \Exception(PHPCI\Helper\Lang::get('could_not_process_report'));
|
||||
}
|
||||
|
||||
$errors = $data['totals']['errors'];
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -84,7 +85,7 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
$phpcpd = $this->phpci->findBinary('phpcpd');
|
||||
|
||||
if (!$phpcpd) {
|
||||
$this->phpci->logFailure('Could not find phpcpd.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'phpcpd'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
|
||||
if ($xml === false) {
|
||||
$this->phpci->log($xmlString);
|
||||
throw new \Exception('Could not process PHPCPD report XML.');
|
||||
throw new \Exception(Lang::get('could_not_process_report'));
|
||||
}
|
||||
|
||||
$warnings = 0;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +54,7 @@ class PhpCsFixer implements \PHPCI\Plugin
|
|||
$phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
|
||||
|
||||
if (!$phpcsfixer) {
|
||||
$this->phpci->logFailure('Could not find php-cs-fixer.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'php-cs-fixer'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$checker = $this->phpci->findBinary('phpdoccheck');
|
||||
|
||||
if (!$checker) {
|
||||
$this->phpci->logFailure('Could not find phpdoccheck.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpdoccheck'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$phploc = $this->phpci->findBinary('phploc');
|
||||
|
||||
if (!$phploc) {
|
||||
$this->phpci->logFailure('Could not find phploc.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phploc'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$phpmdBinaryPath = $this->phpci->findBinary('phpmd');
|
||||
|
||||
if (!$phpmdBinaryPath) {
|
||||
$this->phpci->logFailure('Could not find phpmd.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpmd'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -66,7 +67,7 @@ class PhpParallelLint implements \PHPCI\Plugin
|
|||
$phplint = $this->phpci->findBinary('parallel-lint');
|
||||
|
||||
if (!$phplint) {
|
||||
$this->phpci->logFailure('Could not find parallel-lint.');
|
||||
$this->phpci->logFailure(Lang::get('could_not_find', 'parallel-lint'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class PhpSpec implements PHPCI\Plugin
|
|||
$phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
|
||||
|
||||
if (!$phpspec) {
|
||||
$this->phpci->logFailure('Could not find phpspec.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpspec'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$phpunit = $this->phpci->findBinary('phpunit');
|
||||
|
||||
if (!$phpunit) {
|
||||
$this->phpci->logFailure('Could not find phpunit.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpunit'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
$phpunit = $this->phpci->findBinary('phpunit');
|
||||
|
||||
if (!$phpunit) {
|
||||
$this->phpci->logFailure('Could not find phpunit.');
|
||||
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpunit'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
|
@ -67,7 +68,7 @@ class Shell implements \PHPCI\Plugin
|
|||
public function execute()
|
||||
{
|
||||
if (!defined('ENABLE_SHELL_PLUGIN') || !ENABLE_SHELL_PLUGIN) {
|
||||
throw new \Exception('The shell plugin is not enabled.');
|
||||
throw new \Exception(Lang::get('shell_not_enabled'));
|
||||
}
|
||||
|
||||
$success = true;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PHPCI\Plugin\Util;
|
||||
|
||||
use PHPCI\Helper\Lang;
|
||||
use \PHPCI\Logging\BuildLogger;
|
||||
|
||||
class Executor
|
||||
|
@ -37,7 +38,7 @@ class Executor
|
|||
}
|
||||
|
||||
foreach ($config[$stage] as $plugin => $options) {
|
||||
$this->logger->log('RUNNING PLUGIN: ' . $plugin);
|
||||
$this->logger->log(Lang::get('running_plugin', $plugin));
|
||||
|
||||
// Is this plugin allowed to fail?
|
||||
if ($stage == 'test' && !isset($options['allow_failures'])) {
|
||||
|
@ -48,7 +49,7 @@ class Executor
|
|||
if ($this->executePlugin($plugin, $options)) {
|
||||
|
||||
// Execution was successful:
|
||||
$this->logger->logSuccess('PLUGIN STATUS: SUCCESS!');
|
||||
$this->logger->logSuccess(Lang::get('plugin_success'));
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -58,7 +59,7 @@ class Executor
|
|||
$success = false;
|
||||
}
|
||||
|
||||
$this->logger->logFailure('PLUGIN STATUS: FAILED');
|
||||
$this->logger->logFailure(Lang::get('plugin_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,7 @@ class Executor
|
|||
}
|
||||
|
||||
if (!class_exists($class)) {
|
||||
$this->logger->logFailure('Plugin does not exist: ' . $plugin);
|
||||
$this->logger->logFailure(Lang::get('plugin_missing', $plugin));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ class Executor
|
|||
$rtn = false;
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->logFailure('EXCEPTION: ' . $ex->getMessage(), $ex);
|
||||
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
|
||||
$rtn = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace PHPCI\Plugin\Util;
|
||||
|
||||
use PHPCI\Helper\Lang;
|
||||
|
||||
class TapParser
|
||||
{
|
||||
const TEST_COUNTS_PATTERN = '/([0-9]+)\.\.([0-9]+)/';
|
||||
|
@ -41,7 +43,7 @@ class TapParser
|
|||
$versionLine = array_shift($lines);
|
||||
|
||||
if ($versionLine != 'TAP version 13') {
|
||||
throw new \Exception('TapParser only supports TAP version 13');
|
||||
throw new \Exception(Lang::get('tap_version'));
|
||||
}
|
||||
|
||||
if (isset($lines[count($lines) - 1]) && preg_match(self::TEST_COVERAGE_PATTERN, $lines[count($lines) - 1])) {
|
||||
|
@ -67,7 +69,7 @@ class TapParser
|
|||
$rtn = $this->processTestLines($lines);
|
||||
|
||||
if ($totalTests != count($rtn)) {
|
||||
throw new \Exception('Invalid TAP string, number of tests does not match specified test count.');
|
||||
throw new \Exception(Lang::get('tap_error'));
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
|
|
Loading…
Reference in a new issue