forked from cakephp/cakephp
-
Notifications
You must be signed in to change notification settings - Fork 2
266 lines (221 loc) · 8.49 KB
/
ci.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
name: CI
on:
push:
branches:
- '4.x'
- '4.next'
- '5.x'
- '5.next'
pull_request:
branches:
- '*'
workflow_dispatch:
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
testsuite:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3']
db-type: [sqlite, pgsql]
prefer-lowest: ['']
include:
- php-version: '8.1'
db-type: 'mariadb'
- php-version: '8.1'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'
- php-version: '8.2'
db-type: 'mysql'
- php-version: '8.3'
db-type: 'mysql'
- php-version: '8.4'
db-type: 'mysql'
services:
redis:
image: redis
ports:
- 6379/tcp
memcached:
image: memcached
ports:
- 11211/tcp
steps:
- name: Setup MySQL 8.0
if: matrix.db-type == 'mysql'
run: |
sudo service mysql start
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
- name: Setup PostgreSQL latest
if: matrix.db-type == 'pgsql'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres
- uses: getong/[email protected]
if: matrix.db-type == 'mariadb'
with:
mysql database: 'cakephp'
mysql root password: 'root'
- uses: actions/checkout@v4
- 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: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Get date part for cache key
id: key-date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
- name: Install packages
run: |
sudo locale-gen da_DK.UTF-8
sudo locale-gen de_DE.UTF-8
- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
elif ${{ matrix.php-version == '8.4' }}; then
composer update --ignore-platform-req=php
else
composer update
fi
- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '8.1' && 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'] }}
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
export CODECOVERAGE=1
vendor/bin/phpunit --display-deprecations --display-warnings --display-incomplete --display-skipped --coverage-clover=coverage.xml
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --display-deprecations --display-warnings --display-incomplete --display-skipped --testsuite=database
vendor/bin/phpunit --display-deprecations --display-warnings --display-incomplete --display-skipped --testsuite=globalfunctions --coverage-clover=coverage-functions.xml
else
vendor/bin/phpunit --display-deprecations --display-warnings
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --display-deprecations --display-warnings --testsuite=database
fi
- name: Submit code coverage
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v4
with:
files: coverage.xml,coverage-functions.xml
token: ${{ secrets.CODECOV_TOKEN }}
testsuite-windows:
runs-on: windows-2022
name: Windows - PHP 8.1 & SQL Server
env:
EXTENSIONS: mbstring, intl, apcu, redis, pdo_sqlsrv
PHP_VERSION: '8.1'
steps:
- uses: actions/checkout@v4
- 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@v4
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: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $env:GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
- name: Composer install
run: composer update
- name: Run PHPUnit
env:
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
run: |
set CAKE_DISABLE_GLOBAL_FUNCS=1
vendor/bin/phpunit --display-incomplete --display-skipped
- name: Run PHPUnit (autoquote enabled)
env:
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
run: |
set CAKE_TEST_AUTOQUOTE=1
vendor/bin/phpunit --display-incomplete --display-skipped --testsuite=database
cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-22.04
env:
PHIVE_KEYS: 'CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5'
PHPSTAN_TESTS: 1
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, intl
coverage: none
tools: phive, cs2pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
uses: ramsey/composer-install@v3
- name: Install PHP tools with phive.
run: 'phive install --trust-gpg-keys "$PHIVE_KEYS"'
- name: Run phpcs
if: always()
run: vendor/bin/phpcs --report=checkstyle | cs2pr
- name: Run psalm
if: always()
run: tools/psalm --output-format=github
- name: Run phpstan
if: always()
run: vendor/bin/phpstan analyse --error-format=github
- name: Run phpstan for tests
if: env.PHPSTAN_TESTS
run: vendor/bin/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: Run PHPStan for split packages
if: always()
run: php contrib/validate-split-packages-phpstan.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