Skip to content

Commit

Permalink
Update workflow to run code coverage using matrix strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak Jaiswal authored and Sarthak Jaiswal committed Nov 6, 2024
1 parent 6a0b6a3 commit bad7677
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/php-test-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ jobs:
matrix:
php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2']
wp: [ 'latest' ]
coverage: [false]
include:
- php: '7.4'
wp: '6.5'
- php: '8.3'
wp: 'trunk'
- php: '8.2'
wp: 'latest'
coverage: true
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }}
Expand All @@ -68,18 +72,30 @@ jobs:
- name: Composer Install
run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress
- name: Running single site unit tests
run: npm run test-php -- --coverage-clover=coverage.xml
run: |
if [ "${{ matrix.coverage }}" == "true" ]; then
npm run test-php -- --coverage-clover=coverage.xml
else
npm run test-php
fi
- name: Running multisite unit tests
run: npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml
run: |
if [ "${{ matrix.coverage }}" == "true" ]; then
npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml
else
npm run test-php-multisite
fi
- name: Upload single site coverage reports to Codecov
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: unittests
name: ${{ matrix.php }}-single-site-coverage
- name: Upload multisite coverage reports to Codecov
uses: codecov/codecov-action@v2
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage-multisite.xml
Expand Down

0 comments on commit bad7677

Please sign in to comment.