Skip to content

Commit af773c9

Browse files
committed
Added coverage gate
1 parent e8faf48 commit af773c9

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/phpunit.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ jobs:
4242
- name: Install dependencies
4343
run: docker compose ${{ matrix.compose-files }} run --rm phpfpm composer install
4444

45-
- name: Run test suite
46-
run: docker compose ${{ matrix.compose-files }} run --rm phpfpm vendor/bin/phpunit
45+
- name: Run PHPUnit with coverage
46+
run: docker compose ${{ matrix.compose-files }} run -e XDEBUG_MODE=coverage --rm phpfpm vendor/bin/phpunit --coverage-clover=coverage/clover.xml
47+
48+
- name: Enforce coverage threshold (100%)
49+
run: docker compose ${{ matrix.compose-files }} run --rm phpfpm vendor/bin/coverage-check coverage/clover.xml 100

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.phpunit.cache/
44
/phpunit.xml
55
/var/
6+
/coverage/
67
.php-cs-fixer.cache

Taskfile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ tasks:
4444
cmds:
4545
- '{{.COMPOSE_POSTGRES_PHP85}} run --rm phpfpm vendor/bin/phpunit {{.CLI_ARGS}}'
4646

47+
test:coverage:
48+
desc: Run PHPUnit with coverage and enforce the 100% line gate
49+
cmds:
50+
- '{{.COMPOSE}} run -e XDEBUG_MODE=coverage --rm phpfpm vendor/bin/phpunit --coverage-clover=coverage/clover.xml {{.CLI_ARGS}}'
51+
- '{{.COMPOSE}} run --rm phpfpm vendor/bin/coverage-check coverage/clover.xml 100'
52+
4753
lint:
4854
desc: Run every CI lint check (php, phpstan, composer, markdown, yaml)
4955
cmds:

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"phpstan/phpstan-phpunit": "^2.0",
2424
"phpstan/phpstan-symfony": "^2.0",
2525
"phpunit/phpunit": "^13.1",
26+
"rregeer/phpunit-coverage-check": "^0.3.1",
2627
"symfony/browser-kit": "^7.4 || ^8.0",
2728
"symfony/dotenv": "^7.4 || ^8.0",
2829
"symfony/yaml": "^8.1"

0 commit comments

Comments
 (0)