From 0d47b0d25fab4986b37429700c871905f1351d1b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Sep 2021 04:54:08 +0200 Subject: [PATCH 1/5] Add `infection/infection` to CI runs, when `infection.json(.dist)` exists --- src/create-jobs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/create-jobs.js b/src/create-jobs.js index 5006f164..0d37fe58 100644 --- a/src/create-jobs.js +++ b/src/create-jobs.js @@ -157,6 +157,17 @@ function checks (config) { return createQaJobs('./vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate', config); } ), + new Check( + config.code_checks, + [fileTest('infection.json'), fileTest('infection.json.dist')], + /** + * @param {Config} config + * @return {Array} + */ + function (config) { + return createQaJobs('./vendor/bin/infection', config); + } + ), new Check( config.doc_linting, [fileTest('mkdocs.yml')], From b49cb836feddbff6ab4d758380cbb8a3bd8c0f46 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Sep 2021 05:09:43 +0200 Subject: [PATCH 2/5] Added `roave/infection-static-analysis-plugin` when it is in `require-dev` --- src/create-jobs.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/create-jobs.js b/src/create-jobs.js index 0d37fe58..e271ddc5 100644 --- a/src/create-jobs.js +++ b/src/create-jobs.js @@ -159,7 +159,20 @@ function checks (config) { ), new Check( config.code_checks, - [fileTest('infection.json'), fileTest('infection.json.dist')], + [ + function () { + const composerFile = JSON.parse(fs.readFileSync('composer.json')); + + return ( + fs.existsSync('infection.json') || + fs.existsSync('infection.json.dist') + ) && ! ( + // Skip executing infection, if roave/infection-static-analysis-plugin (redundant task) + composerFile.hasOwnProperty('require-dev') && + composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin') + ); + } + ], /** * @param {Config} config * @return {Array} @@ -168,6 +181,24 @@ function checks (config) { return createQaJobs('./vendor/bin/infection', config); } ), + new Check( + config.code_checks, + [ + function () { + const composerFile = JSON.parse(fs.readFileSync('composer.json')); + + return composerFile.hasOwnProperty('require-dev') && + composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin'); + } + ], + /** + * @param {Config} config + * @return {Array} + */ + function (config) { + return createQaJobs('./vendor/bin/roave-infection-static-analysis-plugin', config); + } + ), new Check( config.doc_linting, [fileTest('mkdocs.yml')], From b9d6a6cc23ccd0deff0e2b71d774fb779be0a2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 10 Oct 2021 17:18:39 +0200 Subject: [PATCH 3/5] refactor: rework the way on how either `roave/infection-static-analysis-plugin` or `infection/infection` is being used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/create-jobs.js | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/src/create-jobs.js b/src/create-jobs.js index e271ddc5..89b52544 100644 --- a/src/create-jobs.js +++ b/src/create-jobs.js @@ -6,6 +6,7 @@ import { Config } from './config.js'; import { Job } from './job.js'; import create_additional_jobs from './additional-checks.js'; import validateAndNormalizeChecks from './validate-and-normalize-checks-from-config.js'; +import parseJsonFile from "./json.js"; /** * @param {String} filename @@ -159,44 +160,20 @@ function checks (config) { ), new Check( config.code_checks, - [ - function () { - const composerFile = JSON.parse(fs.readFileSync('composer.json')); - - return ( - fs.existsSync('infection.json') || - fs.existsSync('infection.json.dist') - ) && ! ( - // Skip executing infection, if roave/infection-static-analysis-plugin (redundant task) - composerFile.hasOwnProperty('require-dev') && - composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin') - ); - } - ], + [fileTest('infection.json'), fileTest('infection.json.dist')], /** * @param {Config} config * @return {Array} */ function (config) { - return createQaJobs('./vendor/bin/infection', config); - } - ), - new Check( - config.code_checks, - [ - function () { - const composerFile = JSON.parse(fs.readFileSync('composer.json')); + const composerFile = parseJsonFile('composer.json', false); + let commandToExecute = 'vendor/bin/infection'; - return composerFile.hasOwnProperty('require-dev') && - composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin'); + if (composerFile.hasOwnProperty('require-dev') && composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin')) { + commandToExecute = 'vendor/bin/roave-infection-static-analysis-plugin'; } - ], - /** - * @param {Config} config - * @return {Array} - */ - function (config) { - return createQaJobs('./vendor/bin/roave-infection-static-analysis-plugin', config); + + return createQaJobs(commandToExecute, config); } ), new Check( From 02f27c9cdc6870bdd400b6cfba58c483883b9f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 10 Oct 2021 17:22:16 +0200 Subject: [PATCH 4/5] docs: added `Infection` to `README` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c129ee0..160e7d4c 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Currently, it identifies the following: - phpcs checks based on the presence of `phpcs.xml.dist` or `phpcs.xml` files. - Psalm checks based on the presence of `psalm.xml.dist` or `psalm.xml` files. - phpbench benchmarks based on the presence of a `phpbench.json`. +- Infection mutation tests based on the presence of `infection.json` or `infection.json.dist`. In case that `roave/infection-static-analysis-plugin` is installed, this will be used instead. - Markdown documentation based on the presence of a `mkdocs.yml` and/or markdown files in the `doc/book/` or `doc/books/` trees. - Codeception checks based on the presence of `codeception.yml.dist` or `codeception.yml` files. From f82f9f85a06630a786f9f35f9ff7b585d64de488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 10 Oct 2021 17:51:06 +0200 Subject: [PATCH 5/5] qa: use `./`-prefix for relative paths in commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/create-jobs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/create-jobs.js b/src/create-jobs.js index 89b52544..552ae636 100644 --- a/src/create-jobs.js +++ b/src/create-jobs.js @@ -167,10 +167,10 @@ function checks (config) { */ function (config) { const composerFile = parseJsonFile('composer.json', false); - let commandToExecute = 'vendor/bin/infection'; + let commandToExecute = './vendor/bin/infection'; if (composerFile.hasOwnProperty('require-dev') && composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin')) { - commandToExecute = 'vendor/bin/roave-infection-static-analysis-plugin'; + commandToExecute = './vendor/bin/roave-infection-static-analysis-plugin'; } return createQaJobs(commandToExecute, config); @@ -217,7 +217,7 @@ function checks (config) { * @return {Array} */ function (config) { - return createQaJobs('vendor/bin/codecept run', config); + return createQaJobs('./vendor/bin/codecept run', config); } ) ];