Add linting check to CI to help catch version-incompatible code
timw4mail/HummingBirdAnimeClient/develop This commit looks good Details

This commit is contained in:
Timothy Warren 2019-12-06 10:05:09 -05:00
parent 4b73b1b249
commit 26fca2a1c2
3 changed files with 21 additions and 17 deletions

View File

@ -11,6 +11,7 @@ php:
script:
- mkdir -p build/logs
- vendor/bin/robo lint
- phpdbg -qrr -- vendor/bin/phpunit -c build
after_script:

3
Jenkinsfile vendored
View File

@ -13,6 +13,7 @@ pipeline {
sh 'curl -sS https://getcomposer.org/installer | php'
sh 'rm -f composer.lock'
sh 'php composer.phar install --ignore-platform-reqs'
sh 'php vendor/bin/robo lint'
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
}
}
@ -28,6 +29,7 @@ pipeline {
sh 'curl -sS https://getcomposer.org/installer | php'
sh 'rm -f composer.lock'
sh 'php composer.phar install --ignore-platform-reqs'
sh 'php vendor/bin/robo lint'
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
}
}
@ -43,6 +45,7 @@ pipeline {
sh 'curl -sS https://getcomposer.org/installer | php'
sh 'rm -f composer.lock'
sh 'php composer.phar install --ignore-platform-reqs'
sh 'php vendor/bin/robo lint'
sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
}
}

View File

@ -54,7 +54,7 @@ class RoboFile extends Tasks {
/**
* Do static analysis tasks
*/
public function analyze()
public function analyze(): void
{
$this->prepare();
$this->lint();
@ -67,7 +67,7 @@ class RoboFile extends Tasks {
/**
* Run all tests, generate coverage, generate docs, generate code statistics
*/
public function build()
public function build(): void
{
$this->analyze();
$this->coverage();
@ -77,19 +77,19 @@ class RoboFile extends Tasks {
/**
* Cleanup temporary files
*/
public function clean()
public function clean(): void
{
$cleanFiles = [
'build/humbug.json',
'build/humbug-log.txt',
];
array_map(function ($file) {
array_map(static function ($file) {
@unlink($file);
}, $cleanFiles);
// So the task doesn't complain,
// make any 'missing' dirs to cleanup
array_map(function ($dir) {
array_map(static function ($dir) {
if ( ! is_dir($dir))
{
`mkdir -p {$dir}`;
@ -103,7 +103,7 @@ class RoboFile extends Tasks {
/**
* Run unit tests and generate coverage reports
*/
public function coverage()
public function coverage(): void
{
$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
}
@ -111,7 +111,7 @@ class RoboFile extends Tasks {
/**
* Generate documentation with phpdox
*/
public function docs()
public function docs(): void
{
$cmd_parts = [
'vendor/bin/phpdox',
@ -122,7 +122,7 @@ class RoboFile extends Tasks {
/**
* Verify that source files are valid
*/
public function lint()
public function lint(): void
{
$files = $this->getAllSourceFiles();
@ -139,7 +139,7 @@ class RoboFile extends Tasks {
*
* @param bool $report - if true, generates reports instead of direct output
*/
public function phpcs($report = FALSE)
public function phpcs($report = FALSE): void
{
$report_cmd_parts = [
'vendor/bin/phpcs',
@ -162,7 +162,7 @@ class RoboFile extends Tasks {
*
* @param bool $report - if true, generates reports instead of direct output
*/
public function phploc($report = FALSE)
public function phploc($report = FALSE): void
{
// Command for generating reports
$report_cmd_parts = [
@ -190,7 +190,7 @@ class RoboFile extends Tasks {
/**
* Create temporary directories
*/
public function prepare()
public function prepare(): void
{
array_map([$this, '_mkdir'], $this->taskDirs);
}
@ -198,7 +198,7 @@ class RoboFile extends Tasks {
/**
* Lint php files and run unit tests
*/
public function test()
public function test(): void
{
$this->lint();
@ -208,7 +208,7 @@ class RoboFile extends Tasks {
/**
* Create pdepend reports
*/
protected function dependencyReport()
protected function dependencyReport(): void
{
$cmd_parts = [
'vendor/bin/pdepend',
@ -225,7 +225,7 @@ class RoboFile extends Tasks {
*
* @return array
*/
protected function getAllSourceFiles()
protected function getAllSourceFiles(): array
{
$files = array_merge(
glob_recursive('build/*.php'),
@ -246,7 +246,7 @@ class RoboFile extends Tasks {
*
* @param array $chunk
*/
protected function parallelLint(array $chunk)
protected function parallelLint(array $chunk): void
{
$task = $this->taskParallelExec()
->timeout(5)
@ -263,7 +263,7 @@ class RoboFile extends Tasks {
/**
* Generate copy paste detector report
*/
protected function phpcpdReport()
protected function phpcpdReport(): void
{
$cmd_parts = [
'vendor/bin/phpcpd',
@ -280,7 +280,7 @@ class RoboFile extends Tasks {
* @param array $cmd_parts - command arguments
* @param string $join_on - what to join the command arguments with
*/
protected function _run(array $cmd_parts, $join_on = ' ')
protected function _run(array $cmd_parts, $join_on = ' '): void
{
$this->taskExec(implode($join_on, $cmd_parts))->run();
}