From ddd0ca477c7cbb7fa45213c5488da6185e5e879e Mon Sep 17 00:00:00 2001 From: George Steel Date: Thu, 8 Aug 2024 12:20:13 +0100 Subject: [PATCH 01/12] 8.4 Missing in Schema Enum Signed-off-by: George Steel --- laminas-ci.schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/laminas-ci.schema.json b/laminas-ci.schema.json index 72aeff8..dc46235 100644 --- a/laminas-ci.schema.json +++ b/laminas-ci.schema.json @@ -256,6 +256,7 @@ "8.1", "8.2", "8.3", + "8.4", "@default" ] }, From af7f1827017e04266487022e6d274cfbeb6f5e7d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:40:31 +0000 Subject: [PATCH 02/12] Update dependency typescript to ~5.6.0 | datasource | package | from | to | | ---------- | ---------- | ----- | ----- | | npm | typescript | 5.5.2 | 5.6.2 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75bfd65..211e786 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "source-map-loader": "^5.0.0", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "typescript": "~5.5.0", + "typescript": "~5.6.0", "webpack": "^5.74.0", "webpack-cli": "^5.0.0" }, @@ -7550,9 +7550,9 @@ } }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index baaca8f..8656a09 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "source-map-loader": "^5.0.0", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "typescript": "~5.5.0", + "typescript": "~5.6.0", "webpack": "^5.74.0", "webpack-cli": "^5.0.0" } From 6248e0b7e71fd01cc14bf4e70c1c397c2f23a0c6 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 10 Sep 2024 18:54:33 +0100 Subject: [PATCH 03/12] Quote glob argument for `markdownlint` Signed-off-by: George Steel --- src/tools.ts | 4 ++-- tests/doc-linting-doc-book/matrix.json | 2 +- tests/doc-linting-docs-book/matrix.json | 2 +- tests/doc-linting-without-code-checks-due-diff/matrix.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools.ts b/src/tools.ts index 453d535..4104998 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -70,14 +70,14 @@ export default function createTools(config: Config): Array { { executionType : ToolExecutionType.STATIC, name : 'Documentation Linting', - command : 'markdownlint doc/book/**/*.md', + command : "markdownlint 'doc/book/**/*.md'", filesToCheck : [ 'doc/book/' ], toolType : ToolType.LINTER, }, { executionType : ToolExecutionType.STATIC, name : 'Documentation Linting', - command : 'markdownlint docs/book/**/*.md', + command : "markdownlint 'docs/book/**/*.md'", filesToCheck : [ 'docs/book/' ], toolType : ToolType.LINTER, }, diff --git a/tests/doc-linting-doc-book/matrix.json b/tests/doc-linting-doc-book/matrix.json index 98a032b..419cb49 100644 --- a/tests/doc-linting-doc-book/matrix.json +++ b/tests/doc-linting-doc-book/matrix.json @@ -2,7 +2,7 @@ "include": [ { "name": "Documentation Linting [8.2, latest]", - "job": "{\"command\":\"markdownlint doc/book/**/*.md\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "job": "{\"command\":\"markdownlint 'doc/book/**/*.md'\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" } diff --git a/tests/doc-linting-docs-book/matrix.json b/tests/doc-linting-docs-book/matrix.json index 5778cec..00ae93e 100644 --- a/tests/doc-linting-docs-book/matrix.json +++ b/tests/doc-linting-docs-book/matrix.json @@ -2,7 +2,7 @@ "include": [ { "name": "Documentation Linting [8.2, latest]", - "job": "{\"command\":\"markdownlint docs/book/**/*.md\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "job": "{\"command\":\"markdownlint 'docs/book/**/*.md'\",\"php\":\"8.2\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" } diff --git a/tests/doc-linting-without-code-checks-due-diff/matrix.json b/tests/doc-linting-without-code-checks-due-diff/matrix.json index edd2308..623e195 100644 --- a/tests/doc-linting-without-code-checks-due-diff/matrix.json +++ b/tests/doc-linting-without-code-checks-due-diff/matrix.json @@ -2,7 +2,7 @@ "include": [ { "name": "Documentation Linting [8.1, locked]", - "job": "{\"command\":\"markdownlint docs/book/**/*.md\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "job": "{\"command\":\"markdownlint 'docs/book/**/*.md'\",\"php\":\"8.1\",\"extensions\":[],\"ini\":[],\"dependencies\":\"locked\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" } From 5c3ff0c05d4d78ad6d7882f969331166dc6a2518 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:12:27 +0000 Subject: [PATCH 04/12] Update dependency @cfworker/json-schema to v2 | datasource | package | from | to | | ---------- | --------------------- | ------ | ----- | | npm | @cfworker/json-schema | 1.12.7 | 2.0.1 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 9 +++++---- package.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 211e786..2b6bb25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "laminas-ci-matrix-action", "dependencies": { "@actions/core": "^1.10.0", - "@cfworker/json-schema": "^1.12.5", + "@cfworker/json-schema": "^2.0.0", "@types/semver": "^7.3.13", "semver": "^7.3.8" }, @@ -761,9 +761,10 @@ "dev": true }, "node_modules/@cfworker/json-schema": { - "version": "1.12.7", - "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-1.12.7.tgz", - "integrity": "sha512-KEJUW22arGRQVoS6Ti8SvgXnme6NNMMcGBugdir1hf32ofWUXC8guwrFbepO2+YtqxNBUo5oO0pLYM5d4pyjOg==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-2.0.1.tgz", + "integrity": "sha512-1w7xVrTFjAWBVaOWRH5AMdKpJdltF4iy/d93E7qj8Rox6yY9OzEW1aC7T5eONrDOxXrlnsclPw9v24XW2c0mkg==", + "license": "MIT" }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", diff --git a/package.json b/package.json index 8656a09..18cf50e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@actions/core": "^1.10.0", - "@cfworker/json-schema": "^1.12.5", + "@cfworker/json-schema": "^2.0.0", "@types/semver": "^7.3.13", "semver": "^7.3.8" }, From 1184bca6b94fba1d15f969750f59a870e9cec573 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 23 Nov 2024 22:20:08 +0000 Subject: [PATCH 05/12] Update dependency typescript to ~5.7.0 (#324) | datasource | package | from | to | | ---------- | ---------- | ----- | ----- | | npm | typescript | 5.6.2 | 5.7.2 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b6bb25..7a03c1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "source-map-loader": "^5.0.0", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "typescript": "~5.6.0", + "typescript": "~5.7.0", "webpack": "^5.74.0", "webpack-cli": "^5.0.0" }, @@ -7551,9 +7551,9 @@ } }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 18cf50e..60538c1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "source-map-loader": "^5.0.0", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "typescript": "~5.6.0", + "typescript": "~5.7.0", "webpack": "^5.74.0", "webpack-cli": "^5.0.0" } From e4b28f46fb7b64083a3432d6736d7c615f7cf258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:58:29 +0200 Subject: [PATCH 06/12] qa: introduce tests for phpstan tool detection 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> --- .../.laminas-ci.json | 3 +++ tests/code-check-phpstan-alternative-dist/matrix.json | 10 ++++++++++ .../phpstan.dist.neon | 0 tests/code-check-phpstan-alternative-dist/test.env | 0 tests/code-check-phpstan-dist/.laminas-ci.json | 3 +++ tests/code-check-phpstan-dist/matrix.json | 10 ++++++++++ tests/code-check-phpstan-dist/phpstan.neon.dist | 0 tests/code-check-phpstan-dist/test.env | 0 tests/code-check-phpstan-no-dist/.laminas-ci.json | 3 +++ tests/code-check-phpstan-no-dist/matrix.json | 10 ++++++++++ tests/code-check-phpstan-no-dist/phpstan.neon | 0 tests/code-check-phpstan-no-dist/test.env | 0 12 files changed, 39 insertions(+) create mode 100644 tests/code-check-phpstan-alternative-dist/.laminas-ci.json create mode 100644 tests/code-check-phpstan-alternative-dist/matrix.json create mode 100644 tests/code-check-phpstan-alternative-dist/phpstan.dist.neon create mode 100644 tests/code-check-phpstan-alternative-dist/test.env create mode 100644 tests/code-check-phpstan-dist/.laminas-ci.json create mode 100644 tests/code-check-phpstan-dist/matrix.json create mode 100644 tests/code-check-phpstan-dist/phpstan.neon.dist create mode 100644 tests/code-check-phpstan-dist/test.env create mode 100644 tests/code-check-phpstan-no-dist/.laminas-ci.json create mode 100644 tests/code-check-phpstan-no-dist/matrix.json create mode 100644 tests/code-check-phpstan-no-dist/phpstan.neon create mode 100644 tests/code-check-phpstan-no-dist/test.env diff --git a/tests/code-check-phpstan-alternative-dist/.laminas-ci.json b/tests/code-check-phpstan-alternative-dist/.laminas-ci.json new file mode 100644 index 0000000..a912e7b --- /dev/null +++ b/tests/code-check-phpstan-alternative-dist/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-phpstan-alternative-dist/matrix.json b/tests/code-check-phpstan-alternative-dist/matrix.json new file mode 100644 index 0000000..dfaa598 --- /dev/null +++ b/tests/code-check-phpstan-alternative-dist/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "PHPStan [7.4, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "operatingSystem": "ubuntu-latest", + "action": "laminas/laminas-continuous-integration-action@v1" + } + ] +} diff --git a/tests/code-check-phpstan-alternative-dist/phpstan.dist.neon b/tests/code-check-phpstan-alternative-dist/phpstan.dist.neon new file mode 100644 index 0000000..e69de29 diff --git a/tests/code-check-phpstan-alternative-dist/test.env b/tests/code-check-phpstan-alternative-dist/test.env new file mode 100644 index 0000000..e69de29 diff --git a/tests/code-check-phpstan-dist/.laminas-ci.json b/tests/code-check-phpstan-dist/.laminas-ci.json new file mode 100644 index 0000000..a912e7b --- /dev/null +++ b/tests/code-check-phpstan-dist/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-phpstan-dist/matrix.json b/tests/code-check-phpstan-dist/matrix.json new file mode 100644 index 0000000..dfaa598 --- /dev/null +++ b/tests/code-check-phpstan-dist/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "PHPStan [7.4, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "operatingSystem": "ubuntu-latest", + "action": "laminas/laminas-continuous-integration-action@v1" + } + ] +} diff --git a/tests/code-check-phpstan-dist/phpstan.neon.dist b/tests/code-check-phpstan-dist/phpstan.neon.dist new file mode 100644 index 0000000..e69de29 diff --git a/tests/code-check-phpstan-dist/test.env b/tests/code-check-phpstan-dist/test.env new file mode 100644 index 0000000..e69de29 diff --git a/tests/code-check-phpstan-no-dist/.laminas-ci.json b/tests/code-check-phpstan-no-dist/.laminas-ci.json new file mode 100644 index 0000000..a912e7b --- /dev/null +++ b/tests/code-check-phpstan-no-dist/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "stablePHP": "7.4" +} diff --git a/tests/code-check-phpstan-no-dist/matrix.json b/tests/code-check-phpstan-no-dist/matrix.json new file mode 100644 index 0000000..dfaa598 --- /dev/null +++ b/tests/code-check-phpstan-no-dist/matrix.json @@ -0,0 +1,10 @@ +{ + "include": [ + { + "name": "PHPStan [7.4, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "operatingSystem": "ubuntu-latest", + "action": "laminas/laminas-continuous-integration-action@v1" + } + ] +} diff --git a/tests/code-check-phpstan-no-dist/phpstan.neon b/tests/code-check-phpstan-no-dist/phpstan.neon new file mode 100644 index 0000000..e69de29 diff --git a/tests/code-check-phpstan-no-dist/test.env b/tests/code-check-phpstan-no-dist/test.env new file mode 100644 index 0000000..e69de29 From a45f94bdac22d25a64e351133901a6aa71603124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:58:42 +0200 Subject: [PATCH 07/12] feature: introduce `phpstan` tool detection 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/tools.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools.ts b/src/tools.ts index 4104998..95c20e9 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -154,6 +154,13 @@ export default function createTools(config: Config): Array { filesToCheck : [ '.php-cs-fixer.php', '.php-cs-fixer.dist.php' ], toolType : ToolType.CODE_CHECK, }, + { + executionType : ToolExecutionType.STATIC, + name : 'PHPStan', + command : './vendor/bin/phpstan analyse --error-format=github --ansi --no-progress', + filesToCheck : [ 'phpstan.neon', 'phpstan.neon.dist', 'phpstan.dist.neon' ], + toolType : ToolType.CODE_CHECK, + }, backwardCompatibilityCheckTool(config), ].filter((tool) => tool !== null) as Tool[]; From 5550924feb342ac5457e9e430afe7447e2e08762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:14:14 +0200 Subject: [PATCH 08/12] docs: add `PHPStan` detection logic 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 ab13ff8..4022d85 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Currently, it identifies the following: - PHPUnit tests based on the presence of `phpunit.xml.dist` or `phpunit.xml` files. - 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. +- PHPStan checks based on the presence of `phpstan.neon`, `phpstan.neon.dist` or `phpstan.dist.neon` files. - ComposerRequireChecker checks based on the presence of `composer-require-checker.json` file. - 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. From 52ab3d192b785076c9c9dca59c941fe808213e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:31:38 +0200 Subject: [PATCH 09/12] refactor: move some tools to dedicated files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the new PHPStan tool, we exceeded the line-length limit of 100 lines per file. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/config/app.ts | 3 +- src/enum/toolExecutionType.ts | 13 ++++ src/enum/toolType.ts | 4 + src/tools.ts | 117 +++++----------------------- src/tools/codeception.ts | 10 +++ src/tools/codesniffer.ts | 11 +++ src/tools/composerRequireChecker.ts | 10 +++ src/tools/infection.ts | 22 ++++++ src/tools/phpCsFixer.ts | 10 +++ src/tools/phpbench.ts | 10 +++ src/tools/phpstan.ts | 10 +++ src/tools/phpunit.ts | 11 +++ src/tools/psalm.ts | 11 +++ 13 files changed, 144 insertions(+), 98 deletions(-) create mode 100644 src/enum/toolExecutionType.ts create mode 100644 src/enum/toolType.ts create mode 100644 src/tools/codeception.ts create mode 100644 src/tools/codesniffer.ts create mode 100644 src/tools/composerRequireChecker.ts create mode 100644 src/tools/infection.ts create mode 100644 src/tools/phpCsFixer.ts create mode 100644 src/tools/phpbench.ts create mode 100644 src/tools/phpstan.ts create mode 100644 src/tools/phpunit.ts create mode 100644 src/tools/psalm.ts diff --git a/src/config/app.ts b/src/config/app.ts index 12005b8..9bd24e1 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -1,8 +1,9 @@ import fs, {PathLike} from 'fs'; import semver from 'semver'; import parseJsonFile from '../json'; -import {isToolRunningContainerDefaultPhpVersion, Tool, ToolExecutionType} from '../tools'; +import {isToolRunningContainerDefaultPhpVersion, Tool} from '../tools'; import {Logger} from '../logging'; +import {ToolExecutionType} from '../enum/toolExecutionType'; import { CONTAINER_DEFAULT_PHP_VERSION, CURRENT_STABLE, diff --git a/src/enum/toolExecutionType.ts b/src/enum/toolExecutionType.ts new file mode 100644 index 0000000..2ccd418 --- /dev/null +++ b/src/enum/toolExecutionType.ts @@ -0,0 +1,13 @@ +export enum ToolExecutionType { + /** + * @description Executed on every supported PHP version with lowest & latest dependencies. + * In case, a lock-file is present, the minimum supported PHP version will also run with LOCKED + * dependencies. + */ + MATRIX = 'matrix', + + /** + * @description Executed on the minimum PHP version with either LOCKED or LATEST dependencies. + */ + STATIC = 'static', +} diff --git a/src/enum/toolType.ts b/src/enum/toolType.ts new file mode 100644 index 0000000..6696a4b --- /dev/null +++ b/src/enum/toolType.ts @@ -0,0 +1,4 @@ +export enum ToolType { + LINTER = 'linter', + CODE_CHECK = 'code_check', +} diff --git a/src/tools.ts b/src/tools.ts index 95c20e9..8fb5daf 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -1,27 +1,17 @@ import fs, {PathLike} from 'fs'; import {Config} from './config/app'; -import {ComposerJson} from './config/composer'; -import parseJsonFile from './json'; import {CONTAINER_DEFAULT_PHP_VERSION} from './config/php'; - -export enum ToolExecutionType { - /** - * @description Executed on every supported PHP version with lowest & latest dependencies. - * In case, a lock-file is present, the minimum supported PHP version will also run with LOCKED - * dependencies. - */ - MATRIX = 'matrix', - - /** - * @description Executed on the minimum PHP version with either LOCKED or LATEST dependencies. - */ - STATIC = 'static', -} - -enum ToolType { - LINTER = 'linter', - CODE_CHECK = 'code_check', -} +import {PHPUnitTool} from './tools/phpunit'; +import {InfectionTool} from './tools/infection'; +import {PhpCodeSnifferTool} from './tools/codesniffer'; +import {PsalmTool} from './tools/psalm'; +import {ComposerRequireCheckerTool} from './tools/composerRequireChecker'; +import {PhpBenchTool} from './tools/phpbench'; +import {CodeceptionTool} from './tools/codeception'; +import {PhpCsFixerTool} from './tools/phpCsFixer'; +import {PHPStanTool} from './tools/phpstan'; +import {ToolExecutionType} from './enum/toolExecutionType'; +import {ToolType} from './enum/toolType'; export type Tool = { executionType: ToolExecutionType, @@ -36,16 +26,6 @@ export type ToolRunningContainerDefaultPhpVersion = Tool & { php: typeof CONTAINER_DEFAULT_PHP_VERSION, } -function detectInfectionCommand(): string { - const composerJson: ComposerJson = parseJsonFile('composer.json', true) as ComposerJson; - - if (composerJson['require-dev']?.['roave/infection-static-analysis-plugin'] !== undefined) { - return './vendor/bin/roave-infection-static-analysis-plugin'; - } - - return './vendor/bin/infection'; -} - function backwardCompatibilityCheckTool(config: Config): ToolRunningContainerDefaultPhpVersion | null { if (!config.backwardCompatibilityCheck) { return null; @@ -95,72 +75,15 @@ export default function createTools(config: Config): Array { filesToCheck : [ 'README.md' ], toolType : ToolType.LINTER, }, - { - executionType : ToolExecutionType.MATRIX, - name : 'PHPUnit', - command : './vendor/bin/phpunit', - filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ], - toolType : ToolType.CODE_CHECK, - lintConfigCommand : 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd', - }, - { - executionType : ToolExecutionType.STATIC, - name : 'Infection', - command : detectInfectionCommand(), - filesToCheck : [ 'infection.json', 'infection.json.dist' ], - toolType : ToolType.CODE_CHECK, - }, - { - executionType : ToolExecutionType.STATIC, - name : 'PHPCodeSniffer', - command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr', - filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ], - toolType : ToolType.CODE_CHECK, - lintConfigCommand : 'xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd', - }, - { - executionType : ToolExecutionType.STATIC, - name : 'Psalm', - command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache', - filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ], - toolType : ToolType.CODE_CHECK, - lintConfigCommand : 'xmllint --schema vendor/vimeo/psalm/config.xsd', - }, - { - executionType : ToolExecutionType.STATIC, - name : 'Composer Require Checker', - command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json', - filesToCheck : [ 'composer-require-checker.json' ], - toolType : ToolType.CODE_CHECK, - }, - { - executionType : ToolExecutionType.STATIC, - name : 'PHPBench', - command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate', - filesToCheck : [ 'phpbench.json' ], - toolType : ToolType.CODE_CHECK, - }, - { - executionType : ToolExecutionType.STATIC, - name : 'Codeception', - command : './vendor/bin/codecept run', - filesToCheck : [ 'codeception.yml.dist', 'codeception.yml' ], - toolType : ToolType.CODE_CHECK, - }, - { - executionType : ToolExecutionType.STATIC, - name : 'PHP CS Fixer', - command : './vendor/bin/php-cs-fixer fix -v --diff --dry-run', - filesToCheck : [ '.php-cs-fixer.php', '.php-cs-fixer.dist.php' ], - toolType : ToolType.CODE_CHECK, - }, - { - executionType : ToolExecutionType.STATIC, - name : 'PHPStan', - command : './vendor/bin/phpstan analyse --error-format=github --ansi --no-progress', - filesToCheck : [ 'phpstan.neon', 'phpstan.neon.dist', 'phpstan.dist.neon' ], - toolType : ToolType.CODE_CHECK, - }, + PHPUnitTool, + InfectionTool, + PhpCodeSnifferTool, + PsalmTool, + ComposerRequireCheckerTool, + PhpBenchTool, + CodeceptionTool, + PhpCsFixerTool, + PHPStanTool, backwardCompatibilityCheckTool(config), ].filter((tool) => tool !== null) as Tool[]; diff --git a/src/tools/codeception.ts b/src/tools/codeception.ts new file mode 100644 index 0000000..006d674 --- /dev/null +++ b/src/tools/codeception.ts @@ -0,0 +1,10 @@ +import {ToolExecutionType} from '../enum/toolExecutionType'; +import {ToolType} from '../enum/toolType'; + +export const CodeceptionTool = { + executionType : ToolExecutionType.STATIC, + name : 'Codeception', + command : './vendor/bin/codecept run', + filesToCheck : [ 'codeception.yml.dist', 'codeception.yml' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/src/tools/codesniffer.ts b/src/tools/codesniffer.ts new file mode 100644 index 0000000..4b902b1 --- /dev/null +++ b/src/tools/codesniffer.ts @@ -0,0 +1,11 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PhpCodeSnifferTool = { + executionType : ToolExecutionType.STATIC, + name : 'PHPCodeSniffer', + command : './vendor/bin/phpcs -q --report=checkstyle | cs2pr', + filesToCheck : [ 'phpcs.xml', 'phpcs.xml.dist' ], + toolType : ToolType.CODE_CHECK, + lintConfigCommand : 'xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd', +}; diff --git a/src/tools/composerRequireChecker.ts b/src/tools/composerRequireChecker.ts new file mode 100644 index 0000000..1ad7776 --- /dev/null +++ b/src/tools/composerRequireChecker.ts @@ -0,0 +1,10 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const ComposerRequireCheckerTool = { + executionType : ToolExecutionType.STATIC, + name : 'Composer Require Checker', + command : './vendor/bin/composer-require-checker check --config-file=composer-require-checker.json -n -v composer.json', + filesToCheck : [ 'composer-require-checker.json' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/src/tools/infection.ts b/src/tools/infection.ts new file mode 100644 index 0000000..2bf14b2 --- /dev/null +++ b/src/tools/infection.ts @@ -0,0 +1,22 @@ +import {ToolType} from '../enum/toolType'; +import {ComposerJson} from '../config/composer'; +import parseJsonFile from '../json'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const InfectionTool = { + executionType : ToolExecutionType.STATIC, + name : 'Infection', + command : detectInfectionCommand(), + filesToCheck : [ 'infection.json', 'infection.json.dist' ], + toolType : ToolType.CODE_CHECK, +}; + +function detectInfectionCommand(): string { + const composerJson: ComposerJson = parseJsonFile('composer.json', true) as ComposerJson; + + if (composerJson['require-dev']?.['roave/infection-static-analysis-plugin'] !== undefined) { + return './vendor/bin/roave-infection-static-analysis-plugin'; + } + + return './vendor/bin/infection'; +} diff --git a/src/tools/phpCsFixer.ts b/src/tools/phpCsFixer.ts new file mode 100644 index 0000000..c67e854 --- /dev/null +++ b/src/tools/phpCsFixer.ts @@ -0,0 +1,10 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PhpCsFixerTool = { + executionType : ToolExecutionType.STATIC, + name : 'PHP CS Fixer', + command : './vendor/bin/php-cs-fixer fix -v --diff --dry-run', + filesToCheck : [ '.php-cs-fixer.php', '.php-cs-fixer.dist.php' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/src/tools/phpbench.ts b/src/tools/phpbench.ts new file mode 100644 index 0000000..d3a0199 --- /dev/null +++ b/src/tools/phpbench.ts @@ -0,0 +1,10 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PhpBenchTool = { + executionType : ToolExecutionType.STATIC, + name : 'PHPBench', + command : './vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate', + filesToCheck : [ 'phpbench.json' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/src/tools/phpstan.ts b/src/tools/phpstan.ts new file mode 100644 index 0000000..85e0cee --- /dev/null +++ b/src/tools/phpstan.ts @@ -0,0 +1,10 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PHPStanTool = { + executionType : ToolExecutionType.STATIC, + name : 'PHPStan', + command : './vendor/bin/phpstan analyse --error-format=github --ansi --no-progress', + filesToCheck : [ 'phpstan.neon', 'phpstan.neon.dist', 'phpstan.dist.neon' ], + toolType : ToolType.CODE_CHECK, +}; diff --git a/src/tools/phpunit.ts b/src/tools/phpunit.ts new file mode 100644 index 0000000..049b534 --- /dev/null +++ b/src/tools/phpunit.ts @@ -0,0 +1,11 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PHPUnitTool = { + executionType : ToolExecutionType.MATRIX, + name : 'PHPUnit', + command : './vendor/bin/phpunit', + filesToCheck : [ 'phpunit.xml.dist', 'phpunit.xml' ], + toolType : ToolType.CODE_CHECK, + lintConfigCommand : 'xmllint --schema vendor/phpunit/phpunit/phpunit.xsd', +}; diff --git a/src/tools/psalm.ts b/src/tools/psalm.ts new file mode 100644 index 0000000..6f9c682 --- /dev/null +++ b/src/tools/psalm.ts @@ -0,0 +1,11 @@ +import {ToolType} from '../enum/toolType'; +import {ToolExecutionType} from '../enum/toolExecutionType'; + +export const PsalmTool = { + executionType : ToolExecutionType.STATIC, + name : 'Psalm', + command : './vendor/bin/psalm --shepherd --stats --output-format=github --no-cache', + filesToCheck : [ 'psalm.xml.dist', 'psalm.xml' ], + toolType : ToolType.CODE_CHECK, + lintConfigCommand : 'xmllint --schema vendor/vimeo/psalm/config.xsd', +}; From e611f14ad449cb88c332c0a99f03d62549e8ae66 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 9 Dec 2024 21:00:37 +0000 Subject: [PATCH 10/12] QA: Fix `AS` keyword casing Signed-off-by: George Steel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b8748c5..fc5cf61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:21.7.3-alpine as compiler +FROM node:21.7.3-alpine AS compiler RUN mkdir -p /usr/local/source WORKDIR /usr/local/source From 5ecd2651c788334a27cf95a2053cd4d5809c0062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:20:35 +0100 Subject: [PATCH 11/12] chore: apply PHP 8.4 to unit tests 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/config/app.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/app.spec.ts b/src/config/app.spec.ts index 2d2b432..ae497df 100644 --- a/src/config/app.spec.ts +++ b/src/config/app.spec.ts @@ -24,7 +24,7 @@ describe('config/app', () => { ${'~8.1'} | ${[ '8.1' ]} ${'~8.1.0'} | ${[ '8.1' ]} ${'~8.1.12'} | ${[ '8.1' ]} - ${'^8.0 || ~8.0.0 || ~8.1.12'} | ${[ '8.0', '8.1', '8.2', '8.3' ]} + ${'^8.0 || ~8.0.0 || ~8.1.12'} | ${[ '8.0', '8.1', '8.2', '8.3', '8.4' ]} ${'<=8.1.0'} | ${[ '8.0', '8.1' ]} `('for "$constraint" === $expected', ({constraint, expected}) => { expect(gatherVersions({require: {php: constraint}})).toEqual(expected); From d0980e78d921b7f500e079bc16829fc45185a3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:21:56 +0100 Subject: [PATCH 12/12] chore: bump PHPStan integration tests to use PHP 8.3 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> --- tests/code-check-phpstan-alternative-dist/.laminas-ci.json | 2 +- tests/code-check-phpstan-alternative-dist/matrix.json | 4 ++-- tests/code-check-phpstan-dist/.laminas-ci.json | 2 +- tests/code-check-phpstan-dist/matrix.json | 4 ++-- tests/code-check-phpstan-no-dist/.laminas-ci.json | 2 +- tests/code-check-phpstan-no-dist/matrix.json | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/code-check-phpstan-alternative-dist/.laminas-ci.json b/tests/code-check-phpstan-alternative-dist/.laminas-ci.json index a912e7b..63c6c4d 100644 --- a/tests/code-check-phpstan-alternative-dist/.laminas-ci.json +++ b/tests/code-check-phpstan-alternative-dist/.laminas-ci.json @@ -1,3 +1,3 @@ { - "stablePHP": "7.4" + "stablePHP": "8.3" } diff --git a/tests/code-check-phpstan-alternative-dist/matrix.json b/tests/code-check-phpstan-alternative-dist/matrix.json index dfaa598..ab295a3 100644 --- a/tests/code-check-phpstan-alternative-dist/matrix.json +++ b/tests/code-check-phpstan-alternative-dist/matrix.json @@ -1,8 +1,8 @@ { "include": [ { - "name": "PHPStan [7.4, latest]", - "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "name": "PHPStan [8.3, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"8.3\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" } diff --git a/tests/code-check-phpstan-dist/.laminas-ci.json b/tests/code-check-phpstan-dist/.laminas-ci.json index a912e7b..63c6c4d 100644 --- a/tests/code-check-phpstan-dist/.laminas-ci.json +++ b/tests/code-check-phpstan-dist/.laminas-ci.json @@ -1,3 +1,3 @@ { - "stablePHP": "7.4" + "stablePHP": "8.3" } diff --git a/tests/code-check-phpstan-dist/matrix.json b/tests/code-check-phpstan-dist/matrix.json index dfaa598..ab295a3 100644 --- a/tests/code-check-phpstan-dist/matrix.json +++ b/tests/code-check-phpstan-dist/matrix.json @@ -1,8 +1,8 @@ { "include": [ { - "name": "PHPStan [7.4, latest]", - "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "name": "PHPStan [8.3, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"8.3\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" } diff --git a/tests/code-check-phpstan-no-dist/.laminas-ci.json b/tests/code-check-phpstan-no-dist/.laminas-ci.json index a912e7b..63c6c4d 100644 --- a/tests/code-check-phpstan-no-dist/.laminas-ci.json +++ b/tests/code-check-phpstan-no-dist/.laminas-ci.json @@ -1,3 +1,3 @@ { - "stablePHP": "7.4" + "stablePHP": "8.3" } diff --git a/tests/code-check-phpstan-no-dist/matrix.json b/tests/code-check-phpstan-no-dist/matrix.json index dfaa598..ab295a3 100644 --- a/tests/code-check-phpstan-no-dist/matrix.json +++ b/tests/code-check-phpstan-no-dist/matrix.json @@ -1,8 +1,8 @@ { "include": [ { - "name": "PHPStan [7.4, latest]", - "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"7.4\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", + "name": "PHPStan [8.3, latest]", + "job": "{\"command\":\"./vendor/bin/phpstan analyse --error-format=github --ansi --no-progress\",\"php\":\"8.3\",\"extensions\":[],\"ini\":[],\"dependencies\":\"latest\",\"ignore_platform_reqs_8\":false,\"ignore_php_platform_requirement\":false,\"additional_composer_arguments\":[],\"before_script\":[]}", "operatingSystem": "ubuntu-latest", "action": "laminas/laminas-continuous-integration-action@v1" }