Skip to content

Commit 6b1adb8

Browse files
pieterocpjrfnl
andcommitted
Add github actions which should get the suite running using phar's so this version works with most/all phpunit installations
Credit to jrfnl for the suggestion and the phar test setup from Yoast Co-authored-by: jrfnl <[email protected]>
1 parent af16eb9 commit 6b1adb8

File tree

1 file changed

+137
-1
lines changed

1 file changed

+137
-1
lines changed

.github/workflows/run-tests.yml

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Tests
1+
name: Tests
22

33
on:
44
push:
@@ -99,3 +99,139 @@ jobs:
9999

100100
- name: Execute Unit Tests
101101
run: vendor/bin/phpunit
102+
103+
test-phar:
104+
runs-on: ubuntu-latest
105+
106+
strategy:
107+
matrix:
108+
include:
109+
# Test against the high/low supported PHP-PHPUnit combinations.
110+
111+
# PHPUnit 4 is only supported at the latest version.
112+
- php: '5.4'
113+
phpunit: '4'
114+
- php: '5.5'
115+
phpunit: '4'
116+
117+
# PHPUnit 5 is only supported for PHPUnit 5.7.21-latest.
118+
- php: '5.6'
119+
phpunit: '5.7.21'
120+
- php: '5.6'
121+
phpunit: '5'
122+
- php: '7.1'
123+
phpunit: '5.7.21'
124+
125+
# PHPUnit 6 is fully supported for the officially supported PHP versions.
126+
- php: '7.0'
127+
phpunit: '6.4'
128+
- php: '7.0'
129+
phpunit: '6'
130+
- php: '7.2'
131+
phpunit: '6.4'
132+
133+
# PHPUnit 7 is fully supported for the officially supported PHP versions.
134+
# Caveats:
135+
# - PHPUnit 7.0 seems to have an issue with something related to TestListeners, so using PHPUnit 7.1 instead for "low".
136+
# - PHPUnit 7 supports PHP 7.3 as of PHPUnit 7.3.0 (for our purposes).
137+
- php: '7.1'
138+
phpunit: '7.1'
139+
- php: '7.1'
140+
phpunit: '7'
141+
- php: '7.3'
142+
phpunit: '7.3'
143+
144+
# PHPUnit 8 is fully supported for the officially supported PHP versions.
145+
# Caveats:
146+
# - PHPUnit 8 supports PHP 8.0 as of PHPUnit 8.5.12 (for our purposes).
147+
# - PHPUnit 8 supports PHP 8.1 as of PHPUnit 8.5.19 (for our purposes).
148+
# - PHPUnit 8 supports PHP 8.2 as of PHPUnit 8.5.19 (for our purposes).
149+
# - PHPUnit 8 supports PHP 8.3 as of PHPUnit 8.5.19 (for our purposes).
150+
# - PHPUnit 8 supports PHP 8.4 as of PHPUnit 8.5.40 (for our purposes).
151+
- php: '7.2'
152+
phpunit: '8'
153+
- php: '8.0'
154+
phpunit: '8.5.12'
155+
- php: '8.4'
156+
phpunit: '8.5.40'
157+
- php: '8.4'
158+
phpunit: '8'
159+
160+
# PHPUnit 9 is fully supported for the officially supported PHP versions.
161+
# Caveats:
162+
# - PHPUnit 9 supports PHP 8.0 as of PHPUnit 9.3.0 (for our purposes).
163+
# - PHPUnit 9 supports PHP 8.1 as of PHPUnit 9.5.8 (for our purposes).
164+
# - PHPUnit 9 supports PHP 8.2 as of PHPUnit 9.5.8 (for our purposes).
165+
# - PHPUnit 9 supports PHP 8.3 as of PHPUnit 9.5.8 (for our purposes).
166+
# - PHPUnit 9 supports PHP 8.4 as of PHPUnit 9.6.21 (for our purposes).
167+
- php: '7.3'
168+
phpunit: '9'
169+
- php: '8.0'
170+
phpunit: '9.3.0'
171+
- php: '8.0'
172+
phpunit: '9'
173+
- php: '8.3'
174+
phpunit: '9.5.8'
175+
- php: '8.3'
176+
phpunit: '9'
177+
- php: '8.4'
178+
phpunit: '9.6.21'
179+
180+
# PHPUnit 10 is NOT supported in PHPUnit Polyfills 3.x.
181+
182+
# PHPUnit 11 is fully supported for the officially supported PHP versions.
183+
- php: '8.2'
184+
phpunit: '11'
185+
- php: '8.3'
186+
phpunit: '11.0'
187+
- php: '8.4'
188+
phpunit: '11.3.6'
189+
190+
# Experimental builds.
191+
- php: 'nightly'
192+
phpunit: '9'
193+
- php: 'nightly'
194+
phpunit: '11'
195+
196+
name: "PHAR test: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
197+
198+
continue-on-error: ${{ matrix.php == '8.4' }}
199+
200+
steps:
201+
- name: Checkout code
202+
uses: actions/checkout@v4
203+
204+
- name: Install PHP
205+
uses: shivammathur/setup-php@v2
206+
with:
207+
php-version: ${{ matrix.php }}
208+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
209+
tools: phpunit:${{ matrix.phpunit }}
210+
env:
211+
fail-fast: true
212+
213+
# Remove PHPUnit from the Composer install as we want to be sure the PHAR file is used.
214+
- name: 'Composer: remove PHPUnit'
215+
run: composer remove phpunit/phpunit --no-update --no-interaction
216+
217+
# Install dependencies and handle caching in one go.
218+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
219+
- name: Install Composer dependencies - normal
220+
if: matrix.php < '8.3'
221+
uses: "ramsey/composer-install@v3"
222+
with:
223+
composer-options: "--no-dev"
224+
# Bust the cache at least once a month - output format: YYYY-MM.
225+
custom-cache-suffix: $(date -u "+%Y-%m")
226+
227+
- name: Install Composer dependencies - ignore PHP restrictions
228+
if: matrix.php >= '8.3'
229+
uses: "ramsey/composer-install@v3"
230+
with:
231+
composer-options: "--no-dev --ignore-platform-req=php+"
232+
# Bust the cache at least once a month - output format: YYYY-MM.
233+
custom-cache-suffix: $(date -u "+%Y-%m")
234+
235+
- name: Run the unit tests
236+
if: ${{ ! matrix.coverage }}
237+
run: phpunit --no-coverage

0 commit comments

Comments
 (0)