-
-
Notifications
You must be signed in to change notification settings - Fork 7
390 lines (385 loc) · 15 KB
/
php.yml
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
# For details of what checks are run for PRs please refer below
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: PHP CI
on:
push:
branches: ["main", "master", "next"]
tags: ["v*"]
pull_request:
workflow_dispatch:
schedule:
# schedule dayly tests, since dependencies are not intended to be locked
# this means: at 23:42
- cron: '42 23 * * *'
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
env:
PHP_VERSION_LATEST: "8.3"
PHP_PROJECT_EXT: dom,json,libxml # via `composer info -pt`
REPORTS_DIR: CI_reports
TESTS_REPORTS_ARTIFACT: tests-reports
TYPES_REPORTS_ARTIFACT: types-reports
jobs:
composer-validate:
name: Composer Validate
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: 'composer:v2'
coverage: none
- name: Validate composer.json and composer.lock
run: composer validate --no-interaction
phpunit:
name: PHPUnit (${{ matrix.os}}, php${{ matrix.php }}, ${{ matrix.dependencies }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
php:
- "8.3" # highest supported
- "8.2"
- "8.1" # lowest supported
dependencies: [ "lowest", "highest" ]
include:
- # Windows highest
os: windows-latest
php: "8.3"
dependencies: "highest"
- # MacOS highest
os: macos-latest
php: "8.3"
dependencies: "highest"
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: dir setup
run: mkdir ${{ env.REPORTS_DIR }}
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: 'composer:v2'
coverage: pcov
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.*', 'tools/phpunit/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.dependencies }}-
composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-
composer-${{ github.job }}-${{ runner.os }}-
- name: Install PHPUnit
run: composer install --prefer-dist --no-interaction --no-progress
working-directory: tools/phpunit
- name: Install (${{ matrix.dependencies }})
shell: bash
run: |
# removing security-foo here is fine, as no code is run, only parsed
composer remove --dev 'roave/security-advisories' \
--no-update --no-install
composer config platform.php ${{ matrix.php }}
composer update \
--no-interaction --no-progress \
--prefer-dist \
${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }}
- name: Run PHPUnit tests
run: >
php
-d zend.assertions=1
-d assert.exception=1
-d display_errors=On
-d error_reporting=-1
-d log_errors_max_len=0
-d memory_limit=-1
tools/phpunit/vendor/phpunit/phpunit/phpunit
--no-progress
--log-junit='${{ env.REPORTS_DIR }}/tests/${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml'
--coverage-clover='${{ env.REPORTS_DIR }}/coverage/${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.clover.xml'
- name: Artifact reports
if: ${{ ! cancelled() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: '${{ env.TESTS_REPORTS_ARTIFACT }}_${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}'
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error
report-coverage:
name: Publish test coverage
needs: [ "phpunit" ]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: fetch test artifacts
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v4
with:
pattern: '${{ env.TESTS_REPORTS_ARTIFACT }}_*'
merge-multiple: true
path: ${{ env.REPORTS_DIR }}
- name: Run codacy-coverage-reporter
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets
if: ${{ env.CODACY_PROJECT_TOKEN != '' }}
# see https://github.com/codacy/codacy-coverage-reporter-action
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*.clover.xml
code-checker:
name: Code Analysis p${{ matrix.php }} c${{ matrix.composer }} ${{ matrix.dependencies }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
php:
- "8.3" # highest supported
- "8.1" # lowest supported
composer:
- "v2" # latest 2.x
- "2.6"
- "2.5"
- "2.4"
- "2.3" # lowest supported
dependencies: [ "highest" ]
include:
- # lowest supported
php: "8.1"
composer: "2.3"
dependencies: "lowest"
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: composer:${{ matrix.composer }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.*', 'tools/psalm/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.dependencies }}-
composer-${{ github.job }}-${{ runner.os }}-php${{ matrix.php }}-
composer-${{ github.job }}-${{ runner.os }}-
- name: Install psalm
run: composer install --no-interaction --no-progress --prefer-dist
working-directory: tools/psalm
- name: Install (composer:~${{ matrix.composer }}.0 ${{ matrix.dependencies }})
run: |
# removing security-foo here is fine, as no code is run, only parsed
composer remove --dev 'roave/security-advisories' \
--no-update --no-install
composer config platform.php ${{ matrix.php }}
composer update \
--no-interaction --no-progress \
--prefer-dist \
${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} \
--with='composer/composer:~${{ matrix.composer }}.0'
- name: Run Psalm tests
run: >
php tools/psalm/vendor/vimeo/psalm/psalm
--no-diff
--no-cache
--long-progress
--output-format=github
--report='${{ env.REPORTS_DIR }}/psalm/p${{ matrix.php }}_c${{ matrix.composer }}_${{ matrix.dependencies }}.junit.xml'
--stats
- name: Artifact reports
if: ${{ ! cancelled() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: '${{ env.TYPES_REPORTS_ARTIFACT }}_php${{ matrix.php }}_composer${{ matrix.composer }}_${{ matrix.dependencies }}'
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error
composer-unused:
name: ComposerUnused
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: 'composer:v2'
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-unused/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-
- name: Install composer-unused
run: composer install --prefer-dist --no-interaction --no-progress
working-directory: tools/composer-unused
- name: Install dependencies
run: composer install --no-dev --prefer-dist --no-interaction --no-progress
- name: Run composer-unused tests
run: >
php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused
--no-progress
--no-interaction
--excludeDir=tools
composer-require-checker:
name: ComposerRequireChecker
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: 'composer:v2'
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-require-checker/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-
- name: Install composer-require-checker
run: composer install --prefer-dist --no-interaction --no-progress
working-directory: tools/composer-require-checker
- name: Install dependencies
run: composer install --no-dev --prefer-dist --no-interaction --no-progress
- name: Run composer-require-checker tests
run: >
php tools/composer-require-checker/vendor/maglnet/composer-require-checker/bin/composer-require-checker
--no-interaction
coding-standards:
name: Coding Standards
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
extensions: ${{ env.PHP_PROJECT_EXT }}
tools: 'composer:v2'
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/php-cs-fixer/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-
- name: Install PHP-CS-Fixer
run: composer install --prefer-dist --no-interaction --no-progress
working-directory: tools/php-cs-fixer
- name: Run PHP-CS-Fixer tests
run: >
php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
fix
--dry-run
--diff
--using-cache=no
--show-progress=dots
--no-interaction
composer-normalize:
name: Composer normalize
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
tools: 'composer:v2'
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.composer-cache.outputs.dir }}
# see https://github.com/actions/cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-normalize/composer.*') }}
restore-keys: |
composer-${{ github.job }}-${{ runner.os }}-
- name: Install composer-normalize
run: composer install --prefer-dist --no-interaction --no-progress
working-directory: tools/composer-normalize
- name: Run composer-normalize tests
run: >
composer -d tools/composer-normalize
normalize
--dry-run
--diff
--no-check-lock
--no-update-lock
--no-interaction
$PWD/composer.json