From 5ac3d532a8a413219c6961d00c0915ed5fa67988 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 23 Feb 2024 07:16:22 +0100 Subject: [PATCH] CI: update for PHPUnit 11.x support As the PHPUnit Polyfills, as of now, will officially support PHPUnit 11.x, with the exception of the TestListeners, the GH Actions workflow should be updated to reflect this. This commit: * Move the PHP 8.2/8.3 "high" (auto) PHPUnit version builds out of the matrix and run these without code coverage (see below). * Add builds for PHP 8.2 and 8.3 against low PHPUnit 11 versions for the Composer based tests. * Add builds for PHP 8.2 and 8.3 against high/low PHPUnit 11 for the PHAR based tests. * Add an extra experimental build in both test workflows against PHP "nightly" to ensure both PHPUnit 9.x, 10.x, as well as PHPUnit 11.x are tested with PHP 8.4. * Updates the experimental build against "future" PHPUnit to always run against the latest official PHP release. **Regarding PHPUnit 11 and running code coverage**: Since PHPUnit 10, PHPUnit does not distinguish between PHPUnit and PHP deprecation notices anymore. This means that when `failOnDeprecation` is enabled (as is done for this library to be ready early for new PHP versions), a test run will also fail if there are PHPUnit native deprecation notices. Now PHPUnit 11.2 deprecated the use of `#[CoversClass]` for traits and introduced a `#[CoversTrait]` attribute to replace this. However, it is currently impossible to action this deprecation notice in a PHPUnit cross-version compatible manner. This has been reported upstream and until that issue has been addressed in PHPUnit itself, the net-effect of this issue is that we can run the tests with code coverage on PHPUnit < 11.2, but not on PHPUnit 11.2 or higher. Ref: * https://github.com/sebastianbergmann/phpunit/issues/5937 --- .github/workflows/test.yml | 62 ++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5185516..c676e9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,12 +21,28 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] phpunit: ['auto'] coverage: [true] experimental: [false] include: + # By rights, these two PHP versions should be in the base matrix, but, + # for now, they can't be as we can't run these builds with code coverage ON. + # + # Running code coverage on PHPUnit 11.2 and higher is blocked + # as it will fail the build on a PHPUnit native deprecation related to + # the use of `#[CoversClass]` instead of `#[CoversTrait]`. + # @link https://github.com/sebastianbergmann/phpunit/issues/5937 + - php: '8.2' + phpunit: 'auto' + coverage: false + experimental: false + - php: '8.3' + phpunit: 'auto' + coverage: false + experimental: false + # Test against a version on the low-end of the PHPUnit versions supported for each PHP version. # Using the Composer `--prefer-lowest` option is, unfortunately, not viable, as # it would result PHP 7.0 - 7.4 all using PHPUnit 6.4.4, which is not the intention. @@ -82,10 +98,18 @@ jobs: phpunit: '9.3.0' coverage: true experimental: false + - php: '8.2' + phpunit: '~11.1.0' + coverage: true + experimental: false - php: '8.3' phpunit: '10.1.0' coverage: true experimental: false + - php: '8.3' + phpunit: '11.0.0' + coverage: true + experimental: false # Experimental builds. - php: 'nightly' @@ -93,12 +117,16 @@ jobs: coverage: false experimental: true - php: 'nightly' - phpunit: 'auto' # PHPUnit 10.x. + phpunit: '^10.5' + coverage: false + experimental: true + - php: 'nightly' + phpunit: 'auto' # PHPUnit 11.x. coverage: false experimental: true - - php: '8.3' - phpunit: 'dev-main' # PHPUnit 11.x + - php: 'latest' + phpunit: 'dev-main' # PHPUnit 11.x/12.x. coverage: false experimental: true @@ -165,7 +193,7 @@ jobs: echo 'NEEDS_MIGRATION=true' >> $GITHUB_OUTPUT elif [ "${{ steps.phpunit_version.outputs.VERSION }}" == "10.0" ]; then echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT - elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then + elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) || startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT echo 'NEEDS_MIGRATION=true' >> $GITHUB_OUTPUT else @@ -301,11 +329,33 @@ jobs: phpunit: '10' coverage: true + # PHPUnit 11 is fully supported for the officially supported PHP versions. + # + # Running code coverage on PHPUnit 11.2 and higher, however, is blocked for now + # as it will fail the build on a PHPUnit native deprecation related to + # the use of `#[CoversClass]` instead of `#[CoversTrait]`. + # @link https://github.com/sebastianbergmann/phpunit/issues/5937 + - php: '8.2' + phpunit: '11.0' + coverage: true + - php: '8.2' + phpunit: '11' + - php: '8.3' + phpunit: '11.0' + # Temporary build to run code coverage on the highest PHPUnit 11 version on which we still can. + - php: '8.3' + phpunit: '11.1' + coverage: true + - php: '8.3' + phpunit: '11' + # Experimental builds. - php: 'nightly' phpunit: '9' - php: 'nightly' phpunit: '10' + - php: 'nightly' + phpunit: '11' name: "PHAR test: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}" @@ -371,7 +421,7 @@ jobs: run: | if [ "${{ steps.phpunit_version.outputs.VERSION }}" == "10.0" ]; then echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT - elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then + elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) || startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT echo 'NEEDS_MIGRATION=true' >> $GITHUB_OUTPUT else