Compare commits
4 commits
master
...
dc/can-exe
Author | SHA1 | Date | |
---|---|---|---|
e437e9b855 | |||
29a6c9767a | |||
6a1b23bbb4 | |||
9dcb29af5d |
|
@ -168,7 +168,7 @@ class Build extends BuildBase
|
|||
}
|
||||
|
||||
foreach (array('setup', 'test', 'complete', 'success', 'failure') as $stage) {
|
||||
if ($className::canExecute($stage, $builder, $this)) {
|
||||
if ($className::canRunZeroConfig($stage, $builder, $this)) {
|
||||
$config[$stage][$className] = array(
|
||||
'zero_config' => true
|
||||
);
|
||||
|
|
|
@ -9,11 +9,16 @@
|
|||
|
||||
namespace PHPCI;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
* PHPCI Plugin Interface - Used by all build plugins.
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
interface Plugin
|
||||
{
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
|
||||
public function isAllowedInStage($stage);
|
||||
public function execute();
|
||||
}
|
||||
|
|
50
PHPCI/Plugin/AbstractPlugin.php
Normal file
50
PHPCI/Plugin/AbstractPlugin.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace PHPCI\Plugin;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Plugin;
|
||||
|
||||
/**
|
||||
* Base for all of the standard PHPCI plugins. Provides the isAllowedInStage() functionality.
|
||||
* @package PHPCI\Plugin
|
||||
*/
|
||||
abstract class AbstractPlugin implements Plugin
|
||||
{
|
||||
/**
|
||||
* Define the stages that this plugin is allowed to run in.
|
||||
* @see AbstractPlugin::isAllowedInStage()
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedStages = array('setup', 'test', 'complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
/**
|
||||
* Verify whether or not this plugin is allowed to execute in a given stage.
|
||||
* @param string $stage
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowedInStage($stage)
|
||||
{
|
||||
return in_array($stage, $this->allowedStages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not this plugin can execute in zero config mode.
|
||||
* Many plugins will check if their required config files can be found here.
|
||||
* @param string $stage
|
||||
* @param Builder $builder
|
||||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the plugin and return its success or failure.
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function execute();
|
||||
}
|
|
@ -17,8 +17,13 @@ use PHPCI\Model\Build;
|
|||
* Atoum plugin, runs Atoum tests within a project.
|
||||
* @package PHPCI\Plugin
|
||||
*/
|
||||
class Atoum implements \PHPCI\Plugin
|
||||
class Atoum extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
private $args;
|
||||
private $config;
|
||||
private $directory;
|
||||
|
|
|
@ -20,8 +20,13 @@ use PHPCI\Model\BuildError;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Behat implements \PHPCI\Plugin
|
||||
class Behat extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
protected $features;
|
||||
|
|
|
@ -20,8 +20,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Campfire implements \PHPCI\Plugin
|
||||
class Campfire extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
private $url;
|
||||
private $authToken;
|
||||
private $userAgent;
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class CleanBuild implements \PHPCI\Plugin
|
||||
class CleanBuild extends AbstractPlugin
|
||||
{
|
||||
protected $remove;
|
||||
protected $phpci;
|
||||
|
|
|
@ -14,6 +14,7 @@ use PHPCI\Helper\Lang;
|
|||
use PHPCI\Model\Build;
|
||||
use PHPCI\Plugin\Util\TestResultParsers\Codeception as Parser;
|
||||
use Psr\Log\LogLevel;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* Codeception Plugin - Enables full acceptance, unit, and functional testing.
|
||||
|
@ -23,8 +24,13 @@ use Psr\Log\LogLevel;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin
|
||||
class Codeception extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/** @var string */
|
||||
protected $args = '';
|
||||
|
||||
|
@ -50,7 +56,7 @@ class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
return $stage == 'test' && !is_null(self::findConfigFile($builder->buildPath));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use PHPCI;
|
|||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* Composer Plugin - Provides access to Composer functionality.
|
||||
|
@ -20,7 +21,7 @@ use PHPCI\Helper\Lang;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class Composer extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $action;
|
||||
|
@ -36,7 +37,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Helper\Lang;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class CopyBuild implements \PHPCI\Plugin
|
||||
class CopyBuild extends AbstractPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $ignore;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Deployer implements \PHPCI\Plugin
|
||||
class Deployer extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
protected $webhookUrl;
|
||||
protected $reason;
|
||||
|
||||
|
|
|
@ -23,8 +23,13 @@ use Psr\Log\LogLevel;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Email implements \PHPCI\Plugin
|
||||
class Email extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Env implements \PHPCI\Plugin
|
||||
class Env extends AbstractPlugin
|
||||
{
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
|
|
|
@ -19,8 +19,13 @@ use Mremi\Flowdock\Api\Push\TeamInboxMessage;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class FlowdockNotify implements \PHPCI\Plugin
|
||||
class FlowdockNotify extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
private $api_key;
|
||||
private $email;
|
||||
const MESSAGE_DEFAULT = 'Build %BUILD% has finished for commit <a href="%COMMIT_URI%">%SHORT_COMMIT%</a>
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Git implements \PHPCI\Plugin
|
||||
class Git extends AbstractPlugin
|
||||
{
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Grunt implements \PHPCI\Plugin
|
||||
class Grunt extends AbstractPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $task;
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Gulp implements \PHPCI\Plugin
|
||||
class Gulp extends AbstractPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $task;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class HipchatNotify implements \PHPCI\Plugin
|
||||
class HipchatNotify extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
protected $authToken;
|
||||
protected $color;
|
||||
protected $notify;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Irc implements \PHPCI\Plugin
|
||||
class Irc extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
protected $message;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Lint implements PHPCI\Plugin
|
||||
class Lint extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $directories;
|
||||
protected $recursive = true;
|
||||
protected $ignore;
|
||||
|
|
|
@ -21,7 +21,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Mysql implements \PHPCI\Plugin
|
||||
class Mysql extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PackageBuild implements \PHPCI\Plugin
|
||||
class PackageBuild extends AbstractPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $filename;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Pdepend implements \PHPCI\Plugin
|
||||
class Pdepend extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $args;
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Pgsql implements \PHPCI\Plugin
|
||||
class Pgsql extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -10,7 +10,7 @@ use Phar as PHPPhar;
|
|||
/**
|
||||
* Phar Plugin
|
||||
*/
|
||||
class Phar implements \PHPCI\Plugin
|
||||
class Phar extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* PHPCI
|
||||
|
|
|
@ -20,7 +20,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Phing implements \PHPCI\Plugin
|
||||
class Phing extends AbstractPlugin
|
||||
{
|
||||
|
||||
private $directory;
|
||||
|
|
|
@ -13,6 +13,7 @@ use PHPCI;
|
|||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Model\BuildError;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
||||
|
@ -20,8 +21,13 @@ use PHPCI\Model\BuildError;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class PhpCodeSniffer extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
@ -80,7 +86,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
|
|
|
@ -20,8 +20,13 @@ use PHPCI\Model\BuildError;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpCpd implements \PHPCI\Plugin
|
||||
class PhpCpd extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $directory;
|
||||
protected $args;
|
||||
protected $phpci;
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpCsFixer implements \PHPCI\Plugin
|
||||
class PhpCsFixer extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Plugin;
|
|||
use PHPCI;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
||||
|
@ -19,8 +20,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class PhpDocblockChecker extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
@ -52,7 +58,7 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Plugin;
|
|||
use PHPCI;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* PHP Loc - Allows PHP Copy / Lines of Code testing.
|
||||
|
@ -19,7 +20,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class PhpLoc extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -37,7 +38,7 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Plugin;
|
|||
use PHPCI;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
||||
|
@ -19,8 +20,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class PhpMessDetector extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
@ -62,7 +68,7 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpParallelLint implements \PHPCI\Plugin
|
||||
class PhpParallelLint extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpSpec implements PHPCI\Plugin
|
||||
class PhpSpec extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
|
|
@ -19,8 +19,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpTalLint implements PHPCI\Plugin
|
||||
class PhpTalLint extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $directories;
|
||||
protected $recursive = true;
|
||||
protected $suffixes;
|
||||
|
|
|
@ -13,6 +13,7 @@ use PHPCI;
|
|||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Plugin\Util\TapParser;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* PHP Unit Plugin - Allows PHP Unit testing.
|
||||
|
@ -20,8 +21,13 @@ use PHPCI\Plugin\Util\TapParser;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class PhpUnit extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
protected $args;
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
|
@ -56,7 +62,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test' && !is_null(self::findConfigFile($builder->buildPath))) {
|
||||
return true;
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Shell implements \PHPCI\Plugin
|
||||
class Shell extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -17,8 +17,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class SlackNotify implements \PHPCI\Plugin
|
||||
class SlackNotify extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('complete', 'success', 'failure', 'fixed', 'broken');
|
||||
|
||||
private $webHook;
|
||||
private $room;
|
||||
private $username;
|
||||
|
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Sqlite implements \PHPCI\Plugin
|
||||
class Sqlite extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCI\Plugin;
|
|||
use PHPCI;
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\ZeroConfigPlugin;
|
||||
|
||||
/**
|
||||
* Technical Debt Plugin - Checks for existence of "TODO", "FIXME", etc.
|
||||
|
@ -20,8 +21,13 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
class TechnicalDebt extends AbstractPlugin implements ZeroConfigPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected $allowedStages = array('test');
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
|
@ -67,7 +73,7 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
|||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
|
|
|
@ -138,7 +138,7 @@ class Executor
|
|||
$this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING);
|
||||
|
||||
// Try and execute it
|
||||
if ($this->executePlugin($plugin, $options)) {
|
||||
if ($this->executePlugin($plugin, $options, $stage)) {
|
||||
// Execution was successful
|
||||
$this->logger->logSuccess(Lang::get('plugin_success'));
|
||||
$this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS);
|
||||
|
@ -166,8 +166,12 @@ class Executor
|
|||
|
||||
/**
|
||||
* Executes a given plugin, with options and returns the result.
|
||||
* @param string $plugin Plugin name
|
||||
* @param array $options Plugin options (from phpci.yml)
|
||||
* @param string $stage Stage name
|
||||
* @return bool
|
||||
*/
|
||||
public function executePlugin($plugin, $options)
|
||||
public function executePlugin($plugin, $options, $stage)
|
||||
{
|
||||
// Any plugin name without a namespace separator is a PHPCI built in plugin
|
||||
// if not we assume it's a fully name-spaced class name that implements the plugin interface.
|
||||
|
@ -188,6 +192,12 @@ class Executor
|
|||
try {
|
||||
// Build and run it
|
||||
$obj = $this->pluginFactory->buildPlugin($class, $options);
|
||||
|
||||
if (!$obj->isAllowedInStage($stage)) {
|
||||
$this->logger->logFailure('Plugin "' . $plugin . '" cannot be run in stage: ' . $stage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $obj->execute();
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Wipe implements \PHPCI\Plugin
|
||||
class Wipe extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class XMPP implements \PHPCI\Plugin
|
||||
class XMPP extends AbstractPlugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $phpci;
|
||||
|
|
|
@ -17,5 +17,5 @@ use PHPCI\Model\Build;
|
|||
*/
|
||||
interface ZeroConfigPlugin
|
||||
{
|
||||
public static function canExecute($stage, Builder $builder, Build $build);
|
||||
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
->shouldBeCalledTimes(1)
|
||||
->willReturn($this->prophesize('PHPCI\Plugin')->reveal());
|
||||
|
||||
$this->testedExecutor->executePlugin($pluginName, $options);
|
||||
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
|
||||
}
|
||||
|
||||
public function testExecutePlugin_KeepsCalledNameSpace()
|
||||
|
@ -61,7 +61,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
->shouldBeCalledTimes(1)
|
||||
->willReturn($this->prophesize('PHPCI\Plugin')->reveal());
|
||||
|
||||
$this->testedExecutor->executePlugin($pluginClass, $options);
|
||||
$this->testedExecutor->executePlugin($pluginClass, $options, 'test');
|
||||
}
|
||||
|
||||
public function testExecutePlugin_CallsExecuteOnFactoryBuildPlugin()
|
||||
|
@ -76,7 +76,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
$this->mockFactory->buildPlugin(Argument::any(), Argument::any())->willReturn($mockPlugin->reveal());
|
||||
$this->mockFactory->getResourceFor('PHPCI\Model\Build')->willReturn($build);
|
||||
|
||||
$this->testedExecutor->executePlugin($pluginName, $options);
|
||||
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
|
||||
}
|
||||
|
||||
public function testExecutePlugin_ReturnsPluginSuccess()
|
||||
|
@ -91,7 +91,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->mockFactory->buildPlugin(Argument::any(), Argument::any())->willReturn($mockPlugin->reveal());
|
||||
|
||||
$returnValue = $this->testedExecutor->executePlugin($pluginName, $options);
|
||||
$returnValue = $this->testedExecutor->executePlugin($pluginName, $options, 'test');
|
||||
|
||||
$this->assertEquals($expectedReturnValue, $returnValue);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->mockBuildLogger->logFailure('Plugin does not exist: ' . $pluginName)->shouldBeCalledTimes(1);
|
||||
|
||||
$this->testedExecutor->executePlugin($pluginName, $options);
|
||||
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
|
||||
}
|
||||
|
||||
public function testExecutePlugin_LogsFailureWhenExceptionsAreThrownByPlugin()
|
||||
|
@ -121,7 +121,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||
$this->mockBuildLogger->logFailure('Exception: ' . $expectedException->getMessage(), $expectedException)
|
||||
->shouldBeCalledTimes(1);
|
||||
|
||||
$this->testedExecutor->executePlugin($pluginName, $options);
|
||||
$this->testedExecutor->executePlugin($pluginName, $options, 'test');
|
||||
}
|
||||
|
||||
public function testExecutePlugins_CallsEachPluginForStage()
|
||||
|
|
|
@ -14,7 +14,7 @@ use PHPCI\Builder;
|
|||
use PHPCI\Model\Build;
|
||||
use PHPCI\Plugin;
|
||||
|
||||
class ExamplePluginFull implements Plugin {
|
||||
class ExamplePluginFull extends Plugin\AbstractPlugin {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
|
|||
|
||||
use PHPCI\Plugin;
|
||||
|
||||
class ExamplePluginWithNoConstructorArgs implements Plugin
|
||||
class ExamplePluginWithNoConstructorArgs extends Plugin\AbstractPlugin
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
|
|||
|
||||
use PHPCI\Plugin;
|
||||
|
||||
class ExamplePluginWithSingleOptionalArg implements Plugin
|
||||
class ExamplePluginWithSingleOptionalArg extends Plugin\AbstractPlugin
|
||||
{
|
||||
function __construct($optional = null)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
|
|||
|
||||
use PHPCI\Plugin;
|
||||
|
||||
class ExamplePluginWithSingleRequiredArg implements Plugin
|
||||
class ExamplePluginWithSingleRequiredArg extends Plugin\AbstractPlugin
|
||||
{
|
||||
|
||||
public $RequiredArgument;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Tests\PHPCI\Plugin\Util\Fake;
|
|||
|
||||
use PHPCI\Plugin;
|
||||
|
||||
class ExamplePluginWithSingleTypedRequiredArg implements Plugin
|
||||
class ExamplePluginWithSingleTypedRequiredArg extends Plugin\AbstractPlugin
|
||||
{
|
||||
|
||||
public $RequiredArgument;
|
||||
|
|
Loading…
Reference in a new issue