Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from Cheppers/internal-lint-report
Browse files Browse the repository at this point in the history
Inhouse lint reporter
  • Loading branch information
Sweetchuck authored Oct 2, 2016
2 parents 9791f45 + cc5000f commit ee44b81
Show file tree
Hide file tree
Showing 27 changed files with 2,086 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/vendor/

/tests/_data/node_modules/
/tests/_data/reports/
/tests/_data/actual/
/tests/_output/
/tests/_support/_generated/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ php:
- '7.0'

env:
- COMPOSER_NO_INTERACTION=1 COMPOSER_DISABLE_XDEBUG_WARN=1
- 'COMPOSER_NO_INTERACTION=1 COMPOSER_DISABLE_XDEBUG_WARN=1'

cache:
directories:
Expand Down
74 changes: 63 additions & 11 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// @codingStandardsIgnoreStart
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;

/**
* Class RoboFile.
Expand All @@ -16,6 +17,11 @@ class RoboFile extends \Robo\Tasks
*/
protected $composerInfo = [];

/**
* @var array
*/
protected $codeceptionInfo = [];

/**
* @var string
*/
Expand Down Expand Up @@ -71,7 +77,12 @@ public function githookPreCommit()
*/
public function test()
{
return $this->getTaskCodecept();
/** @var \Robo\Collection\CollectionBuilder $cb */
$cb = $this->collectionBuilder();

return $cb->addTaskList([
'codecept' => $this->getTaskCodecept(),
]);
}

/**
Expand All @@ -83,11 +94,12 @@ public function lint()
{
/** @var \Robo\Collection\CollectionBuilder $cb */
$cb = $this->collectionBuilder();

return $cb->addTaskList([
$cb->addTaskList([
'lint.composer.lock' => $this->taskComposerValidate(),
'lint.phpcs.psr2' => $this->getTaskPhpcsLint(),
]);

return $cb;
}

/**
Expand All @@ -109,6 +121,28 @@ protected function initComposerInfo()
return $this;
}

/**
* @return $this
*/
protected function initCodeceptionInfo()
{
if ($this->codeceptionInfo) {
return $this;
}

if (is_readable('codeception.yml')) {
$this->codeceptionInfo = Yaml::parse(file_get_contents('codeception.yml'));
} else {
$this->codeceptionInfo = [
'paths' => [
'log' => 'tests/_output',
],
];
}

return $this;
}

/**
* @return \Cheppers\Robo\Phpcs\Task\TaskPhpcsLint
*/
Expand All @@ -119,7 +153,6 @@ protected function getTaskPhpcsLint()
'standard' => 'PSR2',
'reports' => [
'full' => null,
'checkstyle' => 'tests/_output/checkstyle/phpcs-psr2.xml',
],
'files' => [
'src/',
Expand All @@ -133,10 +166,12 @@ protected function getTaskPhpcsLint()
}

/**
* @return \Robo\Task\Base\Exec
* @return \Robo\Collection\CollectionBuilder
*/
protected function getTaskCodecept()
{
$this->initCodeceptionInfo();

$cmd_args = [];
if ($this->isPhpExtensionAvailable('xdebug')) {
$cmd_pattern = '%s';
Expand All @@ -147,13 +182,30 @@ protected function getTaskCodecept()
$cmd_args[] = escapeshellarg("{$this->binDir}/codecept");
}

$cmd_pattern .= ' --ansi --verbose --coverage --coverage-xml=%s --coverage-html=%s run';
$cmd_args[] = escapeshellarg('coverage.xml');
$cmd_args[] = escapeshellarg('html');
$cmd_pattern .= ' --ansi';
$cmd_pattern .= ' --verbose';

$cmd_pattern .= ' --coverage=%s';
$cmd_args[] = escapeshellarg('coverage/coverage.serialized');

$cmd_pattern .= ' --coverage-xml=%s';
$cmd_args[] = escapeshellarg('coverage/coverage.xml');

$cmd_pattern .= ' --coverage-html=%s';
$cmd_args[] = escapeshellarg('coverage/html');

$cmd_pattern .= ' run';

$reportsDir = $this->codeceptionInfo['paths']['log'];

/** @var \Robo\Collection\CollectionBuilder $cb */
$cb = $this->collectionBuilder();
$cb->addTaskList([
'prepareCoverageDir' => $this->taskFilesystemStack()->mkdir("$reportsDir/coverage"),
'runCodeception' => $this->taskExec(vsprintf($cmd_pattern, $cmd_args)),
]);

return $this
->taskExec(vsprintf($cmd_pattern, $cmd_args))
->printed(false);
return $cb;
}

/**
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
"prefer-stable": true,
"require": {
"cheppers/asset-jar": "^0.0",
"consolidation/robo": "1.0.0-RC2"
"consolidation/robo": "1.0.0-RC2",
"samsonasik/package-versions": "^1.1"
},
"require-dev": {
"cheppers/git-hooks": "^0.0.8",
"cheppers/robo-phpcs": "^0.0.4",
"cheppers/lint-report": "^0.0.4",
"cheppers/robo-phpcs": "^0.0.7",
"codeception/codeception": "^2.2",
"symfony/process": "^2.8|^3.1"
"symfony/process": "^2.8 || ^3.1",
"symfony/yaml": "^2.8 || ^3.1"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit ee44b81

Please sign in to comment.