-
-
Notifications
You must be signed in to change notification settings - Fork 452
404 lines (338 loc) · 11.9 KB
/
ci.yml
File metadata and controls
404 lines (338 loc) · 11.9 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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
name: CI
on:
pull_request:
paths:
- "src/**"
- "tests/**"
- "composer.json"
- ".phive/phars.xml"
- "phpstan.neon.dist"
- "phpunit.xml.dist"
- ".php-cs-fixer.dist.php"
- "rector.php"
- "tools/**"
- ".github/workflows/ci.yml"
- ".github/workflows/secure-tests.yml"
push:
branches: ['8.x']
paths:
- "src/**"
- "tests/**"
- "composer.json"
- ".phive/phars.xml"
- "phpstan.neon.dist"
- "phpunit.xml.dist"
- ".php-cs-fixer.dist.php"
- "rector.php"
- "tools/**"
- ".github/workflows/ci.yml"
- ".github/workflows/secure-tests.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
dependency-validation:
name: Dependency Validation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
coverage: none
tools: composer
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer.json
run: composer validate --strict
- name: Ensure dependencies can be installed
run: composer install --no-interaction --no-progress --ansi --dry-run --ignore-platform-req=ext-grpc
static-analysis:
name: "PHPStan (PHP ${{ matrix.php }})"
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php:
- "8.3"
- "8.4"
- "8.5"
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer, pecl
coverage: none
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Cache PHPStan dependencies
uses: actions/cache@v5
with:
path: tools/.phpstan/vendor
key: ${{ runner.os }}-phpstan-tools-${{ hashFiles('tools/.phpstan/composer.lock') }}
- name: Install PHPStan dependencies
run: composer --working-dir=tools/.phpstan install --no-interaction --no-progress --ansi
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Run PHPStan
run: XDEBUG_MODE=off tools/phpstan analyse --no-progress --error-format=github
dependency-audit:
name: Composer Audit
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
tools: composer
coverage: none
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Run Composer Audit
run: composer audit --no-interaction --format=summary --abandoned=report --ansi
lint:
name: "Lint (${{ matrix.name }})"
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- id: rector
name: Rector
php: "8.5"
command: tools/rector --ansi --dry-run
- id: php-cs-fixer
name: PHP-CS-Fixer
php: "8.3"
command: tools/php-cs-fixer check --ansi --diff --verbose
- id: composer-normalize
name: Composer Normalize
php: "8.5"
command: tools/composer-normalize --ansi --dry-run
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer, pecl
coverage: none
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Cache Rector dependencies
if: ${{ matrix.id == 'rector' }}
uses: actions/cache@v5
with:
path: tools/.rector/vendor
key: ${{ runner.os }}-rector-tools-${{ hashFiles('tools/.rector/composer.lock') }}
- name: Install Rector dependencies
if: ${{ matrix.id == 'rector' }}
run: composer --working-dir=tools/.rector install --no-interaction --no-progress --ansi
- name: "Run ${{ matrix.name }}"
run: ${{ matrix.command }}
tests:
name: "PHP ${{ matrix.php }}, ${{ matrix.dependencies }} deps"
needs:
- static-analysis
- lint
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
php:
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "lowest"
- "highest"
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer, pecl
coverage: none
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: |
if [ "${{ matrix.dependencies }}" = "lowest" ]; then
composer update --prefer-lowest --prefer-stable --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
else
composer update --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
fi
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPUnit
run: tools/phpunit --testsuite=unit --testdox
code-coverage:
name: Unit Test Coverage (PHP 8.5)
needs:
- tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
tools: composer, pecl
coverage: xdebug
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Cache PHPUnit static analysis cache
uses: actions/cache@v5
with:
path: .phpunit.cache/code-coverage
key: ${{ runner.os }}-phpunit-code-coverage-${{ github.ref }}-
restore-keys: |
${{ runner.os }}-phpunit-code-coverage-${{ github.ref }}-
- name: Warm PHPUnit static analysis cache
run: tools/phpunit --warm-coverage-cache
- name: Collect code coverage with PHPUnit
run: |
mkdir -p build
tools/phpunit --testsuite=unit --log-junit build/test-results.xml --coverage-clover build/code-coverage.xml --testdox
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
report_type: test_results
files: ./build/test-results.xml
fail_ci_if_error: false
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/code-coverage.xml
flags: unit
fail_ci_if_error: false
bc-check:
name: Backward Compatibility Check
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: "Workaround: Configure Git safe.directory for roave-bc-check Docker action"
run: |
mkdir -p /home/runner/work/_temp/_github_home
printf "[safe]\n\tdirectory = /github/workspace\n" > /home/runner/work/_temp/_github_home/.gitconfig
- name: Check whether repository has tags
id: check-tags
shell: bash
run: |
if git tag --list | grep -q .; then
echo "has_tags=true" >> "$GITHUB_OUTPUT"
else
echo "has_tags=false" >> "$GITHUB_OUTPUT"
fi
- name: Run Roave BC Check
if: ${{ steps.check-tags.outputs.has_tags == 'true' }}
uses: docker://nyholm/roave-bc-check-ga
- name: Skip Roave BC Check (no tags found)
if: ${{ steps.check-tags.outputs.has_tags != 'true' }}
run: echo "Skipping BC check because no git tags were found."