From bad76779aa572cb96df6f1a0a6af69f1f3996a77 Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 7 Nov 2024 02:59:19 +0530 Subject: [PATCH] Update workflow to run code coverage using matrix strategy --- .github/workflows/php-test-plugins.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index 3145419d96..2daacec3aa 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -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 ) }} @@ -68,10 +72,21 @@ 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 }} @@ -79,7 +94,8 @@ jobs: 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