Skip to content

AssertIgnoringLineEndings: fix compatibility with PHPUnit 8/9/10 PHAR… #634

AssertIgnoringLineEndings: fix compatibility with PHPUnit 8/9/10 PHAR…

AssertIgnoringLineEndings: fix compatibility with PHPUnit 8/9/10 PHAR… #634

Workflow file for this run

name: Test
on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
#### TEST STAGE ####
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
phpunit: ['auto']
coverage: [true]
experimental: [false]
include:
# 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 5.6 - 7.4 all using PHPUnit 5.7.21, which is not the intention.
# It also would run into trouble with PHP 8.5.12 being used on PHP 8.0+, while the
# 8.5.12 release still contained a bug which makes it incompatible with PHP 8.1+,
# even though it officially allows for it..
- php: '5.6'
phpunit: '5.7.21'
coverage: true
experimental: false
- php: '7.0'
phpunit: '5.7.27'
coverage: true
experimental: false
- php: '7.1'
phpunit: '5.7.21'
coverage: true
experimental: false
- php: '7.2'
phpunit: '6.3.1'
coverage: true
experimental: false
- php: '7.3'
phpunit: '7.2.7'
coverage: true
experimental: false
- php: '7.4'
phpunit: '8.1.6'
coverage: true
experimental: false
- php: '7.4'
# Specifically set at 9.6.10 to test functioning on 9.x before the 9.6.11 assertObject*() backports came in.
phpunit: '9.6.10'
coverage: true
experimental: false
- php: '8.0'
phpunit: '8.5.16'
# PHPUnit 8.x does not support code coverage on PHP 8.x.
coverage: false
experimental: false
- php: '8.0'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.1'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.1'
# Specifically set at 10.0.12 minimum to prevent needing a toggle in the tests for something
# related to the ArrayIsList polyfill, but not necessarily relevant.
phpunit: '10.0.12'
coverage: true
experimental: false
- php: '8.2'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.3'
phpunit: '10.1.0'
coverage: true
experimental: false
# Experimental builds.
- php: '8.4'
phpunit: '^9.6'
coverage: false
experimental: true
- php: '8.4'
phpunit: 'auto' # PHPUnit 10.x.
coverage: false
experimental: true
- php: '8.3'
phpunit: 'dev-main'
coverage: false
experimental: true
name: "Tests: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
continue-on-error: ${{ matrix.experimental }}
env:
EXTRA_PHPUNIT_CLIARGS: '--fail-on-deprecation --fail-on-notice'
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
coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }}
# 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
- name: 'Composer: set PHPUnit version for tests'
if: ${{ matrix.phpunit != 'auto' }}
run: composer require --no-update phpunit/phpunit:"${{ matrix.phpunit }}" --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.4'
uses: "ramsey/composer-install@v3"
with:
# 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.4'
uses: "ramsey/composer-install@v3"
with:
composer-options: --ignore-platform-req=php+
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- 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
- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
- name: "Run the unit tests (PHPUnit < 10)"
if: ${{ matrix.coverage == false && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer test
- name: "Run the unit tests with code coverage (PHPUnit < 10)"
if: ${{ matrix.coverage == true && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer coverage
# Migrate PHPUnit configuration to deal with changes in the coverage/source setting across PHPUnit 10.x
# versions as otherwise the warning about these would fail the build (which to me, feels like a bug).
- name: "Migrate configuration (PHPUnit 10.0+)"
continue-on-error: true
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) && steps.phpunit_version.outputs.VERSION != '10.0' }}
run: vendor/bin/phpunit -c phpunit10.xml.dist --migrate-configuration
- name: "Run the unit tests (PHPUnit 10.0+)"
if: ${{ matrix.coverage == false && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
# Don't fail the build on a test run failure against a future PHPUnit version.
continue-on-error: ${{ matrix.phpunit == 'dev-main' }}
run: composer test10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}
- name: "Run the unit tests with code coverage (PHPUnit 10.0+)"
if: ${{ matrix.coverage == true && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
# Don't fail the build on a test run failure against a future PHPUnit version.
continue-on-error: ${{ matrix.phpunit == 'dev-main' }}
run: composer coverage10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}
- name: Upload coverage results to Coveralls
if: ${{ success() && matrix.coverage == true }}
uses: coverallsapp/github-action@v2
with:
file: build/logs/clover.xml
format: clover
flag-name: php-${{ matrix.php }}-phpunit-${{ matrix.phpunit }}
parallel: true
coveralls-finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true