Skip to content

Commit

Permalink
Generate both reports at the same time.
Browse files Browse the repository at this point in the history
  • Loading branch information
desrosj committed Oct 24, 2024
1 parent 7a9f882 commit 0780462
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/reusable-phpunit-tests-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ on:
required: false
type: 'string'
default: 'example.org'
coverage-format:
description: 'The coverage report format to generate. Supported values are clover or html.'
coverage-report:
description: 'Whether to generate a code coverage report.'
required: false
type: string
default: ''
type: boolean
default: false
report:
description: 'Whether to report results to WordPress.org Hosting Tests'
required: false
Expand All @@ -73,8 +73,8 @@ on:
required: false
env:
LOCAL_PHP: ${{ inputs.php }}-fpm
LOCAL_PHP_XDEBUG: ${{ inputs.coverage-format && true || false }}
LOCAL_PHP_XDEBUG_MODE: ${{ inputs.coverage-format && 'coverage' || 'develop,debug' }}
LOCAL_PHP_XDEBUG: ${{ inputs.coverage-report || false }}
LOCAL_PHP_XDEBUG_MODE: ${{ inputs.coverage-report && 'coverage' || 'develop,debug' }}
LOCAL_DB_TYPE: ${{ inputs.db-type }}
LOCAL_DB_VERSION: ${{ inputs.db-version }}
LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
phpunit-tests:
name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.phpunit-test-groups && format( ' ({0})', inputs.phpunit-test-groups ) || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
runs-on: ${{ inputs.os }}
timeout-minutes: ${{ inputs.coverage-format && 120 || 20 }}
timeout-minutes: ${{ inputs.coverage-report && 120 || 20 }}

steps:
- name: Configure environment variables
Expand Down Expand Up @@ -180,42 +180,42 @@ jobs:
- name: Install WordPress
run: npm run env:install

- name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-format && format( ' with {0} report', inputs.coverage-format ) || '' }}
- name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}${{ inputs.phpunit-test-groups && format( ' --group {0}', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-format && format( ' --coverage-{0} wp-code-coverage-{1}-{2}{3}', inputs.coverage-format, ( inputs.multisite && 'multisite' || 'single' ), github.sha, ( inputs.coverage-format == 'clover' && '.xml' || '' ) ) }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}${{ inputs.phpunit-test-groups && format( ' --group {0}', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && format( ' --coverage-clover wp-code-coverage-{0}-{1}.xml --coverage-html wp-code-coverage-{0}-{1}', ( inputs.multisite && 'multisite' || 'single' ), github.sha ) }}

- name: Run AJAX tests
if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-format }}
if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax

- name: Run ms-files tests as a multisite install
if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-format }}
if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files

- name: Run external HTTP tests
if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-format }}
if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http

# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
- name: Run (Xdebug) tests
if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups && ! inputs.coverage-format }}
if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__

- name: Upload test coverage report to Codecov
if: ${{ inputs.coverage-format == 'clover' }}
if: ${{ inputs.coverage-report }}
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}${{ 'clover' == inputs.coverage-format && '.xml' || '' }}
file: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml
flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
fail_ci_if_error: true

- name: Upload HTML coverage report as artifact
if: ${{ inputs.coverage-format == 'html' }}
if: ${{ inputs.coverage-report }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
# Creates a PHPUnit test jobs for generating code coverage reports.
#
test-coverage-report:
name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report (${{ matrix.format }})
name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report
uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
permissions:
contents: read
Expand All @@ -48,11 +48,11 @@ jobs:
fail-fast: false
matrix:
multisite: [ false, true ]
format: [ clover, html ]
coverage-report: [ true ]
with:
php: '8.3'
multisite: ${{ matrix.multisite }}
coverage-format: ${{ matrix.format }}
coverage-report: ${{ matrix.coverage-report }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down

0 comments on commit 0780462

Please sign in to comment.