@@ -20,64 +20,92 @@ jobs:
2020
2121 strategy :
2222 matrix :
23- php : ['5.4', '5.5', '5. 6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
23+ php : ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
2424 phpunit : ['auto']
25+ coverage : [true]
2526 experimental : [false]
2627
2728 include :
2829 # Test against a version on the low-end of the PHPUnit versions supported for each PHP version.
29- # On PHP 5.4 and 5.5, only PHPUnit 4.x is supported and the lowest and the
30- # highest supported version would be the same.
3130 # Using the Composer `--prefer-lowest` option is, unfortunately, not viable, as
32- # PHPUnit 4.8.36 doesn't have proper PHP restrictions, which means that it
33- # would always be installed as "low", which would break the builds for PHP 7.2+.
31+ # it would result PHP 5.6 - 7.4 all using PHPUnit 5.7.21, which is not the intention.
32+ # It also would run into trouble with PHP 8.5.12 being used on PHP 8.0+, while the
33+ # 8.5.12 release still contained a bug which makes it incompatible with PHP 8.1+,
34+ # even though it officially allows for it..
3435 - php : ' 5.6'
3536 phpunit : ' 5.7.21'
37+ coverage : true
3638 experimental : false
3739 - php : ' 7.0'
3840 phpunit : ' 5.7.27'
41+ coverage : true
3942 experimental : false
4043 - php : ' 7.1'
4144 phpunit : ' 5.7.21'
45+ coverage : true
4246 experimental : false
4347 - php : ' 7.2'
4448 phpunit : ' 6.3.1'
49+ coverage : true
4550 experimental : false
4651 - php : ' 7.3'
4752 phpunit : ' 7.2.7'
53+ coverage : true
4854 experimental : false
4955 - php : ' 7.4'
5056 phpunit : ' 8.1.6'
57+ coverage : true
5158 experimental : false
5259 - php : ' 8.0'
5360 phpunit : ' 8.5.16'
61+ # PHPUnit 8.x does not support code coverage on PHP 8.x.
62+ coverage : false
5463 experimental : false
5564 - php : ' 8.0'
5665 phpunit : ' 9.3.0'
66+ coverage : true
5767 experimental : false
5868 - php : ' 8.1'
5969 phpunit : ' 9.3.0'
70+ coverage : true
71+ experimental : false
72+ - php : ' 8.1'
73+ # Specifically set at 10.0.12 minimum to prevent needing a toggle in the tests for something
74+ # related to the ArrayIsList polyfill, but not necessarily relevant.
75+ phpunit : ' 10.0.12'
76+ coverage : true
6077 experimental : false
6178 - php : ' 8.2'
6279 phpunit : ' 9.3.0'
80+ coverage : true
81+ experimental : false
82+ - php : ' 8.2'
83+ phpunit : ' 10.1.0'
84+ coverage : true
6385 experimental : false
6486
6587 # Experimental builds.
6688 - php : ' 8.3'
67- phpunit : ' auto' # PHPUnit 9.x.
89+ phpunit : ' ^9.6'
90+ coverage : false
6891 experimental : true
69-
70- - php : ' 8.1 '
71- phpunit : ' ^10.0 '
92+ - php : ' 8.3 '
93+ phpunit : ' auto ' # PHPUnit 10.x.
94+ coverage : false
7295 experimental : true
96+
7397 - php : ' 8.2'
74- phpunit : ' ^10.0'
98+ phpunit : ' dev-main'
99+ coverage : false
75100 experimental : true
76101
77102 name : " Tests: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
78103
79104 continue-on-error : ${{ matrix.experimental }}
80105
106+ env :
107+ EXTRA_PHPUNIT_CLIARGS : ' --fail-on-deprecation --fail-on-notice'
108+
81109 steps :
82110 - name : Checkout code
83111 uses : actions/checkout@v3
87115 with :
88116 php-version : ${{ matrix.php }}
89117 ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
90- coverage : none
118+ coverage : ${{ matrix.coverage == true && 'xdebug' || ' none' }}
91119
92120 - name : ' Composer: set PHPUnit version for tests'
93121 if : ${{ matrix.phpunit != 'auto' }}
@@ -110,11 +138,68 @@ jobs:
110138 # Bust the cache at least once a month - output format: YYYY-MM.
111139 custom-cache-suffix : $(date -u "+%Y-%m")
112140
113- - name : Run the unit tests
114- if : ${{ matrix.phpunit != '^10.0' }}
141+ - name : Grab PHPUnit version
142+ id : phpunit_version
143+ run : echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
144+
145+ - name : " DEBUG: Show grabbed version"
146+ run : echo ${{ steps.phpunit_version.outputs.VERSION }}
147+
148+ - name : " Run the unit tests (PHPUnit < 10)"
149+ if : ${{ matrix.coverage == false && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
115150 run : composer test
116151
117- - name : Trial run the unit tests against PHPUnit 10.0
118- if : ${{ matrix.phpunit == '^10.0' }}
152+ - name : " Run the unit tests with code coverage (PHPUnit < 10)"
153+ if : ${{ matrix.coverage == true && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
154+ run : composer coverage
155+
156+ # Migrate PHPUnit configuration to deal with changes in the coverage/source setting across PHPUnit 10.x
157+ # versions as otherwise the warning about these would fail the build (which to me, feels like a bug).
158+ - name : " Migrate configuration (PHPUnit 10.0+)"
119159 continue-on-error : true
120- run : composer test
160+ if : ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) && steps.phpunit_version.outputs.VERSION != '10.0' }}
161+ run : vendor/bin/phpunit -c phpunit10.xml.dist --migrate-configuration
162+
163+ - name : " Run the unit tests (PHPUnit 10.0+)"
164+ if : ${{ matrix.coverage == false && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
165+ # Don't fail the build on a test run failure against a future PHPUnit version.
166+ continue-on-error : ${{ matrix.phpunit == 'dev-main' }}
167+ run : composer test10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}
168+
169+ - name : " Run the unit tests with code coverage (PHPUnit 10.0+)"
170+ if : ${{ matrix.coverage == true && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
171+ # Don't fail the build on a test run failure against a future PHPUnit version.
172+ continue-on-error : ${{ matrix.phpunit == 'dev-main' }}
173+ run : composer coverage10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}
174+
175+ # PHP Coveralls doesn't fully support PHP 8.x yet, so switch the PHP version.
176+ - name : Switch to PHP 7.4
177+ if : ${{ success() && matrix.coverage == true && startsWith( matrix.php, '8' ) }}
178+ uses : shivammathur/setup-php@v2
179+ with :
180+ php-version : 7.4
181+ coverage : none
182+
183+ # Global install is used to prevent a conflict with the local composer.lock in PHP 8.0+.
184+ - name : Install Coveralls
185+ if : ${{ success() && matrix.coverage == true }}
186+ run : composer global require php-coveralls/php-coveralls:"^2.5.3" --no-interaction
187+
188+ - name : Upload coverage results to Coveralls
189+ if : ${{ success() && matrix.coverage == true }}
190+ env :
191+ COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_TOKEN }}
192+ COVERALLS_PARALLEL : true
193+ COVERALLS_FLAG_NAME : php-${{ matrix.php }}-phpunit-${{ matrix.phpunit }}
194+ run : php-coveralls -v -x build/logs/clover.xml
195+
196+ coveralls-finish :
197+ needs : test
198+ runs-on : ubuntu-latest
199+
200+ steps :
201+ - name : Coveralls Finished
202+ uses : coverallsapp/github-action@v2
203+ with :
204+ github-token : ${{ secrets.COVERALLS_TOKEN }}
205+ parallel-finished : true
0 commit comments