Skip to content

Commit 15e8f3c

Browse files
committed
Add code coverage configuration and CI integration
- Add coverage configuration to phpunit.xml.dist - Include all src/ files except resources directory - Enable processUncoveredFiles for accurate coverage - Add composer scripts for coverage measurement - `composer coverage`: CLI text output - `composer coverage-report`: HTML report to coverage-html/ - Add coverage-html/ to .gitignore - Add GitHub Actions coverage job with Xdebug enabled - Runs on PHP 8.4 - Executes coverage during CI pipeline
1 parent a0bdfef commit 15e8f3c

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ jobs:
4343
- name: Tests
4444
run: composer test
4545

46+
coverage:
47+
name: Code Coverage
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Install PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: 8.4
58+
coverage: xdebug
59+
60+
- name: Cache PHP dependencies
61+
uses: actions/cache@v4
62+
with:
63+
path: vendor
64+
key: ${{ runner.os }}-php-8.4-composer-${{ hashFiles('**/composer.json') }}
65+
restore-keys: ${{ runner.os }}-php-8.4-composer-
66+
67+
- name: Install dependencies
68+
run: composer install
69+
70+
- name: Run tests with coverage
71+
run: composer coverage
72+
4673
phpstan:
4774
name: PHPStan Static Analysis
4875
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.cache
22
*.code-workspace
33
composer.lock
4+
coverage-html
45
env.php
56
phpunit.xml
67
vendor

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
"scripts": {
6666
"demo": "php -S localhost:8888 demo/index.php",
6767
"test": "phpunit",
68+
"coverage": "phpunit --coverage-text",
69+
"coverage-report": "phpunit --coverage-html coverage-html",
6870
"cs-fix": "php-cs-fixer fix",
6971
"phpstan": "phpstan --memory-limit=-1",
7072
"update-resources": [

phpunit.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@
2222
<group>ignore</group>
2323
</exclude>
2424
</groups>
25+
<coverage processUncoveredFiles="true">
26+
<include>
27+
<directory suffix=".php">src</directory>
28+
</include>
29+
<exclude>
30+
<directory>src/resources</directory>
31+
</exclude>
32+
</coverage>
2533
</phpunit>

0 commit comments

Comments
 (0)