本文整理汇总了PHP中PHPCI\Builder类的典型用法代码示例。如果您正苦于以下问题:PHP Builder类的具体用法?PHP Builder怎么用?PHP Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Builder $phpci, Build $build, array $options = array())
{
$this->phpci = $phpci;
$this->build = $build;
$buildSettings = $phpci->getConfig('build_settings');
if (isset($buildSettings['redmine'])) {
$redmine = $buildSettings['redmine'];
$this->server = $redmine['server'];
$this->apiKey = $redmine['api_key'];
}
if (isset($options['enabled'])) {
$this->enabled = $options['enabled'];
}
if (isset($options['status'])) {
$this->status = $options['status'];
}
if (isset($options['prev_status'])) {
$this->prevStatus = $options['prev_status'];
}
if (isset($options['percent'])) {
$this->percent = $options['percent'];
}
if (isset($options['lang'])) {
$this->lang = $options['lang'];
}
if (isset($options['issue_regexp'])) {
$this->issueRegexp = $options['issue_regexp'];
}
$parser = new YamlParser();
$config = (array) $parser->parse(file_get_contents(__DIR__ . '/messages.yml'));
$this->messages = $config[$this->lang];
}
示例2: setUp
/**
* Setup the test environment.
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->builderMock = $this->getMockBuilder('PHPCI\\Builder')->getMock();
$this->buildMock = $this->getMockBuilder('PHPCI\\Model\\Build')->getMock();
$this->builderMock->method('log')->willReturn(null);
$this->builderMock->method('logSuccess')->willReturn(null);
$this->builderMock->method('logFailure')->willReturn(null);
$this->buildMock->method('getBranch')->willReturn('master');
}
示例3: postCloneSetup
/**
* Handle post-clone tasks (switching branch, etc.)
* @param Builder $builder
* @param $cloneTo
* @return bool
*/
protected function postCloneSetup(Builder $builder, $cloneTo)
{
$success = true;
$commit = $this->getCommitId();
// Allow switching to a specific branch:
if (!empty($commit) && $commit != 'Manual') {
$cmd = 'cd "%s" && hg checkout %s';
$success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch());
}
return $success;
}
示例4: handleSymlink
protected function handleSymlink(Builder $builder, $reference, $buildPath)
{
if (is_link($buildPath) && is_file($buildPath)) {
unlink($buildPath);
}
$builder->log(sprintf('Symlinking: %s to %s', $reference, $buildPath));
if (!symlink($reference, $buildPath)) {
$builder->logFailure('Failed to symlink.');
return false;
}
return true;
}
示例5: __construct
/**
* Standard Constructor
*
* $options['directory'] Output Directory. Default: %BUILDPATH%
* $options['filename'] Phar Filename. Default: build.phar
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
* $options['stub'] Stub Content. No Default Value
*
* @param Builder $phpci
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
{
$this->phpci = $phpci;
$this->build = $build;
$this->message = $options['message'];
$buildSettings = $phpci->getConfig('build_settings');
if (isset($buildSettings['irc'])) {
$irc = $buildSettings['irc'];
$this->server = $irc['server'];
$this->port = $irc['port'];
$this->room = $irc['room'];
$this->nick = $irc['nick'];
}
}
示例6: execute
/**
* Triggers Jenkins Build for the project
*/
public function execute()
{
$success = true;
if ($this->build->isSuccessful()) {
// Builds the Jenkins trigger
$jenkins = $this->jenkinsUrl . '/job/' . rawurlencode($this->jenkinsProject) . '/build?delay=0sec';
if ($this->jenkinsToken && !empty($this->jenkinsToken)) {
$jenkins .= '&token=%s';
}
$jenkins = sprintf($jenkins, rawurlencode($this->jenkinsProject), $this->jenkinsToken);
$this->phpci->log($jenkins);
$curlHandler = curl_init($jenkins);
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
curl_exec($curlHandler);
$status = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
$curlUrl = curl_getinfo($curlHandler, CURLINFO_EFFECTIVE_URL);
curl_close($curlHandler);
if ($status != '200') {
$this->phpci->logFailure($curlUrl . ' return with status code ' . $status);
return false;
}
} else {
$this->phpci->log('Skipping due to failed Build');
}
return $success;
}
示例7: execute
/**
* Send a notification mail.
*/
public function execute()
{
$addresses = $this->getEmailAddresses();
// Without some email addresses in the yml file then we
// can't do anything.
if (count($addresses) == 0) {
return false;
}
$buildStatus = $this->build->isSuccessful() ? "Passing Build" : "Failing Build";
$projectName = $this->build->getProject()->getTitle();
try {
$view = $this->getMailTemplate();
} catch (Exception $e) {
$this->phpci->log(sprintf('Unknown mail template "%s", falling back to default.', $this->options['template']), LogLevel::WARNING);
$view = $this->getDefaultMailTemplate();
}
$view->build = $this->build;
$view->project = $this->build->getProject();
$layout = new View('Email/layout');
$layout->build = $this->build;
$layout->project = $this->build->getProject();
$layout->content = $view->render();
$body = $layout->render();
$sendFailures = $this->sendSeparateEmails($addresses, sprintf("PHPCI - %s - %s", $projectName, $buildStatus), $body);
// This is a success if we've not failed to send anything.
$this->phpci->log(sprintf("%d emails sent", count($addresses) - $sendFailures));
$this->phpci->log(sprintf("%d emails failed to send", $sendFailures));
return $sendFailures === 0;
}
示例8: execute
/**
* Connects to MySQL and runs a specified set of queries.
*/
public function execute()
{
$addresses = $this->getEmailAddresses();
// Without some email addresses in the yml file then we
// can't do anything.
if (count($addresses) == 0) {
return false;
}
$subjectTemplate = "PHPCI - %s - %s";
$projectName = $this->phpci->getBuildProjectTitle();
$logText = $this->build->getLog();
if ($this->build->isSuccessful()) {
$sendFailures = $this->sendSeparateEmails($addresses, sprintf($subjectTemplate, $projectName, "Passing Build"), sprintf("Log Output: <br><pre>%s</pre>", $logText));
} else {
$view = new View('Email/failed');
$view->build = $this->build;
$view->project = $this->build->getProject();
$emailHtml = $view->render();
$sendFailures = $this->sendSeparateEmails($addresses, sprintf($subjectTemplate, $projectName, "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)));
return count($sendFailures) == 0;
}
示例9: execute
/**
* Runs Pdepend with the given criteria as arguments
*/
public function execute()
{
if (!is_writable($this->location)) {
throw new \Exception(sprintf('The location %s is not writable.', $this->location));
}
$pdepend = $this->phpci->findBinary('pdepend');
if (!$pdepend) {
$this->phpci->logFailure(Lang::get('could_not_find', 'pdepend'));
return false;
}
$cmd = $pdepend . ' --summary-xml="%s" --jdepend-chart="%s" --overview-pyramid="%s" %s "%s"';
$this->removeBuildArtifacts();
// If we need to ignore directories
if (count($this->phpci->ignore)) {
$ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
} else {
$ignore = '';
}
$success = $this->phpci->executeCommand($cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, $this->location . DIRECTORY_SEPARATOR . $this->chart, $this->location . DIRECTORY_SEPARATOR . $this->pyramid, $ignore, $this->directory);
$config = $this->phpci->getSystemConfig('phpci');
if ($success) {
$this->phpci->logSuccess(sprintf("Pdepend successful. You can use %s\n, ![Chart](%s \"Pdepend Chart\")\n\n and ![Pyramid](%s \"Pdepend Pyramid\")\n\n for inclusion in the readme.md file", $config['url'] . '/build/pdepend/' . $this->summary, $config['url'] . '/build/pdepend/' . $this->chart, $config['url'] . '/build/pdepend/' . $this->pyramid));
}
return $success;
}
示例10: execute
/**
* Runs PHP Spec tests.
*/
public function execute()
{
$curdir = getcwd();
chdir($this->phpci->buildPath);
$phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
if (!$phpspec) {
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpspec'));
return false;
}
$success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run');
$output = $this->phpci->getLastOutput();
chdir($curdir);
/*
* process xml output
*
* <testsuites time=FLOAT tests=INT failures=INT errors=INT>
* <testsuite name=STRING time=FLOAT tests=INT failures=INT errors=INT skipped=INT>
* <testcase name=STRING time=FLOAT classname=STRING status=STRING/>
* </testsuite>
* </testsuites
*/
$xml = new \SimpleXMLElement($output);
$attr = $xml->attributes();
$data = array('time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'suites' => array());
/**
* @var \SimpleXMLElement $group
*/
foreach ($xml->xpath('testsuite') as $group) {
$attr = $group->attributes();
$suite = array('name' => (string) $attr['name'], 'time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'skipped' => (int) $attr['skipped'], 'cases' => array());
/**
* @var \SimpleXMLElement $child
*/
foreach ($group->xpath('testcase') as $child) {
$attr = $child->attributes();
$case = array('name' => (string) $attr['name'], 'classname' => (string) $attr['classname'], 'time' => (double) $attr['time'], 'status' => (string) $attr['status']);
if ($case['status'] == 'failed') {
$error = array();
/*
* ok, sad, we had an error
*
* there should be one - foreach makes this easier
*/
foreach ($child->xpath('failure') as $failure) {
$attr = $failure->attributes();
$error['type'] = (string) $attr['type'];
$error['message'] = (string) $attr['message'];
}
foreach ($child->xpath('system-err') as $system_err) {
$error['raw'] = (string) $system_err;
}
$case['error'] = $error;
}
$suite['cases'][] = $case;
}
$data['suites'][] = $suite;
}
$this->build->storeMeta('phpspec', $data);
return $success;
}
示例11: execute
/**
* Runs PHP Copy/Paste Detector in a specified directory.
*/
public function execute()
{
$ignore = '';
if (count($this->phpci->ignore)) {
$map = function ($item) {
return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item);
};
$ignore = array_map($map, $this->phpci->ignore);
$ignore = implode('', $ignore);
}
$phploc = $this->phpci->findBinary('phploc');
if (!$phploc) {
$this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phploc'));
return false;
}
$success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory);
$output = $this->phpci->getLastOutput();
if (preg_match_all('/\\((LOC|CLOC|NCLOC|LLOC)\\)\\s+([0-9]+)/', $output, $matches)) {
$data = array();
foreach ($matches[1] as $k => $v) {
$data[$v] = (int) $matches[2][$k];
}
$this->build->storeMeta('phploc', $data);
}
return $success;
}
示例12: execute
/**
* Run PHP CS Fixer.
* @return bool
*/
public function execute()
{
$curdir = getcwd();
chdir($this->workingdir);
$phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
$cmd = $phpcsfixer . ' fix . %s %s %s';
$success = $this->phpci->executeCommand($cmd, $this->verbose, $this->diff, $this->level);
chdir($curdir);
return $success;
}
示例13: execute
/**
* Runs PHP Spec tests.
*/
public function execute()
{
$curdir = getcwd();
chdir($this->phpci->buildPath);
$phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
if (!$phpspec) {
$this->phpci->logFailure('Could not find phpspec.');
return false;
}
$success = $this->phpci->executeCommand($phpspec . ' --format=pretty --no-code-generation run');
chdir($curdir);
return $success;
}
示例14: execute
/**
* Executes parallel lint
*/
public function execute()
{
list($ignore) = $this->getFlags();
$phplint = $this->phpci->findBinary('parallel-lint');
$cmd = $phplint . ' %s "%s"';
$success = $this->phpci->executeCommand($cmd, $ignore, $this->directory);
$output = $this->phpci->getLastOutput();
$matches = array();
if (preg_match_all('/Parse error\\:/', $output, $matches)) {
$this->build->storeMeta('phplint-errors', count($matches[0]));
}
return $success;
}
示例15: execute
/**
* Connects to PgSQL and runs a specified set of queries.
* @return boolean
*/
public function execute()
{
try {
$opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
foreach ($this->queries as $query) {
$pdo->query($this->phpci->interpolate($query));
}
} catch (\Exception $ex) {
$this->phpci->logFailure($ex->getMessage());
return false;
}
return true;
}