Skip to content

Commit

Permalink
Coverage on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Jan 26, 2025
1 parent fe8e68e commit 91c8bbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
35 changes: 14 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ jobs:
with:
php-version: 8.2
tools: composer:v2
coverage: xdebug

- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress

- name: "Run unit tests"
run: composer test:unit
- name: "Run unit tests with coverage"
run: composer run test:coverage

- name: "Send coverage to Coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.coverage }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ env.COVERALLS_REPO_TOKEN }}
flag-name: "Unit"
allow-empty: false

wp-test:
name: "WordPress tests with WP ${{ matrix.wp_version }}"
Expand All @@ -31,9 +42,6 @@ jobs:
strategy:
matrix:
wp_version: ["6.3", "6.4", "6.5", "6.6", "6.7", "latest"]
include:
- wp_version: "6.7"
coverage: true

services:
mysql:
Expand All @@ -56,7 +64,7 @@ jobs:
with:
php-version: 8.2
tools: composer:v2
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
coverage: none

- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress
Expand All @@ -73,19 +81,4 @@ jobs:
run: ./config/scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp_version }}

- name: "Run WordPress tests"
if: ${{ !matrix.coverage }}
run: composer run test:wordPress

- name: "Run WordPress tests with coverage"
if: ${{ matrix.coverage }}
run: composer run test:coverage

- name: "Send coverage to Coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.coverage }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ env.COVERALLS_REPO_TOKEN }}
flag-name: "Unit"
allow-empty: false
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
"test:unit": "vendor/bin/phpunit --no-coverage",
"test:wordPress": "vendor/bin/phpunit -c phpunit-wp.xml --no-coverage",
"test:coverage": "vendor/bin/phpunit -c phpunit-wp.xml",
"test:coverage": "vendor/bin/phpunit",
"csFixer": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
"fix:csFixer": "vendor/bin/php-cs-fixer fix"
}
Expand Down

0 comments on commit 91c8bbe

Please sign in to comment.