Skip to content

Commit b447222

Browse files
authored
Merge pull request #16 from valbeat/feat/improve-test-coverage
Improve test coverage reporting and CI/CD pipeline
2 parents 96ea794 + f19481c commit b447222

2 files changed

Lines changed: 48 additions & 29 deletions

File tree

.github/workflows/test.yml

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,61 @@ on:
88

99
jobs:
1010
test:
11+
name: PHP ${{ matrix.php }} Tests
1112
runs-on: ubuntu-latest
12-
name: PHP 8.4 Tests
13-
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php: ['8.4']
17+
1418
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Setup PHP 8.4
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP ${{ matrix.php }} with PCOV
1823
uses: shivammathur/setup-php@v2
1924
with:
20-
php-version: '8.4'
21-
coverage: xdebug
25+
php-version: ${{ matrix.php }}
26+
coverage: pcov
2227
tools: composer:v2
23-
28+
ini-values: |
29+
pcov.enabled=1
30+
pcov.directory=.
31+
pcov.exclude=*/vendor/*,*/tests/*
32+
2433
- name: Validate composer.json
2534
run: composer validate --strict
26-
27-
- name: Cache Composer packages
28-
uses: actions/cache@v3
35+
36+
- name: Install dependencies (cached)
37+
uses: ramsey/composer-install@v3
2938
with:
30-
path: vendor
31-
key: ${{ runner.os }}-php-8.4-${{ hashFiles('**/composer.lock') }}
32-
restore-keys: |
33-
${{ runner.os }}-php-8.4-
34-
35-
- name: Install dependencies
36-
run: composer install --prefer-dist --no-progress
37-
38-
- name: Run tests
39-
run: composer test
40-
41-
- name: Generate coverage report
42-
run: ./vendor/bin/phpunit --coverage-clover coverage.xml
43-
39+
composer-options: --no-interaction --prefer-dist --no-progress
40+
41+
- name: Make report directories
42+
run: mkdir -p build/logs coverage/html
43+
44+
- name: Run PHPUnit with coverage (PCOV)
45+
run: |
46+
vendor/bin/phpunit \
47+
--coverage-clover build/logs/clover.xml \
48+
--coverage-html coverage/html \
49+
--log-junit build/logs/junit.xml \
50+
--colors=always
51+
4452
- name: Upload coverage to Codecov
45-
uses: codecov/codecov-action@v3
53+
uses: codecov/codecov-action@v5
4654
with:
47-
file: ./coverage.xml
55+
files: build/logs/clover.xml
4856
flags: unittests
49-
name: codecov-umbrella
50-
fail_ci_if_error: false
57+
fail_ci_if_error: true
58+
verbose: true
59+
60+
- name: Upload test artifacts (JUnit & HTML & Clover)
61+
if: always()
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: php-${{ matrix.php }}-test-artifacts
65+
path: |
66+
build/logs/
67+
coverage/html/
68+
retention-days: 7

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/.phpunit.cache/
55
/.phpunit.result.cache
66
/coverage/
7+
/build/
78
.DS_Store
89
/.php-cs-fixer.cache
910

0 commit comments

Comments
 (0)