Skip to content

Commit 1c48475

Browse files
committed
GH Actions: run tests against PHPUnit PHAR files as well
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. The new test workflow will (very) selectively also upload code coverage to safeguard that the PHAR-file specific lines in the code base remain covered by tests as well.
1 parent 51c2415 commit 1c48475

File tree

1 file changed

+174
-1
lines changed

1 file changed

+174
-1
lines changed

.github/workflows/test.yml

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,181 @@ jobs:
146146
flag-name: php-${{ matrix.php }}-phpunit-${{ matrix.phpunit }}
147147
parallel: true
148148

149+
test-phar:
150+
runs-on: ubuntu-latest
151+
152+
strategy:
153+
matrix:
154+
include:
155+
# Test against the high/low supported PHP-PHPUnit combinations.
156+
# Code coverage is only run against the high/high PHP-PHPUnit combinations.
157+
# This should be sufficient to record the coverage for the PHAR specific code.
158+
159+
# PHPUnit 4 is only supported at the latest version.
160+
- php: '5.4'
161+
phpunit: '4'
162+
- php: '5.5'
163+
phpunit: '4'
164+
- php: '5.6'
165+
phpunit: '4'
166+
coverage: true
167+
168+
# PHPUnit 5 is only supported for PHPUnit 5.7.21-latest.
169+
- php: '5.6'
170+
phpunit: '5.7.21'
171+
- php: '5.6'
172+
phpunit: '5'
173+
- php: '7.1'
174+
phpunit: '5.7.21'
175+
- php: '7.1'
176+
phpunit: '5'
177+
coverage: true
178+
179+
# PHPUnit 6 is fully supported for the officially supported PHP versions.
180+
- php: '7.0'
181+
phpunit: '6.0'
182+
- php: '7.0'
183+
phpunit: '6'
184+
- php: '7.2'
185+
phpunit: '6.0'
186+
- php: '7.2'
187+
phpunit: '6'
188+
coverage: true
189+
190+
# PHPUnit 7 is fully supported for the officially supported PHP versions.
191+
# Caveats:
192+
# - PHPUnit 7.0 seems to have an issue with something related to TestListeners, so using PHPUnit 7.1 instead for "low".
193+
# - PHPUnit 7 supports PHP 7.3 as of PHPUnit 7.3.0 (for our purposes).
194+
- php: '7.1'
195+
phpunit: '7.1'
196+
- php: '7.1'
197+
phpunit: '7'
198+
- php: '7.3'
199+
phpunit: '7.3'
200+
- php: '7.3'
201+
phpunit: '7'
202+
coverage: true
203+
204+
# PHPUnit 8 is fully supported for the officially supported PHP versions.
205+
# Caveats:
206+
# - PHPUnit 8 supports PHP 8.0 as of PHPUnit 8.5.12 (for our purposes).
207+
# - PHPUnit 8 supports PHP 8.1 as of PHPUnit 8.5.19 (for our purposes).
208+
# - PHPUnit 8 supports PHP 8.2 as of PHPUnit 8.5.19 (for our purposes).
209+
# - PHPUnit 8 supports PHP 8.3 as of PHPUnit 8.5.19 (for our purposes).
210+
# - PHPUnit 8 does not support running code coverage on PHP 8.0 or higher.
211+
- php: '7.2'
212+
phpunit: '8.0'
213+
- php: '7.2'
214+
phpunit: '8'
215+
- php: '7.4'
216+
phpunit: '8.0'
217+
- php: '7.4'
218+
phpunit: '8'
219+
coverage: true
220+
- php: '8.0'
221+
phpunit: '8.5.12'
222+
- php: '8.0'
223+
phpunit: '8'
224+
- php: '8.3'
225+
phpunit: '8.5.19'
226+
- php: '8.3'
227+
phpunit: '8'
228+
229+
# PHPUnit 9 is fully supported for the officially supported PHP versions.
230+
# Caveats:
231+
# - PHPUnit 9 supports PHP 8.0 as of PHPUnit 9.3.0 (for our purposes).
232+
# - PHPUnit 9 supports PHP 8.1 as of PHPUnit 9.5.8 (for our purposes).
233+
# - PHPUnit 9 supports PHP 8.2 as of PHPUnit 9.5.8 (for our purposes).
234+
# - PHPUnit 9 supports PHP 8.3 as of PHPUnit 9.5.8 (for our purposes).
235+
- php: '7.3'
236+
phpunit: '9.0'
237+
- php: '7.3'
238+
phpunit: '9'
239+
- php: '8.0'
240+
phpunit: '9.3.0'
241+
- php: '8.0'
242+
phpunit: '9'
243+
- php: '8.1'
244+
phpunit: '9.5.8'
245+
- php: '8.1'
246+
phpunit: '9'
247+
- php: '8.2'
248+
phpunit: '9.5.8'
249+
- php: '8.2'
250+
phpunit: '9'
251+
- php: '8.3'
252+
phpunit: '9.5.8'
253+
- php: '8.3'
254+
phpunit: '9'
255+
coverage: true
256+
257+
# Experimental builds.
258+
- php: '8.4'
259+
phpunit: '9'
260+
261+
name: "PHAR test: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
262+
263+
continue-on-error: ${{ matrix.php == '8.4' }}
264+
265+
steps:
266+
- name: Checkout code
267+
uses: actions/checkout@v4
268+
269+
- name: Install PHP
270+
uses: shivammathur/setup-php@v2
271+
with:
272+
php-version: ${{ matrix.php }}
273+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
274+
tools: phpunit:${{ matrix.phpunit }}
275+
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
276+
env:
277+
fail-fast: true
278+
279+
# YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package.
280+
- name: 'Composer: remove YoastCS'
281+
run: composer remove --dev yoast/yoastcs --no-update --no-interaction
282+
283+
# Remove PHPUnit from the Composer install as we want to be sure the PHAR file is used.
284+
- name: 'Composer: remove PHPUnit'
285+
run: composer remove phpunit/phpunit --no-update --no-interaction
286+
287+
# Install dependencies and handle caching in one go.
288+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
289+
- name: Install Composer dependencies - normal
290+
if: matrix.php < '8.3'
291+
uses: "ramsey/composer-install@v3"
292+
with:
293+
composer-options: "--no-dev"
294+
# Bust the cache at least once a month - output format: YYYY-MM.
295+
custom-cache-suffix: $(date -u "+%Y-%m")
296+
297+
- name: Install Composer dependencies - ignore PHP restrictions
298+
if: matrix.php >= '8.3'
299+
uses: "ramsey/composer-install@v3"
300+
with:
301+
composer-options: "--no-dev --ignore-platform-req=php+"
302+
# Bust the cache at least once a month - output format: YYYY-MM.
303+
custom-cache-suffix: $(date -u "+%Y-%m")
304+
305+
- name: Run the unit tests
306+
if: ${{ ! matrix.coverage }}
307+
run: phpunit --no-coverage
308+
309+
- name: Run the unit tests with code coverage
310+
if: ${{ matrix.coverage }}
311+
run: phpunit
312+
313+
- name: Upload coverage results to Coveralls
314+
if: ${{ success() && matrix.coverage == true }}
315+
uses: coverallsapp/github-action@v2
316+
with:
317+
file: build/logs/clover.xml
318+
format: clover
319+
flag-name: php-${{ matrix.php }}-phpunit-phar-${{ matrix.phpunit }}
320+
parallel: true
321+
149322
coveralls-finish:
150-
needs: test
323+
needs: [test, test-phar]
151324
runs-on: ubuntu-latest
152325

153326
steps:

0 commit comments

Comments
 (0)