From 01f0cefbb8dec0d38c60b90df5bf9f0121e3f469 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 1 Oct 2024 13:49:10 +0200 Subject: [PATCH 1/4] SkipLintProcess: Pass script by file-name instead of code --- src/Process/SkipLintProcess.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Process/SkipLintProcess.php b/src/Process/SkipLintProcess.php index 527d61b..ad0ae48 100644 --- a/src/Process/SkipLintProcess.php +++ b/src/Process/SkipLintProcess.php @@ -23,15 +23,12 @@ class SkipLintProcess extends PhpProcess public function __construct(PhpExecutable $phpExecutable, array $filesToCheck) { $scriptPath = __DIR__ . '/../../bin/skip-linting.php'; - $script = file_get_contents($scriptPath); - if (!$script) { + if (!is_file($scriptPath)) { throw new RuntimeException("skip-linting.php script not found in '$scriptPath'."); } - $script = str_replace(' Date: Wed, 27 Mar 2024 18:24:43 +0100 Subject: [PATCH 2/4] GH Actions: run tests also on Windows OS When running the tests locally, I realized that patch 146 did not actually work correctly on Windows. This commit adds test runs against Windows in CI on a limited number of PHP versions to prevent this kind of issue going unnoticed for future PRs. Note: the lowest PHP version I can get a running build on is PHP 5.5. This is related to SSL transport issues with Packagist with old Composer versions (which are needed for old PHP versions). --- .github/workflows/test.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24a750b..8b69d3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,8 +91,8 @@ jobs: path: ./parallel-lint.phar test: - name: Run tests on PHP ${{ matrix.php }} - runs-on: ubuntu-latest + name: Run tests on PHP ${{ matrix.php }} (${{ matrix.os }}) + runs-on: "${{ matrix.os }}" continue-on-error: ${{ matrix.php == '8.4' }} needs: - bundle @@ -114,6 +114,19 @@ jobs: - '8.2' - '8.3' - '8.4' + os: + - 'ubuntu-latest' + + include: + # Also run the tests against Windows on a few PHP versions. + - php: '5.5' + os: 'windows-latest' + - php: '7.0' + os: 'windows-latest' + - php: '8.0' + os: 'windows-latest' + - php: '8.3' + os: 'windows-latest' steps: - name: Checkout code From aa0e4a070438fa5c95123aaebe2577eb0f5ef8e4 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 2 Oct 2024 08:54:46 +0200 Subject: [PATCH 3/4] Simplify fix --- .github/workflows/test.yml | 5 +++-- src/Process/SkipLintProcess.php | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b69d3f..c4bcfe8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -167,13 +167,14 @@ jobs: - name: Grab PHPUnit version id: phpunit_version - run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT + shell: bash + run: echo "VERSION=$(echo vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT - name: "Run unit tests (PHPUnit < 10)" if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} run: composer test - - name: "Run unit tests (PHPUnit < 10)" + - name: "Run unit tests (PHPUnit >= 10)" if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} run: composer test10 diff --git a/src/Process/SkipLintProcess.php b/src/Process/SkipLintProcess.php index ad0ae48..53f36d8 100644 --- a/src/Process/SkipLintProcess.php +++ b/src/Process/SkipLintProcess.php @@ -22,13 +22,10 @@ class SkipLintProcess extends PhpProcess */ public function __construct(PhpExecutable $phpExecutable, array $filesToCheck) { - $scriptPath = __DIR__ . '/../../bin/skip-linting.php'; + $scriptPath = dirname(dirname(__DIR__)) . '/bin/skip-linting.php'; + $code = sprintf("include('%s');", $scriptPath); - if (!is_file($scriptPath)) { - throw new RuntimeException("skip-linting.php script not found in '$scriptPath'."); - } - - $parameters = array('-d', 'display_errors=stderr', '-f', realpath($scriptPath)); + $parameters = array('-d', 'display_errors=stderr', '-r', $code); parent::__construct($phpExecutable, $parameters, implode(PHP_EOL, $filesToCheck)); } From f20e77c448224ce6ee150e4523b98e1151ecd85c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 2 Oct 2024 15:12:51 +0200 Subject: [PATCH 4/4] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4bcfe8..5692dd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -168,7 +168,7 @@ jobs: - name: Grab PHPUnit version id: phpunit_version shell: bash - run: echo "VERSION=$(echo vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT + run: echo "VERSION=$(php vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT - name: "Run unit tests (PHPUnit < 10)" if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}