Skip to content

Commit

Permalink
GH Actions: run tests against PHPUnit PHAR files as well
Browse files Browse the repository at this point in the history
PHPUnit 8.5.38 and 9.6.19 contain a change in the PHAR build process, which means that classes external to PHPUnit are now prefixed differently, which breaks one polyfill.

As things were, such issues would previously not be caught by CI.

This commit adds a new job to the test workflow, which will run the tests against a range of PHP-PHPUnit combinations using the PHPUnit Phar to ensure any such issues will be automatically caught in the future.
  • Loading branch information
jrfnl committed Apr 5, 2024
1 parent 3380dcc commit e5f85a0
Showing 1 changed file with 138 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,141 @@ jobs:
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

test-phar:
runs-on: ubuntu-latest

strategy:
matrix:
include:
# Test against the high/low supported PHP-PHPUnit combinations.
# PHPUnit 4 is only supported at the latest version.
- php: '5.4'
phpunit: '4'
- php: '5.5'
phpunit: '4'
- php: '5.6'
phpunit: '4'

# PHPUnit 5 is only supported for PHPUnit 5.7.21-latest.
- php: '5.6'
phpunit: '5.7.21'
- php: '5.6'
phpunit: '5'
- php: '7.1'
phpunit: '5.7.21'
- php: '7.1'
phpunit: '5'

# PHPUnit 6 is fully supported for the officially supported PHP versions.
- php: '7.0'
phpunit: '6.0'
- php: '7.0'
phpunit: '6'
- php: '7.2'
phpunit: '6.0'
- php: '7.2'
phpunit: '6'

# PHPUnit 7 is fully supported for the officially supported PHP versions.
- php: '7.1'
phpunit: '7.0'
- php: '7.1'
phpunit: '7'
- php: '7.3'
phpunit: '7.0'
- php: '7.3'
phpunit: '7'

# PHPUnit 8 is fully supported for the officially supported PHP versions.
# Caveat PHPUnit 8 supports PHP 8 as of PHPUnit 8.....
- php: '7.2'
phpunit: '8.0'
- php: '7.2'
phpunit: '8'
- php: '7.4'
phpunit: '8.0'
- php: '7.4'
phpunit: '8'
- php: '8.0'
phpunit: '8.0'
- php: '8.0'
phpunit: '8'
- php: '8.3'
phpunit: '8.0'
- php: '8.3'
phpunit: '8'

# PHPUnit 9 is fully supported for the officially supported PHP versions.
# Caveat PHPUnit 9 supports PHP 8 as of PHPUnit 9.....
- php: '7.3'
phpunit: '9.0'
- php: '7.3'
phpunit: '9'
- php: '8.0'
phpunit: '9.0'
- php: '8.0'
phpunit: '9'
- php: '8.1'
phpunit: '9.0'
- php: '8.1'
phpunit: '9'
- php: '8.2'
phpunit: '9.0'
- php: '8.2'
phpunit: '9'
- php: '8.3'
phpunit: '9.0'
- php: '8.3'
phpunit: '9'

# Experimental builds.
- php: '8.4'
phpunit: '9'

name: "Tests with PHAR: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"

continue-on-error: ${{ matrix.php == '8.4' }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
tools: phpunit:${{ matrix.phpunit }}
coverage: none
env:
fail-fast: true

# YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package.
- name: 'Composer: remove YoastCS'
run: composer remove --dev yoast/yoastcs --no-update --no-interaction

# Remove PHPUnit from the Composer install as we want to be sure the PHAR file is used.
- name: 'Composer: remove PHPUnit'
run: composer remove phpunit/phpunit --no-update --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: matrix.php < '8.3'
uses: "ramsey/composer-install@v3"
with:
composer-options: "--no-dev"
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Install Composer dependencies - ignore PHP restrictions
if: matrix.php >= '8.3'
uses: "ramsey/composer-install@v3"
with:
composer-options: "--no-dev --ignore-platform-req=php+"
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Run the unit tests
run: phpunit --no-coverage

0 comments on commit e5f85a0

Please sign in to comment.