Skip to content

Commit 91e5819

Browse files
committed
build: enhance testing workflow in tests.yml with improved naming and coverage reporting
1 parent 5c48e25 commit 91e5819

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

.github/workflows/tests.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,75 @@ on:
33
push:
44
branches:
55
- '**'
6-
pull_request:
7-
branches:
8-
- '**'
96

107
jobs:
118
tests:
12-
13-
name: Test ${{ matrix.name_suffix }}
9+
name: Tests (PHP ${{ matrix.php-version }} & ${{ matrix.dependencies }} dependencies)
1410
runs-on: ubuntu-latest
1511
strategy:
1612
fail-fast: false
1713
matrix:
18-
php-version: [ "8.1", "8.2", "8.3", "8.4" ]
19-
dependencies: [ "locked", "highest", "lowest" ]
20-
14+
php-version: ["8.1", "8.2", "8.3", "8.4"]
15+
dependencies: ["locked", "highest", "lowest"]
2116
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
2420

21+
# Prepare environment
2522
- name: Setup PHP
2623
uses: shivammathur/setup-php@v2
2724
with:
2825
php-version: ${{ matrix.php-version }}
2926
tools: composer:v2
3027
coverage: none
3128

29+
# Install dependencies
3230
- name: Install Composer dependencies
3331
uses: ramsey/composer-install@v3
3432
with:
3533
dependency-versions: ${{ matrix.dependencies }}
3634

37-
- name: Run PHPUnit tests
35+
# Run tests
36+
- name: Run tests
3837
run: composer test
3938

4039
coverage:
40+
name: Test coverage
4141
runs-on: ubuntu-latest
42-
name: Code Coverage Report
43-
needs: tests
44-
4542
steps:
46-
- name: Checkout code
47-
uses: actions/checkout@v4
43+
- uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
4846

47+
# Prepare environment
4948
- name: Setup PHP
5049
uses: shivammathur/setup-php@v2
5150
with:
52-
php-version: '8.4'
53-
extensions: libxml, simplexml, xdebug
54-
tools: composer:'2.8'
51+
php-version: 8.4
52+
tools: composer:v2
53+
coverage: pcov
5554

55+
# Install dependencies
5656
- name: Install Composer dependencies
5757
uses: ramsey/composer-install@v3
5858

59-
- name: Run PHPUnit tests with coverage
59+
# Run tests
60+
- name: Build coverage directory
61+
run: mkdir -p .build/coverage
62+
- name: Run tests with coverage
6063
run: composer test:coverage
6164

62-
- name: Upload coverage report
65+
# Upload artifact
66+
- name: Fix coverage path
67+
working-directory: .build/coverage
68+
run: sed -i 's#/home/runner/work/php-cs-fixer-config/php-cs-fixer-config#${{ github.workspace }}#g' clover.xml
69+
- name: Upload coverage artifact
6370
uses: actions/upload-artifact@v4
6471
with:
65-
name: code-coverage-report
72+
name: coverage
6673
path: .build/coverage/clover.xml
67-
retention-days: 5
74+
retention-days: 7
6875

6976
coverage-report:
7077
name: Report test coverage
@@ -75,12 +82,24 @@ jobs:
7582
with:
7683
fetch-depth: 0
7784

85+
# Download artifact
7886
- name: Download coverage artifact
7987
id: download
80-
uses: actions/download-artifact@v4
88+
uses: actions/download-artifact@v5
89+
with:
90+
name: coverage
91+
92+
# CodeClimate
93+
- name: CodeClimate report
94+
uses: paambaati/codeclimate-action@v9.0.0
95+
if: env.CC_TEST_REPORTER_ID
96+
env:
97+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
8198
with:
82-
name: code-coverage-report
99+
coverageLocations: |
100+
${{ steps.download.outputs.download-path }}/clover.xml:clover
83101
102+
# Coveralls
84103
- name: Coveralls report
85104
uses: coverallsapp/github-action@v2
86105
with:

0 commit comments

Comments
 (0)