-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (95 loc) · 3.2 KB
/
Copy pathtests.yml
File metadata and controls
112 lines (95 loc) · 3.2 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Tests
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: tests-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
tests:
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependencies }} dependencies
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
laravel: ['12', '13']
dependencies: [lowest, highest]
include:
- laravel: '12'
testbench: '10'
- laravel: '13'
testbench: '11'
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mbstring
ini-values: memory_limit=512M
coverage: none
- name: Select the Laravel version
run: |
composer require --no-interaction --no-update \
"illuminate/console:^${{ matrix.laravel }}.0" \
"illuminate/http:^${{ matrix.laravel }}.0" \
"illuminate/support:^${{ matrix.laravel }}.0"
composer require --dev --no-interaction --no-update \
"orchestra/testbench:^${{ matrix.testbench }}.0"
- name: Install dependencies
uses: ramsey/composer-install@v4
with:
dependency-versions: ${{ matrix.dependencies }}
- name: Run test suite
run: composer test
coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: json, mbstring
ini-values: memory_limit=512M
coverage: pcov
- name: Install dependencies
uses: ramsey/composer-install@v4
with:
dependency-versions: highest
- name: Run test suite with coverage
run: vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text
- name: Check the coverage against the minimum
env:
MIN_COVERAGE: '94'
run: |
php -r '
$metrics = simplexml_load_file("coverage.xml")->project->metrics;
$covered = (int) $metrics["coveredstatements"];
$total = (int) $metrics["statements"];
$percentage = $total > 0 ? round($covered / $total * 100, 2) : 0.0;
$minimum = (float) getenv("MIN_COVERAGE");
$summary = sprintf(
"### Code coverage%s%s**%.2f%%** of %d lines are covered (minimum: %.2f%%).%s",
PHP_EOL, PHP_EOL, $percentage, $total, $minimum, PHP_EOL
);
echo $summary;
if (($file = getenv("GITHUB_STEP_SUMMARY")) !== false) {
file_put_contents($file, $summary, FILE_APPEND);
}
exit($percentage >= $minimum ? 0 : 1);
'
- name: Upload the coverage report to codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false