-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (79 loc) · 3.36 KB
/
tests.yml
File metadata and controls
96 lines (79 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Tests
on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [ '8.1', '8.2', '8.3', '8.4' ]
dependency-version: [ prefer-lowest, prefer-stable ]
name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, sodium, zlib
coverage: none
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-
- name: Override PHP platform for dev tools on PHP 8.4
if: matrix.php == '8.4'
run: composer config platform.php 8.3.99
- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress
- name: Run test suite
run: composer test
coverage:
runs-on: ubuntu-latest
name: Code Coverage
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: json, sodium, zlib
coverage: xdebug
- name: Install dependencies
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
- name: Run tests with coverage
run: XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite Unit --coverage-clover coverage.xml
- name: Check minimum coverage threshold (70%)
run: |
php -r '
$xml = simplexml_load_file("coverage.xml");
$metrics = $xml->project->metrics;
$statements = (int) $metrics["statements"];
$covered = (int) $metrics["coveredstatements"];
$pct = $statements > 0 ? round($covered / $statements * 100, 2) : 0;
printf("Coverage: %.2f%%\n", $pct);
if ($pct < 70) {
printf("ERROR: Coverage %.2f%% is below the 70%% minimum.\n", $pct);
exit(1);
}
echo "Coverage check passed.\n";
'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: false
verbose: true