Code style fixes for plugins.
This commit is contained in:
parent
16755eadd4
commit
5e9e3088cc
|
@ -16,11 +16,17 @@
|
||||||
|
|
||||||
<rule ref="rulesets/naming.xml">
|
<rule ref="rulesets/naming.xml">
|
||||||
<exclude name="ShortVariable"/>
|
<exclude name="ShortVariable"/>
|
||||||
|
<exclude name="ShortMethodName"/>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<rule ref="rulesets/naming.xml/ShortVariable">
|
<rule ref="rulesets/naming.xml/ShortVariable">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="exceptions" value="db,id,i,j" />
|
<property name="exceptions" value="db,dn,id,i,j" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/naming.xml/ShortMethodName">
|
||||||
|
<properties>
|
||||||
|
<property name="exceptions" value="up" />
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\Model\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project Controller - Allows users to create, edit and view projects.
|
* Project Controller - Allows users to create, edit and view projects.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class GroupController extends Controller
|
class GroupController extends Controller
|
||||||
|
@ -46,7 +46,7 @@ class GroupController extends Controller
|
||||||
];
|
];
|
||||||
$projects_active = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), false);
|
$projects_active = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), false);
|
||||||
$projects_archived = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), true);
|
$projects_archived = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), true);
|
||||||
|
|
||||||
$thisGroup['projects'] = array_merge($projects_active['items'], $projects_archived['items']);
|
$thisGroup['projects'] = array_merge($projects_active['items'], $projects_archived['items']);
|
||||||
$groups[] = $thisGroup;
|
$groups[] = $thisGroup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -647,30 +647,30 @@ class WebhookController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function gogsPullRequest(Project $project, array $payload)
|
protected function gogsPullRequest(Project $project, array $payload)
|
||||||
{
|
{
|
||||||
$pull_request = $payload['pull_request'];
|
$pullRequest = $payload['pull_request'];
|
||||||
$head_branch = $pull_request['head_branch'];
|
$headBranch = $pullRequest['head_branch'];
|
||||||
|
|
||||||
$action = $payload['action'];
|
$action = $payload['action'];
|
||||||
$active_actions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
|
$activeActions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
|
||||||
$inactive_actions = ['closed'];
|
$inactiveActions = ['closed'];
|
||||||
|
|
||||||
$state = $pull_request['state'];
|
$state = $pullRequest['state'];
|
||||||
$active_states = ['open'];
|
$activeStates = ['open'];
|
||||||
$inactive_states = ['closed'];
|
$inactiveStates = ['closed'];
|
||||||
|
|
||||||
if (!in_array($action, $active_actions) and !in_array($action, $inactive_actions)) {
|
if (!in_array($action, $activeActions) and !in_array($action, $inactiveActions)) {
|
||||||
return ['status' => 'ignored', 'message' => 'Action ' . $action . ' ignored'];
|
return ['status' => 'ignored', 'message' => 'Action ' . $action . ' ignored'];
|
||||||
}
|
}
|
||||||
if (!in_array($state, $active_states) and !in_array($state, $inactive_states)) {
|
if (!in_array($state, $activeStates) and !in_array($state, $inactiveStates)) {
|
||||||
return ['status' => 'ignored', 'message' => 'State ' . $state . ' ignored'];
|
return ['status' => 'ignored', 'message' => 'State ' . $state . ' ignored'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$envs = [];
|
$envs = [];
|
||||||
|
|
||||||
// Get environment form labels
|
// Get environment form labels
|
||||||
if (in_array($action, $active_actions) and in_array($state, $active_states)) {
|
if (in_array($action, $activeActions) and in_array($state, $activeStates)) {
|
||||||
if (isset($pull_request['labels']) && is_array($pull_request['labels'])) {
|
if (isset($pullRequest['labels']) && is_array($pullRequest['labels'])) {
|
||||||
foreach ($pull_request['labels'] as $label) {
|
foreach ($pullRequest['labels'] as $label) {
|
||||||
if (strpos($label['name'], 'env:') === 0) {
|
if (strpos($label['name'], 'env:') === 0) {
|
||||||
$envs[] = substr($label['name'], 4);
|
$envs[] = substr($label['name'], 4);
|
||||||
}
|
}
|
||||||
|
@ -678,42 +678,42 @@ class WebhookController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$envs_updated = [];
|
$envsUpdated = [];
|
||||||
$env_objs = $project->getEnvironmentsObjects();
|
$envObjects = $project->getEnvironmentsObjects();
|
||||||
$store = Factory::getStore('Environment', 'PHPCensor');;
|
$store = Factory::getStore('Environment', 'PHPCensor');
|
||||||
foreach ($env_objs['items'] as $environment) {
|
foreach ($envObjects['items'] as $environment) {
|
||||||
$branches = $environment->getBranches();
|
$branches = $environment->getBranches();
|
||||||
if (in_array($environment->getName(), $envs)) {
|
if (in_array($environment->getName(), $envs)) {
|
||||||
if (!in_array($head_branch, $branches)) {
|
if (!in_array($headBranch, $branches)) {
|
||||||
// Add branch to environment
|
// Add branch to environment
|
||||||
$branches[] = $head_branch;
|
$branches[] = $headBranch;
|
||||||
$environment->setBranches($branches);
|
$environment->setBranches($branches);
|
||||||
$store->save($environment);
|
$store->save($environment);
|
||||||
$envs_updated[] = $environment->getName();
|
$envsUpdated[] = $environment->getName();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (in_array($head_branch, $branches)) {
|
if (in_array($headBranch, $branches)) {
|
||||||
// Remove branch from environment
|
// Remove branch from environment
|
||||||
$branches = array_diff($branches, [$head_branch]);
|
$branches = array_diff($branches, [$headBranch]);
|
||||||
$environment->setBranches($branches);
|
$environment->setBranches($branches);
|
||||||
$store->save($environment);
|
$store->save($environment);
|
||||||
$envs_updated[] = $environment->getName();
|
$envsUpdated[] = $environment->getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($state == 'closed') and $pull_request['merged']) {
|
if (($state == 'closed') and $pullRequest['merged']) {
|
||||||
// update base branch enviroments
|
// update base branch environments
|
||||||
$environment_names = $project->getEnvironmentsNamesByBranch($pull_request['base_branch']);
|
$environmentNames = $project->getEnvironmentsNamesByBranch($pullRequest['base_branch']);
|
||||||
$envs_updated = array_merge($envs_updated, $environment_names);
|
$envsUpdated = array_merge($envsUpdated, $environmentNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
$envs_updated = array_unique($envs_updated);
|
$envsUpdated = array_unique($envsUpdated);
|
||||||
if (!empty($envs_updated)) {
|
if (!empty($envsUpdated)) {
|
||||||
foreach ($envs_updated as $environment_name) {
|
foreach ($envsUpdated as $environmentName) {
|
||||||
$this->buildService->createBuild(
|
$this->buildService->createBuild(
|
||||||
$project,
|
$project,
|
||||||
$environment_name,
|
$environmentName,
|
||||||
'',
|
'',
|
||||||
$project->getBranch(),
|
$project->getBranch(),
|
||||||
null,
|
null,
|
||||||
|
@ -725,7 +725,7 @@ class WebhookController extends Controller
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envs_updated)];
|
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envsUpdated)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['status' => 'ignored', 'message' => 'Branch environments not changed'];
|
return ['status' => 'ignored', 'message' => 'Branch environments not changed'];
|
||||||
|
|
|
@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composer Plugin - Provides access to Composer functionality.
|
* Composer Plugin - Provides access to Composer functionality.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class Composer extends Plugin implements ZeroConfigPluginInterface
|
class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
@ -18,7 +18,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $action;
|
protected $action;
|
||||||
protected $preferDist;
|
protected $preferDist;
|
||||||
protected $nodev;
|
protected $noDev;
|
||||||
protected $ignorePlatformReqs;
|
protected $ignorePlatformReqs;
|
||||||
protected $preferSource;
|
protected $preferSource;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->action = 'install';
|
$this->action = 'install';
|
||||||
$this->preferDist = false;
|
$this->preferDist = false;
|
||||||
$this->preferSource = false;
|
$this->preferSource = false;
|
||||||
$this->nodev = false;
|
$this->noDev = false;
|
||||||
$this->ignorePlatformReqs = false;
|
$this->ignorePlatformReqs = false;
|
||||||
|
|
||||||
if (array_key_exists('directory', $options)) {
|
if (array_key_exists('directory', $options)) {
|
||||||
|
@ -63,7 +63,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('no_dev', $options)) {
|
if (array_key_exists('no_dev', $options)) {
|
||||||
$this->nodev = (bool)$options['no_dev'];
|
$this->noDev = (bool)$options['no_dev'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('ignore_platform_reqs', $options)) {
|
if (array_key_exists('ignore_platform_reqs', $options)) {
|
||||||
|
@ -107,7 +107,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||||
$cmd .= ' --prefer-source';
|
$cmd .= ' --prefer-source';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->nodev) {
|
if ($this->noDev) {
|
||||||
$this->builder->log('Using --no-dev flag');
|
$this->builder->log('Using --no-dev flag');
|
||||||
$cmd .= ' --no-dev';
|
$cmd .= ' --no-dev';
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,11 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment variable plugin
|
* Environment variable plugin
|
||||||
*
|
*
|
||||||
* @author Steve Kamerman <stevekamerman@gmail.com>
|
* @author Steve Kamerman <stevekamerman@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Env extends Plugin
|
class Env extends Plugin
|
||||||
{
|
{
|
||||||
protected $env_vars;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +18,7 @@ class Env extends Plugin
|
||||||
{
|
{
|
||||||
return 'env';
|
return 'env';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified environment variables to the builder environment
|
* Adds the specified environment variables to the builder environment
|
||||||
*/
|
*/
|
||||||
|
@ -30,13 +28,13 @@ class Env extends Plugin
|
||||||
foreach ($this->options as $key => $value) {
|
foreach ($this->options as $key => $value) {
|
||||||
if (is_numeric($key)) {
|
if (is_numeric($key)) {
|
||||||
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
|
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
|
||||||
$env_var = is_array($value)? key($value).'='.current($value): $value;
|
$envVar = is_array($value)? key($value).'='.current($value): $value;
|
||||||
} else {
|
} else {
|
||||||
// This allows the standard syntax: "FOO: bar"
|
// This allows the standard syntax: "FOO: bar"
|
||||||
$env_var = "$key=$value";
|
$envVar = "$key=$value";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!putenv($this->builder->interpolate($env_var))) {
|
if (!putenv($this->builder->interpolate($envVar))) {
|
||||||
$success = false;
|
$success = false;
|
||||||
$this->builder->logFailure('Unable to set environment variable');
|
$this->builder->logFailure('Unable to set environment variable');
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flowdock Plugin
|
* Flowdock Plugin
|
||||||
*
|
*
|
||||||
* @author Petr Cervenka <petr@nanosolutions.io>
|
* @author Petr Cervenka <petr@nanosolutions.io>
|
||||||
*/
|
*/
|
||||||
class FlowdockNotify extends Plugin
|
class FlowdockNotify extends Plugin
|
||||||
{
|
{
|
||||||
protected $api_key;
|
protected $apiKey;
|
||||||
protected $email;
|
protected $email;
|
||||||
protected $message;
|
protected $message;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class FlowdockNotify extends Plugin
|
||||||
{
|
{
|
||||||
return 'flowdock_notify';
|
return 'flowdock_notify';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +40,7 @@ class FlowdockNotify extends Plugin
|
||||||
if (!is_array($options) || !isset($options['api_key'])) {
|
if (!is_array($options) || !isset($options['api_key'])) {
|
||||||
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
|
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
|
||||||
}
|
}
|
||||||
$this->api_key = trim($options['api_key']);
|
$this->apiKey = trim($options['api_key']);
|
||||||
$this->message = isset($options['message']) ? $options['message'] : self::MESSAGE_DEFAULT;
|
$this->message = isset($options['message']) ? $options['message'] : self::MESSAGE_DEFAULT;
|
||||||
$this->email = isset($options['email']) ? $options['email'] : 'PHP Censor';
|
$this->email = isset($options['email']) ? $options['email'] : 'PHP Censor';
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,9 @@ class FlowdockNotify extends Plugin
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
|
|
||||||
$message = $this->builder->interpolate($this->message);
|
$message = $this->builder->interpolate($this->message);
|
||||||
$successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed';
|
$successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed';
|
||||||
$push = new Push($this->api_key);
|
$push = new Push($this->apiKey);
|
||||||
$flowMessage = TeamInboxMessage::create()
|
$flowMessage = TeamInboxMessage::create()
|
||||||
->setSource("PHPCensor")
|
->setSource("PHPCensor")
|
||||||
->setFromAddress($this->email)
|
->setFromAddress($this->email)
|
||||||
|
|
|
@ -12,13 +12,14 @@ use \PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integrates PHPCensor with Mage: https://github.com/andres-montanez/Magallanes
|
* Integrates PHPCensor with Mage: https://github.com/andres-montanez/Magallanes
|
||||||
|
*
|
||||||
* @package PHPCensor
|
* @package PHPCensor
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Mage extends Plugin
|
class Mage extends Plugin
|
||||||
{
|
{
|
||||||
protected $mage_bin = 'mage';
|
protected $mageBin = 'mage';
|
||||||
protected $mage_env;
|
protected $mageEnv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -37,11 +38,11 @@ class Mage extends Plugin
|
||||||
|
|
||||||
$config = $builder->getSystemConfig('mage');
|
$config = $builder->getSystemConfig('mage');
|
||||||
if (!empty($config['bin'])) {
|
if (!empty($config['bin'])) {
|
||||||
$this->mage_bin = $config['bin'];
|
$this->mageBin = $config['bin'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['env'])) {
|
if (isset($options['env'])) {
|
||||||
$this->mage_env = $builder->interpolate($options['env']);
|
$this->mageEnv = $builder->interpolate($options['env']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +51,12 @@ class Mage extends Plugin
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
if (empty($this->mage_env)) {
|
if (empty($this->mageEnv)) {
|
||||||
$this->builder->logFailure('You must specify environment.');
|
$this->builder->logFailure('You must specify environment.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->builder->executeCommand($this->mage_bin . ' deploy to:' . $this->mage_env);
|
$result = $this->builder->executeCommand($this->mageBin . ' deploy to:' . $this->mageEnv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
||||||
|
@ -75,12 +76,12 @@ class Mage extends Plugin
|
||||||
*/
|
*/
|
||||||
protected function getMageLog()
|
protected function getMageLog()
|
||||||
{
|
{
|
||||||
$logs_dir = $this->build->getBuildPath() . '/.mage/logs';
|
$logsDir = $this->build->getBuildPath() . '/.mage/logs';
|
||||||
if (!is_dir($logs_dir)) {
|
if (!is_dir($logsDir)) {
|
||||||
throw new \Exception('Log directory not found');
|
throw new \Exception('Log directory not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = scandir($logs_dir);
|
$list = scandir($logsDir);
|
||||||
if ($list === false) {
|
if ($list === false) {
|
||||||
throw new \Exception('Log dir read fail');
|
throw new \Exception('Log dir read fail');
|
||||||
}
|
}
|
||||||
|
@ -97,17 +98,17 @@ class Mage extends Plugin
|
||||||
throw new \Exception('Logs sort fail');
|
throw new \Exception('Logs sort fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_log_file = end($list);
|
$lastLogFile = end($list);
|
||||||
if ($last_log_file === false) {
|
if ($lastLogFile === false) {
|
||||||
throw new \Exception('Get last Log name fail');
|
throw new \Exception('Get last Log name fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
|
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
|
||||||
if ($log_content === false) {
|
if ($logContent === false) {
|
||||||
throw new \Exception('Get last Log content fail');
|
throw new \Exception('Get last Log content fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = explode("\n", $log_content);
|
$lines = explode("\n", $logContent);
|
||||||
$lines = array_map('trim', $lines);
|
$lines = array_map('trim', $lines);
|
||||||
$lines = array_filter($lines);
|
$lines = array_filter($lines);
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,15 @@ use \PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integrates PHPCensor with Mage v3: https://github.com/andres-montanez/Magallanes
|
* Integrates PHPCensor with Mage v3: https://github.com/andres-montanez/Magallanes
|
||||||
|
*
|
||||||
* @package PHPCensor
|
* @package PHPCensor
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Mage3 extends Plugin
|
class Mage3 extends Plugin
|
||||||
{
|
{
|
||||||
protected $mage_bin = 'mage';
|
protected $mageBin = 'mage';
|
||||||
protected $mage_env;
|
protected $mageEnv;
|
||||||
protected $mage_log_dir;
|
protected $mageLogDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -38,15 +39,15 @@ class Mage3 extends Plugin
|
||||||
|
|
||||||
$config = $builder->getSystemConfig('mage3');
|
$config = $builder->getSystemConfig('mage3');
|
||||||
if (!empty($config['bin'])) {
|
if (!empty($config['bin'])) {
|
||||||
$this->mage_bin = $config['bin'];
|
$this->mageBin = $config['bin'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['env'])) {
|
if (isset($options['env'])) {
|
||||||
$this->mage_env = $builder->interpolate($options['env']);
|
$this->mageEnv = $builder->interpolate($options['env']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['log_dir'])) {
|
if (isset($options['log_dir'])) {
|
||||||
$this->mage_log_dir = $builder->interpolate($options['log_dir']);
|
$this->mageLogDir = $builder->interpolate($options['log_dir']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +56,12 @@ class Mage3 extends Plugin
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
if (empty($this->mage_env)) {
|
if (empty($this->mageEnv)) {
|
||||||
$this->builder->logFailure('You must specify environment.');
|
$this->builder->logFailure('You must specify environment.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->builder->executeCommand($this->mage_bin . ' -n deploy ' . $this->mage_env);
|
$result = $this->builder->executeCommand($this->mageBin . ' -n deploy ' . $this->mageEnv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
||||||
|
@ -80,12 +81,12 @@ class Mage3 extends Plugin
|
||||||
*/
|
*/
|
||||||
protected function getMageLog()
|
protected function getMageLog()
|
||||||
{
|
{
|
||||||
$logs_dir = $this->build->getBuildPath() . (!empty($this->mage_log_dir) ? '/' . $this->mage_log_dir : '');
|
$logsDir = $this->build->getBuildPath() . (!empty($this->mageLogDir) ? '/' . $this->mageLogDir : '');
|
||||||
if (!is_dir($logs_dir)) {
|
if (!is_dir($logsDir)) {
|
||||||
throw new \Exception('Log directory not found');
|
throw new \Exception('Log directory not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = scandir($logs_dir);
|
$list = scandir($logsDir);
|
||||||
if ($list === false) {
|
if ($list === false) {
|
||||||
throw new \Exception('Log dir read fail');
|
throw new \Exception('Log dir read fail');
|
||||||
}
|
}
|
||||||
|
@ -102,17 +103,17 @@ class Mage3 extends Plugin
|
||||||
throw new \Exception('Logs sort fail');
|
throw new \Exception('Logs sort fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_log_file = end($list);
|
$lastLogFile = end($list);
|
||||||
if ($last_log_file === false) {
|
if ($lastLogFile === false) {
|
||||||
throw new \Exception('Get last Log name fail');
|
throw new \Exception('Get last Log name fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
|
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
|
||||||
if ($log_content === false) {
|
if ($logContent === false) {
|
||||||
throw new \Exception('Get last Log content fail');
|
throw new \Exception('Get last Log content fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = explode("\n", $log_content);
|
$lines = explode("\n", $logContent);
|
||||||
$lines = array_map('trim', $lines);
|
$lines = array_map('trim', $lines);
|
||||||
$lines = array_filter($lines);
|
$lines = array_filter($lines);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use b8\Database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL Plugin - Provides access to a MySQL database.
|
* MySQL Plugin - Provides access to a MySQL database.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
* @author Steve Kamerman <stevekamerman@gmail.com>
|
* @author Steve Kamerman <stevekamerman@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
@ -110,15 +110,15 @@ class Mysql extends Plugin
|
||||||
throw new \Exception('Import statement must contain a \'file\' key');
|
throw new \Exception('Import statement must contain a \'file\' key');
|
||||||
}
|
}
|
||||||
|
|
||||||
$import_file = $this->builder->buildPath . $this->builder->interpolate($query['file']);
|
$importFile = $this->builder->buildPath . $this->builder->interpolate($query['file']);
|
||||||
if (!is_readable($import_file)) {
|
if (!is_readable($importFile)) {
|
||||||
throw new \Exception(sprintf('Cannot open SQL import file: %s', $import_file));
|
throw new \Exception(sprintf('Cannot open SQL import file: %s', $importFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
$database = isset($query['database']) ? $this->builder->interpolate($query['database']) : null;
|
$database = isset($query['database']) ? $this->builder->interpolate($query['database']) : null;
|
||||||
|
|
||||||
$import_command = $this->getImportCommand($import_file, $database);
|
$importCommand = $this->getImportCommand($importFile, $database);
|
||||||
if (!$this->builder->executeCommand($import_command)) {
|
if (!$this->builder->executeCommand($importCommand)) {
|
||||||
throw new \Exception('Unable to execute SQL file');
|
throw new \Exception('Unable to execute SQL file');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,15 +140,15 @@ class Mysql extends Plugin
|
||||||
'gz' => '| gzip --decompress',
|
'gz' => '| gzip --decompress',
|
||||||
];
|
];
|
||||||
|
|
||||||
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
|
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
|
||||||
$decomp_cmd = '';
|
$decompressionCmd = '';
|
||||||
if (array_key_exists($extension, $decompression)) {
|
if (array_key_exists($extension, $decompression)) {
|
||||||
$decomp_cmd = $decompression[$extension];
|
$decompressionCmd = $decompression[$extension];
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = [
|
$args = [
|
||||||
':import_file' => escapeshellarg($import_file),
|
':import_file' => escapeshellarg($import_file),
|
||||||
':decomp_cmd' => $decomp_cmd,
|
':decomp_cmd' => $decompressionCmd,
|
||||||
':host' => escapeshellarg($this->host),
|
':host' => escapeshellarg($this->host),
|
||||||
':user' => escapeshellarg($this->user),
|
':user' => escapeshellarg($this->user),
|
||||||
':pass' => (!$this->pass) ? '' : '-p' . escapeshellarg($this->pass),
|
':pass' => (!$this->pass) ? '' : '-p' . escapeshellarg($this->pass),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a ZIP or TAR.GZ archive of the entire build.
|
* Create a ZIP or TAR.GZ archive of the entire build.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class PackageBuild extends Plugin
|
class PackageBuild extends Plugin
|
||||||
|
@ -24,7 +24,7 @@ class PackageBuild extends Plugin
|
||||||
{
|
{
|
||||||
return 'package_build';
|
return 'package_build';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -58,7 +58,7 @@ class PackageBuild extends Plugin
|
||||||
$filename = str_replace('%time%', date('Hi'), $filename);
|
$filename = str_replace('%time%', date('Hi'), $filename);
|
||||||
$filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
|
$filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
|
||||||
|
|
||||||
$curdir = getcwd();
|
$currentDir = getcwd();
|
||||||
chdir($this->builder->buildPath);
|
chdir($this->builder->buildPath);
|
||||||
|
|
||||||
if (!is_array($this->format)) {
|
if (!is_array($this->format)) {
|
||||||
|
@ -79,7 +79,7 @@ class PackageBuild extends Plugin
|
||||||
$success = $this->builder->executeCommand($cmd, $this->directory, $filename);
|
$success = $this->builder->executeCommand($cmd, $this->directory, $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir($curdir);
|
chdir($currentDir);
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Phing extends Plugin
|
||||||
{
|
{
|
||||||
return 'phing';
|
return 'phing';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -106,7 +106,7 @@ class Phing extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTargets()
|
public function getTargets()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
@ -34,7 +34,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $tab_width;
|
protected $tabWidth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -44,12 +44,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $allowed_errors;
|
protected $allowedErrors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $allowed_warnings;
|
protected $allowedWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string, based on the assumption the root may not hold the code to be tested, extends the base path
|
* @var string, based on the assumption the root may not hold the code to be tested, extends the base path
|
||||||
|
@ -68,12 +68,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var null|int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
protected $error_severity = null;
|
protected $errorSeverity = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var null|int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
protected $warning_severity = null;
|
protected $warningSeverity = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -93,24 +93,24 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->suffixes = ['php'];
|
$this->suffixes = ['php'];
|
||||||
$this->directory = $this->builder->buildPath;
|
$this->directory = $this->builder->buildPath;
|
||||||
$this->standard = 'PSR2';
|
$this->standard = 'PSR2';
|
||||||
$this->tab_width = '';
|
$this->tabWidth = '';
|
||||||
$this->encoding = '';
|
$this->encoding = '';
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->ignore = $this->builder->ignore;
|
$this->ignore = $this->builder->ignore;
|
||||||
$this->allowed_warnings = 0;
|
$this->allowedWarnings = 0;
|
||||||
$this->allowed_errors = 0;
|
$this->allowedErrors = 0;
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
$this->allowed_warnings = -1;
|
$this->allowedWarnings = -1;
|
||||||
$this->allowed_errors = -1;
|
$this->allowedErrors = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['allowed_errors']) && is_int($options['allowed_errors'])) {
|
if (!empty($options['allowed_errors']) && is_int($options['allowed_errors'])) {
|
||||||
$this->allowed_errors = $options['allowed_errors'];
|
$this->allowedErrors = $options['allowed_errors'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['allowed_warnings']) && is_int($options['allowed_warnings'])) {
|
if (!empty($options['allowed_warnings']) && is_int($options['allowed_warnings'])) {
|
||||||
$this->allowed_warnings = $options['allowed_warnings'];
|
$this->allowedWarnings = $options['allowed_warnings'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['suffixes'])) {
|
if (isset($options['suffixes'])) {
|
||||||
|
@ -118,7 +118,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['tab_width'])) {
|
if (!empty($options['tab_width'])) {
|
||||||
$this->tab_width = ' --tab-width='.$options['tab_width'];
|
$this->tabWidth = ' --tab-width='.$options['tab_width'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['encoding'])) {
|
if (!empty($options['encoding'])) {
|
||||||
|
@ -138,11 +138,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['error_severity']) && is_int($options['error_severity'])) {
|
if (isset($options['error_severity']) && is_int($options['error_severity'])) {
|
||||||
$this->error_severity = $options['error_severity'];
|
$this->errorSeverity = $options['error_severity'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['warning_severity']) && is_int($options['warning_severity'])) {
|
if (isset($options['warning_severity']) && is_int($options['warning_severity'])) {
|
||||||
$this->warning_severity = $options['warning_severity'];
|
$this->warningSeverity = $options['warning_severity'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
$standard,
|
$standard,
|
||||||
$suffixes,
|
$suffixes,
|
||||||
$ignore,
|
$ignore,
|
||||||
$this->tab_width,
|
$this->tabWidth,
|
||||||
$this->encoding,
|
$this->encoding,
|
||||||
$this->builder->buildPath . $this->path,
|
$this->builder->buildPath . $this->path,
|
||||||
$severity,
|
$severity,
|
||||||
|
@ -198,11 +198,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->build->storeMeta('phpcs-warnings', $warnings);
|
$this->build->storeMeta('phpcs-warnings', $warnings);
|
||||||
$this->build->storeMeta('phpcs-errors', $errors);
|
$this->build->storeMeta('phpcs-errors', $errors);
|
||||||
|
|
||||||
if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
|
if ($this->allowedWarnings != -1 && $warnings > $this->allowedWarnings) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
|
if ($this->allowedErrors != -1 && $errors > $this->allowedErrors) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,13 +237,13 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$errorSeverity = '';
|
$errorSeverity = '';
|
||||||
if ($this->error_severity !== null) {
|
if ($this->errorSeverity !== null) {
|
||||||
$errorSeverity = ' --error-severity=' . $this->error_severity;
|
$errorSeverity = ' --error-severity=' . $this->errorSeverity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$warningSeverity = '';
|
$warningSeverity = '';
|
||||||
if ($this->warning_severity !== null) {
|
if ($this->warningSeverity !== null) {
|
||||||
$warningSeverity = ' --warning-severity=' . $this->warning_severity;
|
$warningSeverity = ' --warning-severity=' . $this->warningSeverity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$ignore, $standard, $suffixes, $severity, $errorSeverity, $warningSeverity];
|
return [$ignore, $standard, $suffixes, $severity, $errorSeverity, $warningSeverity];
|
||||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
@ -33,7 +33,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
protected $allowed_warnings;
|
protected $allowedWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -42,7 +42,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
{
|
{
|
||||||
return 'php_docblock_checker';
|
return 'php_docblock_checker';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -52,10 +52,10 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
|
||||||
$this->ignore = $this->builder->ignore;
|
$this->ignore = $this->builder->ignore;
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->allowed_warnings = 0;
|
$this->allowedWarnings = 0;
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
$this->allowed_warnings = -1;
|
$this->allowedWarnings = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('skip_classes', $options)) {
|
if (array_key_exists('skip_classes', $options)) {
|
||||||
|
@ -71,7 +71,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('allowed_warnings', $options)) {
|
if (array_key_exists('allowed_warnings', $options)) {
|
||||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->build->storeMeta('phpdoccheck-warnings', $errors);
|
$this->build->storeMeta('phpdoccheck-warnings', $errors);
|
||||||
$this->reportErrors($output);
|
$this->reportErrors($output);
|
||||||
|
|
||||||
if ($this->allowed_warnings != -1 && $errors > $this->allowed_warnings) {
|
if ($this->allowedWarnings != -1 && $errors > $this->allowedWarnings) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
@ -38,7 +38,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $rules;
|
protected $rules;
|
||||||
protected $allowed_warnings;
|
protected $allowedWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -59,10 +59,10 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->ignore = $this->builder->ignore;
|
$this->ignore = $this->builder->ignore;
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->rules = ['codesize', 'unusedcode', 'naming'];
|
$this->rules = ['codesize', 'unusedcode', 'naming'];
|
||||||
$this->allowed_warnings = 0;
|
$this->allowedWarnings = 0;
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
$this->allowed_warnings = -1;
|
$this->allowedWarnings = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['path'])) {
|
if (!empty($options['path'])) {
|
||||||
|
@ -70,7 +70,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('allowed_warnings', $options)) {
|
if (array_key_exists('allowed_warnings', $options)) {
|
||||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['rules', 'ignore', 'suffixes'] as $key) {
|
foreach (['rules', 'ignore', 'suffixes'] as $key) {
|
||||||
|
@ -247,7 +247,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||||
{
|
{
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
if ($this->allowed_warnings != -1 && $errorCount > $this->allowed_warnings) {
|
if ($this->allowedWarnings != -1 && $errorCount > $this->allowedWarnings) {
|
||||||
$success = false;
|
$success = false;
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Spec Plugin - Allows PHP Spec testing.
|
* PHP Spec Plugin - Allows PHP Spec testing.
|
||||||
*
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
class PhpSpec extends Plugin
|
class PhpSpec extends Plugin
|
||||||
|
@ -25,7 +25,7 @@ class PhpSpec extends Plugin
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$curdir = getcwd();
|
$currentDir = getcwd();
|
||||||
chdir($this->builder->buildPath);
|
chdir($this->builder->buildPath);
|
||||||
|
|
||||||
$phpspec = $this->findBinary(['phpspec', 'phpspec.php']);
|
$phpspec = $this->findBinary(['phpspec', 'phpspec.php']);
|
||||||
|
@ -33,7 +33,7 @@ class PhpSpec extends Plugin
|
||||||
$success = $this->builder->executeCommand($phpspec . ' --format=junit --no-code-generation run');
|
$success = $this->builder->executeCommand($phpspec . ' --format=junit --no-code-generation run');
|
||||||
$output = $this->builder->getLastOutput();
|
$output = $this->builder->getLastOutput();
|
||||||
|
|
||||||
chdir($curdir);
|
chdir($currentDir);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* process xml output
|
* process xml output
|
||||||
|
|
|
@ -93,9 +93,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = $this->findBinary('phpunit');
|
$cmd = $this->findBinary('phpunit');
|
||||||
// run without logging
|
|
||||||
$ret = null;
|
|
||||||
$lastLine = exec($cmd.' --log-json . --version');
|
$lastLine = exec($cmd.' --log-json . --version');
|
||||||
if (false !== strpos($lastLine, '--log-json')) {
|
if (false !== strpos($lastLine, '--log-json')) {
|
||||||
$logFormat = 'junit'; // --log-json is not supported
|
$logFormat = 'junit'; // --log-json is not supported
|
||||||
|
|
|
@ -12,7 +12,7 @@ use SensioLabs\Security\SecurityChecker as BaseSecurityChecker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SensioLabs Security Checker Plugin
|
* SensioLabs Security Checker Plugin
|
||||||
*
|
*
|
||||||
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
|
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
|
||||||
*/
|
*/
|
||||||
class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
@ -20,8 +20,8 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
protected $allowed_warnings;
|
protected $allowedWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -37,14 +37,14 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
{
|
{
|
||||||
parent::__construct($builder, $build, $options);
|
parent::__construct($builder, $build, $options);
|
||||||
|
|
||||||
$this->allowed_warnings = 0;
|
$this->allowedWarnings = 0;
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
$this->allowed_warnings = -1;
|
$this->allowedWarnings = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('allowed_warnings', $options)) {
|
if (array_key_exists('allowed_warnings', $options)) {
|
||||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
|
||||||
if ($warnings) {
|
if ($warnings) {
|
||||||
foreach ($warnings as $library => $warning) {
|
foreach ($warnings as $library => $warning) {
|
||||||
foreach ($warning['advisories'] as $advisory => $data) {
|
foreach ($warning['advisories'] as $data) {
|
||||||
$this->build->reportError(
|
$this->build->reportError(
|
||||||
$this->builder,
|
$this->builder,
|
||||||
'security_checker',
|
'security_checker',
|
||||||
|
@ -88,7 +88,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->allowed_warnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowed_warnings)) {
|
if ($this->allowedWarnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowedWarnings)) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Maknz\Slack\AttachmentField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slack Plugin
|
* Slack Plugin
|
||||||
*
|
*
|
||||||
* @author Stephen Ball <phpci@stephen.rebelinblue.com>
|
* @author Stephen Ball <phpci@stephen.rebelinblue.com>
|
||||||
*/
|
*/
|
||||||
class SlackNotify extends Plugin
|
class SlackNotify extends Plugin
|
||||||
|
@ -21,7 +21,7 @@ class SlackNotify extends Plugin
|
||||||
private $username;
|
private $username;
|
||||||
private $message;
|
private $message;
|
||||||
private $icon;
|
private $icon;
|
||||||
private $show_status;
|
private $showStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -62,9 +62,9 @@ class SlackNotify extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['show_status'])) {
|
if (isset($options['show_status'])) {
|
||||||
$this->show_status = (bool) $options['show_status'];
|
$this->showStatus = (bool) $options['show_status'];
|
||||||
} else {
|
} else {
|
||||||
$this->show_status = true;
|
$this->showStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['icon'])) {
|
if (isset($options['icon'])) {
|
||||||
|
@ -100,7 +100,7 @@ class SlackNotify extends Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include an attachment which shows the status and hide the message
|
// Include an attachment which shows the status and hide the message
|
||||||
if ($this->show_status) {
|
if ($this->showStatus) {
|
||||||
$successfulBuild = $this->build->isSuccessful();
|
$successfulBuild = $this->build->isSuccessful();
|
||||||
|
|
||||||
if ($successfulBuild) {
|
if ($successfulBuild) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $allowed_errors;
|
protected $allowedErrors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array - paths to ignore
|
* @var array - paths to ignore
|
||||||
|
@ -123,7 +123,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
||||||
$this->suffixes = ['php'];
|
$this->suffixes = ['php'];
|
||||||
$this->directory = $this->builder->buildPath;
|
$this->directory = $this->builder->buildPath;
|
||||||
$this->ignore = $this->builder->ignore;
|
$this->ignore = $this->builder->ignore;
|
||||||
$this->allowed_errors = 0;
|
$this->allowedErrors = 0;
|
||||||
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
|
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
|
||||||
|
|
||||||
if (!empty($options['suffixes']) && is_array($options['suffixes'])) {
|
if (!empty($options['suffixes']) && is_array($options['suffixes'])) {
|
||||||
|
@ -135,7 +135,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
$this->allowed_errors = -1;
|
$this->allowedErrors = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
|
@ -185,7 +185,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
||||||
|
|
||||||
$this->build->storeMeta('technical_debt-warnings', $errorCount);
|
$this->build->storeMeta('technical_debt-warnings', $errorCount);
|
||||||
|
|
||||||
if ($this->allowed_errors !== -1 && $errorCount > $this->allowed_errors) {
|
if ($this->allowedErrors !== -1 && $errorCount > $this->allowedErrors) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XMPP Notification - Send notification for successful or failure build
|
* XMPP Notification - Send notification for successful or failure build
|
||||||
*
|
*
|
||||||
* @author Alexandre Russo <dev.github@ange7.com>
|
* @author Alexandre Russo <dev.github@ange7.com>
|
||||||
*/
|
*/
|
||||||
class XMPP extends Plugin
|
class XMPP extends Plugin
|
||||||
|
@ -48,7 +48,7 @@ class XMPP extends Plugin
|
||||||
/**
|
/**
|
||||||
* @var string, mask to format date
|
* @var string, mask to format date
|
||||||
*/
|
*/
|
||||||
protected $date_format;
|
protected $dateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -57,7 +57,7 @@ class XMPP extends Plugin
|
||||||
{
|
{
|
||||||
return 'xmpp';
|
return 'xmpp';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +71,7 @@ class XMPP extends Plugin
|
||||||
$this->alias = '';
|
$this->alias = '';
|
||||||
$this->recipients = [];
|
$this->recipients = [];
|
||||||
$this->tls = false;
|
$this->tls = false;
|
||||||
$this->date_format = '%c';
|
$this->dateFormat = '%c';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set recipients list
|
* Set recipients list
|
||||||
|
@ -189,7 +189,7 @@ class XMPP extends Plugin
|
||||||
$message = "✘ [".$this->build->getProjectTitle()."] Build #" . $this->build->getId()." failure";
|
$message = "✘ [".$this->build->getProjectTitle()."] Build #" . $this->build->getId()." failure";
|
||||||
}
|
}
|
||||||
|
|
||||||
$message .= ' ('.strftime($this->date_format).')';
|
$message .= ' ('.strftime($this->dateFormat).')';
|
||||||
|
|
||||||
return file_put_contents($message_file, $message);
|
return file_put_contents($message_file, $message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue