From 76d27d0b8a4e740123b63a090f5c6c2f16dbb805 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:03:07 +0200 Subject: [PATCH 1/8] GH Actions: ubuntu-16.04 is no longer supported ... use `ubuntu-18.04` or `ubuntu-latest` for `20.04` instead. Also see: * https://ubuntu.com/blog/ubuntu-16-04-lts-transitions-to-extended-security-maintenance-esm * shivammathur/setup-php#452 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 642d8ea..9178b5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.operating-system }} strategy: matrix: - operating-system: ['ubuntu-16.04'] + operating-system: ['ubuntu-18.04'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0'] phpunit-versions: ['7.5.20'] steps: From e386675a4082cde0d6a68420e6ac8bdaf3d9880a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:07:31 +0200 Subject: [PATCH 2/8] GH Actions: explicitly set code coverage to none As no code coverage is being recorded for these builds, it is good practice to explicitly set `coverage: none` in `setup-php`. This fixes a warning on PHP 5.3 stating that Xdebug is on. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9178b5c..7f6b5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: extensions: mbstring, intl ini-values: post_max_size=256M, max_execution_time=180 tools: psalm, phpunit:${{ matrix.phpunit-versions }} + coverage: none - name: Install dependencies run: composer self-update --1; composer install @@ -50,6 +51,7 @@ jobs: extensions: mbstring, intl, sodium ini-values: post_max_size=256M, max_execution_time=180 tools: psalm, phpunit:${{ matrix.phpunit-versions }} + coverage: none - name: Install dependencies run: composer install @@ -82,6 +84,7 @@ jobs: extensions: mbstring, intl, sodium ini-values: post_max_size=256M, max_execution_time=180 tools: psalm, phpunit:${{ matrix.phpunit-versions }} + coverage: none - name: Install dependencies run: composer install From 6ab88bd2bc021b5ed7b0c5b4e9b7736b5f3462f7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:09:06 +0200 Subject: [PATCH 3/8] GH Actions: enable Composer caching ... by using the `ramsey/composer-install` action. This means that the Composer downloads directory for dependencies will be cached and restored on each build. This conserves resources and should also make builds faster. Ref: https://github.com/marketplace/actions/install-composer-dependencies --- .github/workflows/ci.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f6b5e7..257e464 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,11 @@ jobs: tools: psalm, phpunit:${{ matrix.phpunit-versions }} coverage: none - - name: Install dependencies - run: composer self-update --1; composer install + - name: Use Composer 1.x + run: composer self-update --1 + + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" - name: PHPUnit tests uses: php-actions/phpunit@v2 @@ -53,11 +56,11 @@ jobs: tools: psalm, phpunit:${{ matrix.phpunit-versions }} coverage: none - - name: Install dependencies - run: composer install - - name: Modernize dependencies - run: composer require --dev "phpunit/phpunit:>=4" + run: composer require --dev --no-update "phpunit/phpunit:>=4" + + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" - name: PHPUnit tests uses: php-actions/phpunit@v2 @@ -86,11 +89,11 @@ jobs: tools: psalm, phpunit:${{ matrix.phpunit-versions }} coverage: none - - name: Install dependencies - run: composer install - - name: Modernize dependencies - run: composer require --dev "phpunit/phpunit:>=4" + run: composer require --dev --no-update "phpunit/phpunit:>=4" + + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" - name: PHPUnit tests uses: php-actions/phpunit@v2 From 64256a012fe83e73778c9a0be3b8cd4a33c33aa8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:11:18 +0200 Subject: [PATCH 4/8] GH Actions: split off Psalm to separate workflow Psalm does not need to be run against multiple PHP versions. Running it once should be enough. With that in mind, this commit: * Introduces a separate, dedicated workflow which only installs and runs Psalm. * Removes the Psalm related steps from the `CI` workflow. * Removes Psalm from the `tools` setting for `setup-php`. --- .github/workflows/ci.yml | 12 +++--------- .github/workflows/psalm.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/psalm.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257e464..985add5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl ini-values: post_max_size=256M, max_execution_time=180 - tools: psalm, phpunit:${{ matrix.phpunit-versions }} + tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Use Composer 1.x @@ -53,7 +53,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, sodium ini-values: post_max_size=256M, max_execution_time=180 - tools: psalm, phpunit:${{ matrix.phpunit-versions }} + tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Modernize dependencies @@ -86,7 +86,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, sodium ini-values: post_max_size=256M, max_execution_time=180 - tools: psalm, phpunit:${{ matrix.phpunit-versions }} + tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Modernize dependencies @@ -100,9 +100,3 @@ jobs: timeout-minutes: 30 with: memory_limit: 256M - - - name: Install Psalm - run: rm composer.lock && composer require --dev vimeo/psalm:^4 - - - name: Static Analysis - run: vendor/bin/psalm diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..43aeeea --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,30 @@ +name: Psalm + +on: [push] + +jobs: + psalm: + name: Psalm on PHP ${{ matrix.php-versions }} + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-latest'] + php-versions: ['7.4'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: psalm:4 + coverage: none + + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" + with: + composer-options: --no-dev + + - name: Static Analysis + run: psalm From d0bbad2647da4bf8afa5ce33d636307d611006b5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:16:44 +0200 Subject: [PATCH 5/8] GH Actions: clean up running of the tests In contrast to Sodium Compat, the tests for this package _were_ running on the low PHP versions. However, the point remains that PHPUnit was being installed 3 (!) times, once via the `setup-php` action, once via the `composer install` and once via the `php-actions/phpunit` action. This simplifies the script and ensures that the tests are always run against the most appropriate PHPUnit version for the PHP version against which the tests are being run, by: * Remove the installing of PHPUnit via `setup-php`. * Remove the use of the `php-actions/phpunit` action. * Defer to the Composer installed PHPUnit version in all cases. I'm also removing the explicit ini settings for the jobs. These look like they were copied over from example code, but these values don't have any effect on the test runs in these workflows, so may as well be removed. --- .github/workflows/ci.yml | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 985add5..6656a6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,6 @@ jobs: matrix: operating-system: ['ubuntu-18.04'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0'] - phpunit-versions: ['7.5.20'] steps: - name: Checkout uses: actions/checkout@v2 @@ -20,8 +19,6 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl - ini-values: post_max_size=256M, max_execution_time=180 - tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Use Composer 1.x @@ -31,9 +28,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: PHPUnit tests - uses: php-actions/phpunit@v2 - with: - memory_limit: 256M + run: vendor/bin/phpunit moderate: name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} @@ -42,7 +37,6 @@ jobs: matrix: operating-system: ['ubuntu-latest'] php-versions: ['7.1', '7.2', '7.3'] - phpunit-versions: ['latest'] steps: - name: Checkout uses: actions/checkout@v2 @@ -52,8 +46,6 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, sodium - ini-values: post_max_size=256M, max_execution_time=180 - tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Modernize dependencies @@ -63,10 +55,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: PHPUnit tests - uses: php-actions/phpunit@v2 - timeout-minutes: 30 - with: - memory_limit: 256M + run: vendor/bin/phpunit modern: name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} @@ -75,7 +64,6 @@ jobs: matrix: operating-system: ['ubuntu-latest'] php-versions: ['7.4', '8.0'] - phpunit-versions: ['latest'] steps: - name: Checkout uses: actions/checkout@v2 @@ -85,8 +73,6 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, sodium - ini-values: post_max_size=256M, max_execution_time=180 - tools: phpunit:${{ matrix.phpunit-versions }} coverage: none - name: Modernize dependencies @@ -96,7 +82,4 @@ jobs: uses: "ramsey/composer-install@v1" - name: PHPUnit tests - uses: php-actions/phpunit@v2 - timeout-minutes: 30 - with: - memory_limit: 256M + run: vendor/bin/phpunit From 71c5eb7f3113e9dfba7825e4b73e668d128925f2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:22:26 +0200 Subject: [PATCH 6/8] GH Actions: merge "moderate" and "modern" jobs As there is now effectively no difference anymore between the `moderate` and `modern` jobs, these jobs can now be merged into one. --- .github/workflows/ci.yml | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6656a6f..fa96876 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,40 +30,13 @@ jobs: - name: PHPUnit tests run: vendor/bin/phpunit - moderate: + moderate-modern: name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }} strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['7.1', '7.2', '7.3'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, intl, sodium - coverage: none - - - name: Modernize dependencies - run: composer require --dev --no-update "phpunit/phpunit:>=4" - - - name: Install Composer dependencies - uses: "ramsey/composer-install@v1" - - - name: PHPUnit tests - run: vendor/bin/phpunit - - modern: - name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: ['ubuntu-latest'] - php-versions: ['7.4', '8.0'] + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0'] steps: - name: Checkout uses: actions/checkout@v2 From c84f7b72a495b1814ae49677c48bec40eb33d868 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:23:08 +0200 Subject: [PATCH 7/8] GH Actions: set error reporting to E_ALL The default setting for `error_reporting` used by the SetupPHP action is `error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT` and `display_errors` is set to `Off`. For the purposes of CI, I'd recommend running with `E_ALL` and `display_errors=On` to ensure **all** PHP notices are shown. Ref: https://github.com/shivammathur/setup-php/issues/469 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa96876..c3b24be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl + ini-values: error_reporting=-1, display_errors=On coverage: none - name: Use Composer 1.x @@ -46,6 +47,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, sodium + ini-values: error_reporting=-1, display_errors=On coverage: none - name: Modernize dependencies From 8100036886f7d33df819e695112a3868fd9cc0bd Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Aug 2021 02:24:37 +0200 Subject: [PATCH 8/8] GH Actions: enable testing against PHP 8.1 For now, this build is still allowed to fail. --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3b24be..8ed6e34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,10 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0'] + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + + continue-on-error: ${{ matrix.php-versions == '8.1' }} + steps: - name: Checkout uses: actions/checkout@v2 @@ -53,8 +56,15 @@ jobs: - name: Modernize dependencies run: composer require --dev --no-update "phpunit/phpunit:>=4" - - name: Install Composer dependencies + - name: Install Composer dependencies (PHP < 8.1) + if: ${{ matrix.php-versions != '8.1' }} uses: "ramsey/composer-install@v1" + - name: Install Composer dependencies - ignore-platform-reqs (PHP 8.1) + if: ${{ matrix.php-versions == '8.1' }} + uses: "ramsey/composer-install@v1" + with: + composer-options: --ignore-platform-reqs + - name: PHPUnit tests run: vendor/bin/phpunit