Skip to content

Commit 2650c4b

Browse files
committed
Add coverage input to reusable-testing
1 parent dd23312 commit 2650c4b

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

.github/workflows/reusable-testing.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
type: string
1414
required: false
1515
default: '4.9'
16+
with-coverage:
17+
description: 'Include coverages tests.'
18+
type: bool
19+
required: false
20+
default: true
1621

1722
# Cancels all previous workflow runs for the same branch that have not yet completed.
1823
concurrency:
@@ -233,7 +238,7 @@ jobs:
233238
unit: #-----------------------------------------------------------------------
234239
needs: prepare-unit
235240
if: ${{ needs.prepare-unit.outputs.matrix != '' }}
236-
name: Unit test / PHP ${{ matrix.php }}${{ matrix.coverage && ' (with coverage)' || '' }}
241+
name: Unit test / PHP ${{ matrix.php }}${{ ( matrix.coverage && inputs.with-coverage ) && ' (with coverage)' || '' }}
237242
strategy:
238243
fail-fast: false
239244
matrix: ${{ fromJson(needs.prepare-unit.outputs.matrix) }}
@@ -250,7 +255,7 @@ jobs:
250255
with:
251256
php-version: '${{ matrix.php }}'
252257
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
253-
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
258+
coverage: ${{ ( matrix.coverage && inputs.with-coverage ) && 'xdebug' || 'none' }}
254259
tools: composer,cs2pr
255260
env:
256261
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -279,14 +284,14 @@ jobs:
279284

280285
- name: Run PHPUnit
281286
run: |
282-
if [[ ${{ matrix.coverage == true }} == true ]]; then
287+
if [[ ${{ matrix.coverage == true && inputs.with-coverage == true }} == true ]]; then
283288
composer phpunit -- --coverage-clover build/logs/unit-coverage.xml
284289
else
285290
composer phpunit
286291
fi
287292
288293
- name: Upload code coverage report
289-
if: ${{ matrix.coverage }}
294+
if: ${{ matrix.coverage && inputs.with-coverage }}
290295
uses: codecov/codecov-action@v5.4.3
291296
with:
292297
directory: build/logs
@@ -348,7 +353,7 @@ jobs:
348353
# Disable error reporting for Behat tests on PHP 8.4+, as long as Behat is not upgraded to a newer version.
349354
ini-values: ${{ matrix.php != '8.4' && matrix.php != 'nightly' && 'zend.assertions=1, error_reporting=-1, display_errors=On' || '' }}
350355
extensions: gd, imagick, mysql, zip
351-
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
356+
coverage: ${{ ( matrix.coverage && inputs.with-coverage ) && 'xdebug' || 'none' }}
352357
tools: composer
353358
env:
354359
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -406,7 +411,7 @@ jobs:
406411
WP_VERSION: '${{ matrix.wp }}'
407412
WP_CLI_TEST_DBTYPE: ${{ matrix.dbtype || 'mysql' }}
408413
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
409-
WP_CLI_TEST_COVERAGE: ${{ matrix.coverage }}
414+
WP_CLI_TEST_COVERAGE: ${{ matrix.coverage && inputs.with-coverage }}
410415
run: |
411416
ARGS=()
412417
@@ -425,13 +430,13 @@ jobs:
425430
426431
- name: Retrieve list of coverage files
427432
id: coverage_files
428-
if: ${{ matrix.coverage }}
433+
if: ${{ matrix.coverage && inputs.with-coverage }}
429434
run: |
430435
FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
431436
echo "files=$FILES" >> $GITHUB_OUTPUT
432437
433438
- name: Upload code coverage report
434-
if: ${{ matrix.coverage }}
439+
if: ${{ matrix.coverage && inputs.with-coverage }}
435440
uses: codecov/codecov-action@v5.4.3
436441
with:
437442
# Because somehow providing `directory: build/logs` doesn't work for these files

0 commit comments

Comments
 (0)