Skip to content

Commit 9c03fd0

Browse files
authored
Merge pull request #160 from Yoast/feature/ghactions-add-phar-testing-job
GH Actions: run tests against PHPUnit PHAR files as well
2 parents 51c2415 + 7395997 commit 9c03fd0

File tree

1 file changed

+178
-1
lines changed

1 file changed

+178
-1
lines changed

.github/workflows/test.yml

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

153330
steps:

0 commit comments

Comments
 (0)