3333 MATRIX=$(cat << EOF
3434 {
3535 "include": [
36+ {
37+ "php": "5.6",
38+ "wp": "3.7",
39+ "mysql": "5.6"
40+ },
41+ {
42+ "php": "5.6",
43+ "wp": "6.2",
44+ "mysql": "8.0"
45+ },
3646 {
3747 "php": "7.2",
3848 "wp": "latest",
@@ -93,6 +103,17 @@ jobs:
93103 "wp": "latest",
94104 "dbtype": "sqlite"
95105 },
106+ {
107+ "php": "8.3",
108+ "wp": "latest",
109+ "mysql": "8.0",
110+ "coverage": true
111+ },
112+ {
113+ "php": "8.3",
114+ "wp": "latest",
115+ "dbtype": "sqlite"
116+ },
96117 {
97118 "php": "7.2",
98119 "wp": "trunk",
@@ -138,26 +159,11 @@ jobs:
138159 "wp": "trunk",
139160 "mysql": "8.0"
140161 },
141- {
142- "php": "5.6",
143- "wp": "3.7",
144- "mysql": "5.6"
145- },
146- {
147- "php": "5.6",
148- "wp": "6.2",
149- "mysql": "8.0"
150- },
151162 {
152163 "php": "8.3",
153164 "wp": "trunk",
154165 "mysql": "8.0"
155166 },
156- {
157- "php": "8.2",
158- "wp": "trunk",
159- "dbtype": "sqlite"
160- },
161167 {
162168 "php": "8.3",
163169 "wp": "trunk",
@@ -209,7 +215,7 @@ jobs:
209215 id : set-matrix
210216 run : |
211217 if [[ $FILE_EXISTS == 'true' ]]; then
212- echo "matrix=$(jq -c '.include |= map(with_entries(select(.key == "php"))) | .include |= map(select(.php >= "${{ inputs.minimum-php }}")) | .include |= unique_by(.php)' <<< $BASE_MATRIX)" >> $GITHUB_OUTPUT
218+ echo "matrix=$(jq -c '.include |= map(with_entries(select(.key == "php", .key == "coverage" ))) | .include |= map(select(.php >= "${{ inputs.minimum-php }}")) | .include |= unique_by(.php)' <<< $BASE_MATRIX)" >> $GITHUB_OUTPUT
213219 else
214220 echo "matrix=" >> $GITHUB_OUTPUT
215221 fi
@@ -220,7 +226,7 @@ jobs:
220226 unit : # -----------------------------------------------------------------------
221227 needs : prepare-unit
222228 if : ${{ needs.prepare-unit.outputs.matrix != '' }}
223- name : Unit test / PHP ${{ matrix.php }}
229+ name : Unit test / PHP ${{ matrix.php }}${{ matrix.coverage && ' (with coverage)' || '' }}
224230 strategy :
225231 fail-fast : false
226232 matrix : ${{ fromJson(needs.prepare-unit.outputs.matrix) }}
@@ -237,7 +243,7 @@ jobs:
237243 with :
238244 php-version : ' ${{ matrix.php }}'
239245 ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
240- coverage : none
246+ coverage : ${{ matrix.coverage && 'xdebug' || ' none' }}
241247 tools : composer,cs2pr
242248 env :
243249 COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -265,7 +271,20 @@ jobs:
265271 run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
266272
267273 - name : Run PHPUnit
268- run : composer phpunit
274+ run : |
275+ if [[ ${{ matrix.coverage == true }} == true ]]; then
276+ composer phpunit -- --coverage-clover build/logs/unit-coverage.xml
277+ else
278+ composer phpunit
279+ fi
280+
281+ - name : Upload code coverage report
282+ if : ${{ matrix.coverage }}
283+ uses : codecov/codecov-action@v5.3.1
284+ with :
285+ directory : build/logs
286+ flags : unit
287+ token : ${{ secrets.CODECOV_TOKEN }}
269288
270289 prepare-functional : # ---------------------------------------------------------
271290 name : Prepare matrix for functional tests
@@ -298,7 +317,7 @@ jobs:
298317 functional : # -----------------------------------------------------------------
299318 needs : prepare-functional
300319 if : ${{ needs.prepare-functional.outputs.matrix != '' }}
301- name : Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with ${{ matrix.dbtype != 'sqlite' && format('MySQL {0}', matrix.mysql) || 'SQLite' }}
320+ name : Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with ${{ matrix.dbtype != 'sqlite' && format('MySQL {0}', matrix.mysql) || 'SQLite' }}${{ matrix.coverage && ' (with coverage)' || '' }}
302321 strategy :
303322 fail-fast : false
304323 matrix : ${{ fromJson(needs.prepare-functional.outputs.matrix) }}
@@ -322,7 +341,7 @@ jobs:
322341 # Disable error reporting for Behat tests on PHP 8.4+, as long as Behat is not upgraded to a newer version.
323342 ini-values : ${{ matrix.php != '8.4' && matrix.php != 'nightly' && 'zend.assertions=1, error_reporting=-1, display_errors=On' || '' }}
324343 extensions : gd, imagick, mysql, zip
325- coverage : none
344+ coverage : ${{ matrix.coverage && 'xdebug' || ' none' }}
326345 tools : composer
327346 env :
328347 COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -380,4 +399,21 @@ jobs:
380399 WP_VERSION : ' ${{ matrix.wp }}'
381400 WP_CLI_TEST_DBTYPE : ${{ matrix.dbtype || 'mysql' }}
382401 WP_CLI_TEST_DBSOCKET : ' ${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
402+ WP_CLI_TEST_COVERAGE : ${{ matrix.coverage }}
383403 run : composer behat || composer behat-rerun
404+
405+ - name : Retrieve list of coverage files
406+ id : coverage_files
407+ if : ${{ matrix.coverage }}
408+ run : |
409+ FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
410+ echo "files=$FILES" >> $GITHUB_OUTPUT
411+
412+ - name : Upload code coverage report
413+ if : ${{ matrix.coverage }}
414+ uses : codecov/codecov-action@v5.3.1
415+ with :
416+ # Because somehow providing `directory: build/logs` doesn't work for these files
417+ files : ${{ steps.coverage_files.outputs.files }}
418+ flags : feature
419+ token : ${{ secrets.CODECOV_TOKEN }}
0 commit comments