Repository navigation
146 lines (119 loc) · 4.4 KB
/
Copy pathtests.yml
File metadata and controls
146 lines (119 loc) · 4.4 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Tests
on:
push:
branches: [main, v2]
pull_request:
branches: [main, v2]
permissions:
contents: read
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@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962
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
static-analysis:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set up PHP 8.4
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962
with:
php-version: "8.4"
coverage: none
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --memory-limit=1G
mutation:
name: Mutation testing
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set up PHP 8.4 with pcov
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962
with:
php-version: "8.4"
coverage: pcov
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run Infection
run: php -d memory_limit=1G vendor/bin/infection --threads=max --only-covering-test-cases --no-progress
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set up PHP 8.4 with pcov
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962
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"