Skip to content

Commit

Permalink
Add coverage report
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Foti <foti.giuseppe@gmail.com>
  • Loading branch information
MocioF committed Feb 6, 2024
1 parent 59aced2 commit 5623291
Show file tree
Hide file tree
Showing 3 changed files with 890 additions and 20 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:

name: Tests

env:
coverage-php-version: 8.1
coverage-wp-version: 6.4

jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -56,7 +60,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
tools: php-cs-fixer, composer
extensions: pcntl, posix
extensions: pcntl, posix, xdebug
env:
fail-fast: true

Expand All @@ -77,6 +81,10 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Remove phpunit-merger
if: ${{(matrix.php-versions != env.coverage-php-version) && (matrix.wordpress-version != env.coverage-wp-version)}}
run: (composer remove --dev nimut/phpunit-merger phpunit/phpunit || true ) && composer update

- name: Only for WP >= 5.9 Install Composer dependencies
# See: https://make.wordpress.org/core/2021/09/27/changes-to-the-wordpress-core-php-test-suite/
if: ${{ ( matrix.wordpress-version == '5.9' || matrix.wordpress-version == '6.0' || matrix.wordpress-version == '6.1' || matrix.wordpress-version == '6.2' || matrix.wordpress-version == '6.3' || matrix.wordpress-version == '6.4' ) }}
Expand All @@ -93,10 +101,23 @@ jobs:
# Rest of the versions
#if: ${{ matrix.php-versions != '8.0' }}
#run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run the tests
if: ${{(matrix.php-versions != env.coverage-php-version) && (matrix.wordpress-version != env.coverage-wp-version)}}
run: vendor/bin/phpunit --debug

- name: When using PHP 8.1 and WP 6.4 - Run the tests and generate coverage report (single)
if: ${{(matrix.php-versions == env.coverage-php-version) && (matrix.wordpress-version == env.coverage-wp-version)}}
run: vendor/bin/phpunit --debug --coverage-php coverage/single.cov

- name: When using PHP 8.1 and WP 6.4 - Run the tests and generate coverage report (multisite)
if: ${{(matrix.php-versions == env.coverage-php-version) && (matrix.wordpress-version == env.coverage-wp-version)}}
run: vendor/bin/phpunit --debug -c tests/phpunit/multisite.xml --coverage-php=coverage/multisite.cov

- name: Generate coverage merged report
if: ${{(matrix.php-versions == env.coverage-php-version) && (matrix.wordpress-version == env.coverage-wp-version)}}
run: vendor/bin/phpunit-merger coverage coverage/ --html=coverage-html/ coverage/coverage-merged.cov

sync-trunk:
name: Sync trunk with main
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"phpunit/phpunit": "^9.6.13",
"yoast/phpunit-polyfills": "^1.1.0",
"phpcompatibility/php-compatibility": "^9.3.5"
"phpcompatibility/php-compatibility": "^9.3.5",
"nimut/phpunit-merger": "^2.0"
},
"config": {
"allow-plugins": {
Expand Down
Loading

0 comments on commit 5623291

Please # to comment.