add web-puc plugin
This commit is contained in:
parent
42ca1c6527
commit
6abb68e19b
|
@ -440,5 +440,5 @@ PHPCI',
|
||||||
'php_docblock_checker' => 'PHP Docblock Checker',
|
'php_docblock_checker' => 'PHP Docblock Checker',
|
||||||
'behat' => 'Behat',
|
'behat' => 'Behat',
|
||||||
'technical_debt' => 'Technical Debt',
|
'technical_debt' => 'Technical Debt',
|
||||||
|
'web_puc' => 'Web-Puc',
|
||||||
);
|
);
|
||||||
|
|
131
PHPCI/Plugin/WebPuc.php
Normal file
131
PHPCI/Plugin/WebPuc.php
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPCI - Continuous Integration for PHP
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2014, Block 8 Limited.
|
||||||
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
||||||
|
* @link https://www.phptesting.org/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PHPCI\Plugin;
|
||||||
|
|
||||||
|
use PHPCI;
|
||||||
|
use PHPCI\Builder;
|
||||||
|
use PHPCI\Model\Build;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
||||||
|
* @author Ilia Grabko <ilya4041@yandex.ru>
|
||||||
|
* @package PHPCI
|
||||||
|
* @subpackage Plugins
|
||||||
|
*/
|
||||||
|
class WebPuc implements PHPCI\Plugin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \PHPCI\Builder
|
||||||
|
*/
|
||||||
|
protected $phpci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PHPCI\Model\Build
|
||||||
|
*/
|
||||||
|
protected $build;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $exclude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $allowSupported;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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->directory = $phpci->buildPath;
|
||||||
|
|
||||||
|
$this->exclude = "";
|
||||||
|
$this->allowSupported = "";
|
||||||
|
$this->update = "";
|
||||||
|
|
||||||
|
if (isset($options['exclude'])) {
|
||||||
|
$this->exclude = $options['exclude'];
|
||||||
|
}
|
||||||
|
if (isset($options['allow-supported'])) {
|
||||||
|
$this->allowSupported = $options['allow-supported'];
|
||||||
|
}
|
||||||
|
if (isset($options['update'])) {
|
||||||
|
$this->update = $options['update'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs Web-Puc.
|
||||||
|
*/
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
$path = $this->phpci->buildPath;
|
||||||
|
$webpuc = $this->phpci->findBinary('web-puc');
|
||||||
|
$cmd = $webpuc . ' %s %s %s %s';
|
||||||
|
|
||||||
|
$exclude = '';
|
||||||
|
if (!empty($this->exclude)) {
|
||||||
|
$exclude = ' -e "' . $this->exclude . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->phpci->executeCommand(
|
||||||
|
$cmd,
|
||||||
|
$exclude,
|
||||||
|
$this->allowSupported,
|
||||||
|
$this->update,
|
||||||
|
$path
|
||||||
|
);
|
||||||
|
$output = $this->phpci->getLastOutput();
|
||||||
|
|
||||||
|
$failed_findings = 0;
|
||||||
|
$stat = json_decode($output);
|
||||||
|
if ($stat === null) {
|
||||||
|
$this->phpci->log($output);
|
||||||
|
throw new \Exception('Could not parse web-puc output.');
|
||||||
|
}
|
||||||
|
if(isset($stat->findings))
|
||||||
|
foreach ($stat->findings as $finding)
|
||||||
|
if($finding->failure){
|
||||||
|
$failed_findings++;
|
||||||
|
|
||||||
|
$this->build->reportError(
|
||||||
|
$this->phpci,
|
||||||
|
'web_puc',
|
||||||
|
$finding->description,
|
||||||
|
PHPCI\Model\BuildError::SEVERITY_HIGH,
|
||||||
|
$finding->location->path,
|
||||||
|
$finding->location->beginLine,
|
||||||
|
$finding->location->endLine
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->phpci->logExecOutput(true);
|
||||||
|
|
||||||
|
return $failed_findings == 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,7 @@
|
||||||
"maknz/slack": "~1.7",
|
"maknz/slack": "~1.7",
|
||||||
"hipchat/hipchat-php": "~1.4",
|
"hipchat/hipchat-php": "~1.4",
|
||||||
"mremi/flowdock": "~1.0"
|
"mremi/flowdock": "~1.0"
|
||||||
|
"fulldecent/web-puc": "0.1"
|
||||||
},
|
},
|
||||||
|
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
Loading…
Reference in a new issue