Repository navigation
486 lines (477 loc) · 18.2 KB
/
Copy pathci.yml
File metadata and controls
486 lines (477 loc) · 18.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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
name: CI
on:
push:
branches:
- '*'
- '!v1'
pull_request:
branches-ignore:
- v1
env:
COMPOSER_ALLOW_SUPERUSER: '1' # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
COVERAGE: '0'
INFECTION_VERSION: '0.35.4'
TEST_PROCESSES: '4'
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
php-cs-fixer:
name: PHP-CS-Fixer (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.5'
fail-fast: false
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl, bcmath, curl, openssl, mbstring, gd
ini-values: memory_limit=-1
tools: pecl, composer, php-cs-fixer
coverage: none
- name: Run PHP-CS-Fixer fix
run: php-cs-fixer fix --dry-run --diff --ansi --allow-unsupported-php-version 8.5
phpstan:
name: PHPStan (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.5'
fail-fast: false
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl, bcmath, curl, openssl, mbstring, gd
ini-values: memory_limit=-1
tools: composer
coverage: none
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Update project dependencies
run: composer update --no-progress --ansi
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --ansi
phpunit:
name: PHPUnit (Symfony ${{ matrix.symfony }}) (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php:
- '8.5'
symfony:
- '7.4'
- '8.1'
experimental:
- false
include:
- php: '8.5'
symfony: '7.4'
experimental: false
coverage: true
fail-fast: false
timeout-minutes: ${{ matrix.coverage && 40 || 20 }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
GD_CONFIGURE_OPTS: --enable-gd=shared,/usr --with-external-gd --with-jpeg --with-freetype
GD_LIBS: libjpeg-dev libpng-dev
GD_PATH: ext/gd
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, exif, xsl, gd
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Enable code coverage
if: matrix.coverage
run: echo "COVERAGE=1" >> $GITHUB_ENV
- name: Disable deprecations helper
if: ${{ !matrix.coverage }}
run: echo "SYMFONY_DEPRECATIONS_HELPER=disabled=1" >> $GITHUB_ENV
- name: Update project dependencies
run: |
composer config extra.symfony.require ${{ matrix.symfony }}
composer update --no-progress --ansi
- name: Clear test app cache
run: |
if [ "$COVERAGE" = '1' ]; then
tests/Functional/app/bin/console cache:clear --ansi
exit
fi
pids=
for token in $(seq "$TEST_PROCESSES"); do
TEST_TOKEN=$token tests/Functional/app/bin/console cache:clear --ansi &
pids="$pids $!"
done
for pid in $pids; do wait "$pid"; done
- name: Run PHPUnit tests
run: |
mkdir -p build/logs/phpunit
if [ "$COVERAGE" = '1' ]; then
vendor/bin/phpunit --configuration=phpunit.coverage.xml.dist --coverage-xml=build/logs/phpunit/coverage-xml --coverage-clover=build/logs/phpunit/clover.xml --log-junit=build/logs/phpunit/junit.xml
else
vendor/bin/paratest --processes="$TEST_PROCESSES" --log-junit build/logs/phpunit/junit.xml
fi
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-php${{ matrix.php }}-symfony${{ matrix.symfony }}
path: build/logs/phpunit
continue-on-error: true
- name: Upload coverage results to Codecov
if: matrix.coverage
uses: codecov/codecov-action@v4
with:
flags: phpunit
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Download Infection
if: matrix.coverage
run: |
wget https://github.com/infection/infection/releases/download/$INFECTION_VERSION/infection.phar
wget https://github.com/infection/infection/releases/download/$INFECTION_VERSION/infection.phar.asc
gpg --import .github/infection-signing-key.asc
gpg --with-fingerprint --verify infection.phar.asc infection.phar
chmod +x infection.phar
- name: Run Infection Mutation Tests
if: matrix.coverage && github.event_name != 'pull_request'
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
run: ./infection.phar --min-covered-msi=80 --threads=30 --only-covering-test-cases
- name: Run Infection Mutation Tests on changed lines
if: matrix.coverage && github.event_name == 'pull_request'
env:
BASE_REF: ${{ github.base_ref }}
run: |
if [ -f "$(git rev-parse --git-dir)/shallow" ]; then UNSHALLOW=--unshallow; else UNSHALLOW=; fi
git fetch --no-tags $UNSHALLOW origin "+refs/heads/$BASE_REF:refs/remotes/origin/$BASE_REF"
echo "Merge base of origin/$BASE_REF and HEAD: $(git merge-base "origin/$BASE_REF" HEAD)"
git diff --stat "origin/$BASE_REF...HEAD" -- src
./infection.phar --min-covered-msi=80 --threads=30 --only-covering-test-cases --git-diff-lines --git-diff-base="origin/$BASE_REF" --ignore-msi-with-no-mutations
- name: Upload Infection Mutation Logs
if: always() && matrix.coverage
uses: actions/upload-artifact@v4
with:
name: infection-logs-php${{ matrix.php }}
path: build/logs/infection*
functional:
name: Functional (Symfony ${{ matrix.symfony }}) (API Platform ${{ matrix.api-platform }}) (PHP ${{ matrix.php }})${{ matrix.symfony-listeners == '1' && ' (use_symfony_listeners)' || '' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php:
- '8.5'
symfony:
- '7.4'
- '8.1'
api-platform:
- '^4.4'
- '^5.0'
experimental:
- false
symfony-listeners:
- ''
include:
- php: '8.5'
symfony: '7.4'
api-platform: '^4.4'
experimental: false
symfony-listeners: '1'
fail-fast: false
timeout-minutes: 20
env:
API_PLATFORM_USE_SYMFONY_LISTENERS: ${{ matrix.symfony-listeners }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
GD_CONFIGURE_OPTS: --enable-gd=shared,/usr --with-external-gd --with-jpeg --with-freetype
GD_LIBS: libjpeg-dev libpng-dev
GD_PATH: ext/gd
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, exif, xsl, gd
coverage: none
ini-values: memory_limit=-1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-
continue-on-error: true
- name: Update project dependencies
run: |
composer config extra.symfony.require ${{ matrix.symfony }}
composer require "api-platform/core:${{ matrix.api-platform }}" --no-update --no-interaction
composer update --no-progress --ansi
- name: Clear test app cache
run: |
pids=
for token in $(seq "$TEST_PROCESSES"); do
TEST_TOKEN=$token tests/Functional/app/bin/console cache:clear --ansi &
pids="$pids $!"
done
for pid in $pids; do wait "$pid"; done
- name: Run PHPUnit functional tests
env:
SYMFONY_DEPRECATIONS_HELPER: disabled=1
run: |
mkdir -p build/logs/functional
vendor/bin/paratest --processes="$TEST_PROCESSES" --testsuite functional --log-junit build/logs/functional/junit.xml
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: functional-logs-php${{ matrix.php }}-symfony${{ matrix.symfony }}-api-platform${{ matrix.api-platform }}-listeners${{ matrix.symfony-listeners }}
path: build/logs/functional
continue-on-error: true
phpunit-lowest-deps:
name: PHPUnit (Symfony ${{ matrix.symfony }}) (PHP ${{ matrix.php }}) (lowest dependencies)
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.5'
symfony:
- '^7.4'
fail-fast: false
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
GD_CONFIGURE_OPTS: --enable-gd=shared,/usr --with-external-gd --with-jpeg --with-freetype
GD_LIBS: libjpeg-dev libpng-dev
GD_PATH: ext/gd
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, exif, xsl, gd
coverage: none
ini-values: memory_limit=-1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-lowest-deps-php${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-lowest-deps-php${{ matrix.php }}-
continue-on-error: true
- name: Update project dependencies
run: composer update --no-progress --ansi --prefer-stable --prefer-lowest
- name: Clear test app cache
run: |
pids=
for token in $(seq "$TEST_PROCESSES"); do
TEST_TOKEN=$token tests/Functional/app/bin/console cache:clear --ansi &
pids="$pids $!"
done
for pid in $pids; do wait "$pid"; done
- name: Disable deprecations helper
run: echo "SYMFONY_DEPRECATIONS_HELPER=disabled=1" >> $GITHUB_ENV
- name: Run PHPUnit tests
run: |
mkdir -p build/logs/phpunit
vendor/bin/paratest --processes="$TEST_PROCESSES" --log-junit build/logs/phpunit/junit.xml
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-php${{ matrix.php }}-lowest-deps
path: build/logs/phpunit
continue-on-error: true
route-security-databases:
name: Route security list and voter agree (PostgreSQL, MySQL, MariaDB)
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: --health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s --health-retries 20
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping -ppassword" --health-interval 5s --health-timeout 5s --health-retries 30
mariadb:
image: mariadb:10.11
env:
MARIADB_ROOT_PASSWORD: password
MARIADB_DATABASE: test
ports:
- 3307:3306
options: --health-cmd "healthcheck.sh --connect --innodb_initialized" --health-interval 5s --health-timeout 5s --health-retries 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
tools: composer
extensions: intl, bcmath, mbstring, pdo_sqlite, pdo_pgsql, pdo_mysql
coverage: none
ini-values: memory_limit=-1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-route-security-databases-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-route-security-databases-
continue-on-error: true
- name: Update project dependencies
run: composer update --no-progress --ansi --prefer-stable
- name: Disable deprecations helper
run: echo "SYMFONY_DEPRECATIONS_HELPER=disabled=1" >> $GITHUB_ENV
- name: PostgreSQL 16
run: vendor/bin/phpunit tests/Doctrine/Extension/ORM/RouteExtensionTest.php
env:
ROUTE_EXTENSION_DATABASE_URL: postgresql://postgres:password@127.0.0.1:5432/postgres?serverVersion=16
- name: MySQL 8.0
if: always()
run: vendor/bin/phpunit tests/Doctrine/Extension/ORM/RouteExtensionTest.php
env:
ROUTE_EXTENSION_DATABASE_URL: mysql://root:password@127.0.0.1:3306/test?serverVersion=8.0
- name: MariaDB 10.11
if: always()
run: vendor/bin/phpunit tests/Doctrine/Extension/ORM/RouteExtensionTest.php
env:
ROUTE_EXTENSION_DATABASE_URL: mariadb://root:password@127.0.0.1:3307/test?serverVersion=10.11.0-MariaDB
phpunit-symfony-next:
name: PHPUnit (Symfony NEXT ${{ matrix.symfony }}) (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
php:
- '8.5'
symfony:
- '8.2'
fail-fast: false
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
GD_CONFIGURE_OPTS: --enable-gd=shared,/usr --with-external-gd --with-jpeg --with-freetype
GD_LIBS: libjpeg-dev libpng-dev
GD_PATH: ext/gd
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, exif, xsl, gd
coverage: none
ini-values: memory_limit=-1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-symfony${{ matrix.symfony }}-
composer-php${{ matrix.php }}-
composer-
continue-on-error: true
- name: Update project dependencies
run: |
composer config extra.symfony.require ${{ matrix.symfony }}
composer config minimum-stability dev
composer config prefer-stable false
composer require --dev --no-update --ansi 'phpunit/phpunit:^13.3@stable' 'brianium/paratest:^7.26@stable'
composer update --no-progress --ansi
- name: Flag held back Symfony packages
env:
symfony_version: ${{ matrix.symfony }}
run: |
version_pattern=$symfony_version.x-dev
if [ "${symfony_version%.4}" != "$symfony_version" ]; then
current_major=${symfony_version%.4}
next_major=$((current_major + 1))
version_pattern=$version_pattern'|'$next_major.0.x-dev'|'dev-main
fi
version_pattern=$(echo "$version_pattern" | sed -r 's/\./\\./g')
symfony_packages=$(composer show symfony/* | tr -s ' ' '\t' | cut -f1-2 | grep -vE 'polyfill|contracts|mercure|debug|maker-bundle|monolog-bundle')
! echo "$symfony_packages" | grep -vE "$version_pattern"
continue-on-error: true
- name: Clear test app cache
run: |
pids=
for token in $(seq "$TEST_PROCESSES"); do
TEST_TOKEN=$token tests/Functional/app/bin/console cache:clear --ansi &
pids="$pids $!"
done
for pid in $pids; do wait "$pid"; done
- name: Run PHPUnit tests
run: |
mkdir -p build/logs/phpunit
vendor/bin/paratest --processes="$TEST_PROCESSES" --log-junit build/logs/phpunit/junit.xml
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-php${{ matrix.php }}-symfony${{ matrix.symfony }}
path: build/logs/phpunit
continue-on-error: true