forked from cakephp/cakephp
-
Notifications
You must be signed in to change notification settings - Fork 0
378 lines (315 loc) · 12.3 KB
/
Copy pathci.yml
File metadata and controls
378 lines (315 loc) · 12.3 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
name: CI
on:
push:
branches:
- '4.x'
- '5.x'
- '5.next'
pull_request:
branches:
- '*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
testsuite:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.5']
db-type: [sqlite, pgsql]
dependencies: ['highest']
include:
- php-version: '8.2'
db-type: 'mariadb'
dependencies: highest
- php-version: '8.2'
db-type: 'mysql'
dependencies: 'lowest'
- php-version: '8.2'
db-type: 'mysql'
dependencies: highest
- php-version: '8.3'
db-type: 'mysql'
dependencies: highest
- php-version: '8.4'
db-type: 'mysql'
dependencies: highest
- php-version: '8.5'
db-type: 'mysql'
dependencies: highest
services:
redis:
image: redis
ports:
- 6379/tcp
memcached:
image: memcached
ports:
- 11211/tcp
redis-cluster:
image: grokzen/redis-cluster:6.2.1
ports:
- 7000:7000
- 7001:7001
options: >-
--health-cmd "redis-cli -p 7000 ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Setup MySQL 8.4
if: matrix.db-type == 'mysql' && matrix.dependencies == 'highest' && matrix.php-version != '8.3'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:8.4
- name: Setup MySQL 8.0
if: matrix.db-type == 'mysql' && matrix.dependencies == 'highest' && matrix.php-version == '8.3'
run: |
sudo service mysql start
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
- name: Setup MySQL 5.7
if: matrix.db-type == 'mysql' && matrix.dependencies == 'lowest'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
- name: Setup PostgreSQL with PostGIS
if: matrix.db-type == 'pgsql'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgis/postgis:18-3.6
- name: Setup MariaDB 11.8
if: matrix.db-type == 'mariadb'
run: |
docker run -d --name=mariadb \
-e MARIADB_ROOT_PASSWORD=root \
-e MARIADB_DATABASE=cakephp \
-p 3306:3306 \
--health-cmd="mariadb-admin ping -h 127.0.0.1 -proot || exit 1" \
--health-interval=10s \
--health-timeout=5s \
--health-retries=10 \
mariadb:11.8
echo "Waiting for MariaDB to be ready..."
for i in {1..60}; do
if docker exec mariadb mariadb-admin ping -h 127.0.0.1 -proot >/dev/null 2>&1; then
echo "MariaDB is responding."
break
fi
sleep 2
done
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }}
ini-values: apc.enable_cli = 1, zend.assertions = 1
coverage: pcov
- name: Install packages
run: |
sudo locale-gen da_DK.UTF-8
sudo locale-gen de_DE.UTF-8
- name: Composer install
uses: ramsey/composer-install@v4
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: "${{ matrix.composer-options }}"
- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '8.2' && matrix.db-type == 'mysql'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPUnit
env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
REDIS_CLUSTER_NODES: "127.0.0.1:7000,127.0.0.1:7001"
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
if [[ ${{ matrix.php-version }} == '8.2' && ${{ matrix.dependencies }} == 'highest' ]]; then
export CODECOVERAGE=1
vendor/bin/phpunit --display-all-issues --fail-on-all-issues --do-not-fail-on-skipped --do-not-fail-on-incomplete --testsuite=cakephp --coverage-clover=coverage.xml
vendor/bin/phpunit --display-all-issues --fail-on-all-issues --do-not-fail-on-skipped --do-not-fail-on-incomplete --testsuite=database --coverage-clover=coverage-database.xml
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --display-all-issues --fail-on-all-issues --do-not-fail-on-skipped --do-not-fail-on-incomplete --testsuite=database
vendor/bin/phpunit --display-all-issues --fail-on-all-issues --do-not-fail-on-skipped --do-not-fail-on-incomplete --do-not-fail-on-warning --testsuite=globalfunctions --coverage-clover=coverage-functions.xml
elif [[ ${{ matrix.php-version }} == '8.2' && ${{ matrix.dependencies }} == 'lowest' ]]; then
vendor/bin/phpunit
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --testsuite=database
else
vendor/bin/phpunit --display-phpunit-notices --display-phpunit-deprecations --display-deprecations --display-warnings
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --display-phpunit-notices --display-phpunit-deprecations --display-deprecations --display-warnings --testsuite=database
fi
- name: Submit code coverage
if: matrix.php-version == '8.2'
uses: codecov/codecov-action@v7
with:
files: coverage.xml,coverage-database.xml,coverage-functions.xml
token: ${{ secrets.CODECOV_TOKEN }}
testsuite-windows:
runs-on: windows-2022
name: Windows - PHP 8.2 & SQL Server
env:
EXTENSIONS: mbstring, intl, apcu, redis, pdo_sqlsrv
PHP_VERSION: '8.2'
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Get date part for cache key
id: key-date
run: echo "date=$(date +'%Y-%m')" >> $env:GITHUB_OUTPUT
- name: Setup PHP extensions cache
id: php-ext-cache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.EXTENSIONS }}
key: ${{ steps.key-date.outputs.date }}
- name: Cache PHP extensions
uses: actions/cache@v6.1.0
with:
path: ${{ steps.php-ext-cache.outputs.dir }}
key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli = 1, zend.assertions = 1, extension = php_fileinfo.dll
coverage: none
- name: Setup SQLServer
run: |
# MSSQLLocalDB is the default SQL LocalDB instance
SqlLocalDB start MSSQLLocalDB
SqlLocalDB info MSSQLLocalDB
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;"
- name: Composer install
uses: ramsey/composer-install@v4
- name: Run PHPUnit
env:
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
run: |
set CAKE_DISABLE_GLOBAL_FUNCS=1
vendor/bin/phpunit --display-incomplete
- name: Run PHPUnit (autoquote enabled)
env:
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
run: |
set CAKE_TEST_AUTOQUOTE=1
vendor/bin/phpunit --display-incomplete --testsuite=database
cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-24.04
env:
PHIVE_KEYS: 'CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5,99BF4D9A33D65E1E'
PHPSTAN_TESTS: 1
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, pcntl
coverage: none
tools: phive, cs2pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
uses: ramsey/composer-install@v4
- name: Cache phive tools
uses: actions/cache@v6.1.0
with:
path: |
~/.phive
tools
key: ${{ runner.os }}-phive-${{ hashFiles('.phive/phars.xml') }}
restore-keys: ${{ runner.os }}-phive-
- name: Install PHP tools with phive.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: 'phive install --trust-gpg-keys "$PHIVE_KEYS"'
- name: Run phpstan
if: always()
run: tools/phpstan analyse --error-format=github
- name: Run Psalm
if: always()
run: tools/psalm --output-format=github
- name: Setup phpcs cache
if: always()
uses: actions/cache@v6.1.0
with:
path: ${{ runner.temp }}/phpcs.cache
key: ${{ runner.os }}-phpcs-${{ hashFiles('phpcs.xml', 'composer.lock') }}
restore-keys: ${{ runner.os }}-phpcs-
- name: Run phpcs
if: always()
run: vendor/bin/phpcs --parallel=8 --cache=${{ runner.temp }}/phpcs.cache --report=checkstyle | cs2pr
- name: Run phpstan for tests
if: env.PHPSTAN_TESTS
run: tools/phpstan analyse -c tests/phpstan.neon --error-format=github
- name: Run class deprecation aliasing validation script
if: always()
run: php contrib/validate-deprecation-aliases.php
- name: Run composer.json validation for split packages
if: always()
run: php contrib/validate-split-packages.php
- name: Prefer lowest check
if: matrix.prefer-lowest == 'prefer-lowest'
run: composer require --dev dereuromark/composer-prefer-lowest && vendor/bin/validate-prefer-lowest -m
- name: Setup rector cache
if: always()
uses: actions/cache@v6.1.0
with:
path: ${{ runner.temp }}/rector
key: ${{ runner.os }}-rector-${{ hashFiles('rector.php', 'composer.lock') }}
restore-keys: ${{ runner.os }}-rector-
- name: Create rector cache dir
if: always()
run: mkdir -p ${{ runner.temp }}/rector
- name: Run rector
if: always()
env:
RECTOR_CACHE_DIR: ${{ runner.temp }}/rector
run: composer rector-setup && composer rector-check
- name: Run StructArmed
if: always()
run: vendor/bin/structarmed analyze src
split-packages-stan:
name: Static Analysis for Split Packages
runs-on: ubuntu-24.04
env:
PHIVE_KEYS: 'CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5,99BF4D9A33D65E1E'
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl
coverage: none
tools: phive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
uses: ramsey/composer-install@v4
- name: Cache phive tools
uses: actions/cache@v6.1.0
with:
path: |
~/.phive
tools
key: ${{ runner.os }}-phive-${{ hashFiles('.phive/phars.xml') }}
restore-keys: ${{ runner.os }}-phive-
- name: Install PHP tools with phive.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: 'phive install --trust-gpg-keys "$PHIVE_KEYS"'
- name: Run phpstan for split packages
run: php contrib/validate-split-packages-phpstan.php