-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 3.13 KB
/
Copy pathtests.yml
File metadata and controls
104 lines (88 loc) · 3.13 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
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Laravel 10 and 11 are dropped from support: every laravel/framework
# patch on those lines — including the newest — is now blocked by
# Composer's security-advisory policy (both majors are past their
# security-support window), so they're no longer installable at all.
- php: "8.4"
laravel: "12.*"
testbench: "10.*"
phpunit: "^11.5.3"
- php: "8.4"
laravel: "13.*"
testbench: "11.*"
phpunit: "^11.5.50"
steps:
- uses: actions/checkout@v7
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Require Laravel version
run: |
composer require \
"illuminate/contracts:${{ matrix.laravel }}" \
"illuminate/support:${{ matrix.laravel }}" \
--no-update
composer require \
"orchestra/testbench:${{ matrix.testbench }}" \
"phpunit/phpunit:${{ matrix.phpunit }}" \
--no-update --dev
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run tests
run: vendor/bin/phpunit --no-coverage
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v7
- name: Set up PHP 8.4 with pcov
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
coverage: pcov
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run tests with coverage
run: |
mkdir -p build
vendor/bin/phpunit --coverage-clover=build/coverage.xml --coverage-text
- name: Enforce 100% coverage
run: composer coverage:check
- name: Extract coverage percentage
run: |
PCT=$(php -r "
\$xml = simplexml_load_file('build/coverage.xml');
\$m = \$xml->project->metrics;
\$t = (int)\$m['statements'];
\$c = (int)\$m['coveredstatements'];
echo \$t > 0 ? round(\$c / \$t * 100) : 0;
")
echo "COVERAGE_PCT=$PCT" >> $GITHUB_ENV
- name: Update coverage badge
if: github.ref == 'refs/heads/main'
env:
GIST_SECRET: ${{ secrets.GIST_SECRET }}
run: |
CONTENT=$(printf '{"schemaVersion":1,"label":"coverage","message":"%s%%","color":"brightgreen"}' "$COVERAGE_PCT")
curl -sf -X PATCH \
-H "Authorization: token $GIST_SECRET" \
-H "Content-Type: application/json" \
-H "User-Agent: GitHub-Actions" \
-d "{\"files\":{\"coverage.json\":{\"content\":$(echo "$CONTENT" | jq -Rs .)}}}" \
"https://api.github.com/gists/1a6bdbea77d160eeaf4524b8e165d3ac"