-
Notifications
You must be signed in to change notification settings - Fork 0
365 lines (304 loc) · 12.6 KB
/
Copy pathci.yml
File metadata and controls
365 lines (304 loc) · 12.6 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
# The lock file is gitignored, so dependencies only re-resolve when something
# is pushed — a weekly run surfaces silent dependency rot and audit-ignore
# entries that Symfony has patched in the meantime.
schedule:
- cron: '30 5 * * 1'
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
validate:
name: Composer validate
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
coverage: none
- name: Validate composer.json
run: composer validate --strict
shellcheck:
name: Shellcheck host runner
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# shellcheck ships preinstalled on ubuntu-latest. Scoped to the runner
# itself and any real *.sh files under src/tests — none exist today
# (deploytasks:host:generate writes its stub at runtime, from a PHP
# template, not a committed .sh file), so the find is a no-op guard
# against future additions rather than dead weight.
- name: shellcheck runner + host-task scripts
run: |
shellcheck bin/deploy-tasks-host.sh.dist
find src tests -name '*.sh' -print0 | xargs -0 -r shellcheck
changelog:
name: Changelog structure
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# Keep a Changelog discipline: [Unreleased] holds at most one section per
# change type, and only the six canonical types. Duplicate sections have
# already drifted in once (two independent "### Changed" blocks).
- name: Lint the [Unreleased] section structure
run: |
awk '
/^## / { in_unreleased = ($0 ~ /^## \[Unreleased\]/) }
in_unreleased && /^### / {
type = substr($0, 5)
sub(/[ \t]+$/, "", type)
if (type !~ /^(Added|Changed|Deprecated|Removed|Fixed|Security)$/) {
printf "CHANGELOG.md line %d: unknown section \"%s\"\n", NR, type; bad = 1
} else if (seen[type]++) {
printf "CHANGELOG.md line %d: duplicate section \"%s\"\n", NR, type; bad = 1
}
}
END { if (bad) exit 1; print "CHANGELOG [Unreleased] structure OK" }
' CHANGELOG.md
phpstan:
name: PHPStan
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
extensions: mbstring, xml, ctype, iconv, intl
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- name: Cache PHPStan result
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: var/cache/phpstan
key: phpstan-${{ runner.os }}-${{ hashFiles('phpstan.neon', '**/composer.json') }}
restore-keys: phpstan-${{ runner.os }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-scripts
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress
cs-fixer:
name: CS Fixer
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
extensions: mbstring, xml, ctype, iconv, intl
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- name: Cache CS Fixer result
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .php-cs-fixer.cache
key: php-cs-fixer-${{ runner.os }}-${{ hashFiles('.php-cs-fixer.dist.php', '**/composer.json') }}
restore-keys: php-cs-fixer-${{ runner.os }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-scripts
- name: Run CS Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff
tests:
name: Tests (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}${{ matrix.prefer-lowest && ', prefer-lowest' || '' }})
runs-on: ubuntu-latest
timeout-minutes: 15
# Non-tty runners report an 80-column terminal, so SymfonyStyle wraps long
# literals out of display assertions that pass locally. Pin the width every
# PHPUnit-running job uses to a realistic terminal.
env:
COLUMNS: 120
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4', '8.5']
# Symfony 7.0–7.3 are end-of-life and receive no security patches, so the
# advisory-aware resolver can never install them — only the maintained
# lines (6.4 LTS, 7.4, 8.1) are exercised. 7.4 covers the 7.x API surface
# and 8.1 the 8.x one.
symfony: ['6.4.*', '7.4.*', '8.1.*']
# Symfony 8 requires PHP >= 8.4, so the 8.1 line cannot resolve on the
# older PHP versions of the matrix.
exclude:
- php: '8.2'
symfony: '8.1.*'
- php: '8.3'
symfony: '8.1.*'
include:
- php: '8.2'
symfony: '6.4.*'
prefer-lowest: true
composer-flags: '--prefer-lowest --prefer-stable'
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}-sf${{ matrix.symfony }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-sf${{ matrix.symfony }}-
composer-php${{ matrix.php }}-
- name: Set Symfony version constraint
if: matrix.symfony != ''
run: echo "SYMFONY_REQUIRE=${{ matrix.symfony }}" >> $GITHUB_ENV
- name: Install Symfony Flex globally
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-scripts ${{ matrix.composer-flags }}
- name: Run tests
env:
SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.prefer-lowest && 'disabled=1' || 'max[direct]=0' }}
run: vendor/bin/phpunit
coverage:
name: Coverage
runs-on: ubuntu-latest
timeout-minutes: 15
# Hoisted to job level: the secrets context is not available inside step-level
# `if:` expressions — referencing it there fails the whole workflow at startup.
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
COLUMNS: 120
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache
key: composer-coverage-${{ hashFiles('composer.json') }}
restore-keys: composer-coverage-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-scripts
- name: Run tests with coverage
run: vendor/bin/phpunit --coverage-clover=build/coverage/clover.xml --coverage-text=build/coverage/coverage.txt
- name: Enforce coverage threshold
run: |
php -r '
$xml = simplexml_load_file("build/coverage/clover.xml");
$metrics = $xml->xpath("/coverage/project/metrics")[0];
$covered = (int) $metrics["coveredstatements"];
$total = (int) $metrics["statements"];
$pct = $total > 0 ? ($covered / $total) * 100 : 0;
printf("Line coverage: %.2f%% (%d / %d)\n", $pct, $covered, $total);
exit($pct >= 95 ? 0 : 1);
'
- name: Upload coverage to Codecov
if: env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
files: ./build/coverage/clover.xml
fail_ci_if_error: true
- name: Upload coverage artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: coverage-clover
path: build/coverage/
retention-days: 14
security:
name: Composer audit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
coverage: none
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-scripts
- name: Run composer audit
run: composer audit --locked
mutation:
name: Mutation testing
runs-on: ubuntu-latest
timeout-minutes: 30
# By far the slowest job — keep it off pull requests; MSI regressions are
# still caught on every push to main and on the weekly scheduled run.
if: github.event_name != 'pull_request'
env:
COLUMNS: 120
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.composer/cache
key: composer-mutation-${{ hashFiles('composer.json') }}
restore-keys: composer-mutation-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-scripts
- name: Run Infection
# Explicit --threads=4 (ubuntu-latest has 4 vCPUs): --threads=max fails to
# detect the core count on the runner and falls back to a single thread,
# which pushed the run to ~18 min — close to the job timeout.
#
# --show-mutations=0: Infection's console diff colorizer crashes with
# "Incorrectly nested style tag" whenever an escaped mutant's inline diff
# boundary lands right after a backslash (its own `\<` escaping defeats the
# style tag it inserts next). Escaped mutants stay visible as GitHub
# annotations (--logger-github) and in the uploaded infection.log.
run: vendor/bin/infection --threads=4 --logger-github --show-mutations=0
- name: Upload mutation log
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: infection-log
path: infection.log
retention-days: 14