Skip to content

Commit f645fb6

Browse files
committed
PHPUnit: add clover code coverage config to config file
This moves the clover code coverage config from the composer script to the `phpunit[10].xml.dist` config files. It also moves the default location for the file from the project root to the `tests/coverage/` directory so all coverage files are in the same place (and automatically git ignored etc). Includes updating the "upload to CodeCov" step to find the file in the new location.
1 parent 88e570f commit f645fb6

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ jobs:
123123

124124
- name: Run the unit tests with code coverage (PHPUnit < 10)
125125
if: ${{ matrix.coverage == true && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
126-
run: composer coverage -- --coverage-clover clover.xml
126+
run: composer coverage
127127

128128
- name: Run the unit tests with code coverage (PHPUnit 10+)
129129
if: ${{ matrix.coverage == true && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
130-
run: composer coverage10 -- --coverage-clover clover.xml
130+
run: composer coverage10
131131

132132
- name: Stop proxy server
133133
continue-on-error: true
@@ -144,6 +144,6 @@ jobs:
144144
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
145145
with:
146146
token: "${{ secrets.CODECOV_TOKEN }}"
147-
files: ./clover.xml
147+
files: ./tests/coverage/clover.xml
148148
fail_ci_if_error: true
149149
verbose: true

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<logging>
1919
<log type="coverage-html" target="tests/coverage" lowUpperBound="35" highLowerBound="90"/>
20+
<log type="coverage-clover" target="tests/coverage/clover.xml"/>
2021
</logging>
2122

2223
<filter>

phpunit10.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<coverage includeUncoveredFiles="true" ignoreDeprecatedCodeUnits="true">
3232
<report>
3333
<html outputDirectory="tests/coverage" lowUpperBound="35" highLowerBound="90"/>
34+
<clover outputFile="tests/coverage/clover.xml"/>
3435
</report>
3536
</coverage>
3637
</phpunit>

0 commit comments

Comments
 (0)