-
Notifications
You must be signed in to change notification settings - Fork 40
344 lines (328 loc) · 10.4 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
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
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
schedule:
- cron: '33 2 * * 1' # weekly, on Monday morning
env:
MAILER_DSN: null://null
ILIOS_LOCALE: en
ILIOS_SECRET: ThisTokenIsNotSoSecretChangeIt
ILIOS_FILE_SYSTEM_STORAGE_PATH: /tmp
SYMFONY_DEPRECATIONS_HELPER: disabled=1
MESSENGER_TRANSPORT_DSN: doctrine://default
latest_php: 8.3
DOCKER_BUILDKIT: 1
jobs:
code_style:
name: Code Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ env.latest_php }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.latest_php }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: lint PHP
run: vendor/bin/phpcs
- name: lint twig
run: bin/console lint:twig templates custom
- name: lint yaml
run: |
vendor/bin/yaml-lint .gitpod.yml
vendor/bin/yaml-lint .github
vendor/bin/yaml-lint config
vendor/bin/yaml-lint docker
vendor/bin/yaml-lint docs
vendor/bin/yaml-lint compose.yaml
- name: phpstan
run: |
bin/console cache:warmup --env=test
vendor/bin/phpstan analyse --no-progress
tests:
name: PHPUnit Tests
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: pcov
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run Tests
run: vendor/bin/phpunit --coverage-clover build/coverage.xml
- name: Archive Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-output
path: build/coverage.xml
overwrite: true
retention-days: 1
test_migrations_against_mysql:
name: Test Migrations Against MySQL
needs: code_style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ env.latest_php }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.latest_php }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Drop, Create, Migrate, and Validate DB
env:
ILIOS_DATABASE_URL: mysql://root:root@127.0.0.1:3306/ilios?serverVersion=8.0
run: |
sudo systemctl start mysql.service
bin/console doctrine:database:drop --if-exists --force
bin/console doctrine:database:create
bin/console doctrine:migrations:migrate --no-interaction
bin/console doctrine:schema:validate
run_twice:
name: PHPUnit Run Twice
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: First Run
run: vendor/bin/phpunit --group twice
- name: Second Run
run: vendor/bin/phpunit --group twice
build_amd_containers:
name: Build Containers (amd64)
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
image:
- php-apache
- nginx
- fpm
- fpm-dev
- admin
- update-frontend
- consume-messages
- mysql
- mysql-demo
- opensearch
- redis
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
target: ${{ matrix.image }}
push: false
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar
tags: ${{ matrix.image }}:testing
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.image }}-image
path: /tmp/${{ matrix.image }}.tar
retention-days: 1
build_arm_containers:
name: Build Containers (arm64)
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
image:
- php-apache
- nginx
- fpm
- fpm-dev
- admin
- update-frontend
- consume-messages
- mysql
- mysql-demo
- opensearch
- redis
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
target: ${{ matrix.image }}
push: false
run_containers:
name: Run and Test Containers
needs: build_amd_containers
runs-on: ubuntu-latest
env:
ILIOS_DATABASE_URL: mysql://root:root@127.0.0.1:3306/ilios?serverVersion=8.0
ILIOS_SECRET: DifferentSecret
ILIOS_FILE_SYSTEM_STORAGE_PATH: /tmp
steps:
- uses: actions/checkout@v4
- name: Drop, Create Database to use everywhere else
run: |
sudo systemctl start mysql.service
mysql -uroot -proot -e "DROP DATABASE IF EXISTS ilios"
mysql -uroot -proot -e "CREATE DATABASE ilios"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/
- name: Load Images
run: |
docker load --input /tmp/php-apache-image/php-apache.tar
docker load --input /tmp/nginx-image/nginx.tar
docker load --input /tmp/fpm-image/fpm.tar
docker load --input /tmp/fpm-dev-image/fpm-dev.tar
docker load --input /tmp/admin-image/admin.tar
docker load --input /tmp/update-frontend-image/update-frontend.tar
docker load --input /tmp/consume-messages-image/consume-messages.tar
docker load --input /tmp/mysql-image/mysql.tar
docker load --input /tmp/mysql-demo-image/mysql-demo.tar
docker load --input /tmp/opensearch-image/opensearch.tar
docker load --input /tmp/redis-image/redis.tar
docker image ls -a
- name: Consume Messages
run: |
docker run -d --name ilios-consume-messages -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH consume-messages:testing
docker ps | grep -q ilios-consume-messages
- name: Apache PHP
run: |
docker run -d --name ilios-php-apache -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH php-apache:testing
docker ps | grep -q ilios-php-apache
docker exec ilios-php-apache php /var/www/ilios/bin/console monitor:health
- name: Nginx
run: |
docker run -d --name ilios-nginx nginx:testing
sleep 15
docker ps --filter "health=healthy" | grep -q ilios-nginx
- name: FPM
run: |
docker run -d --name ilios-fpm -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH fpm:testing
docker ps | grep -q ilios-fpm
docker exec ilios-fpm php bin/console monitor:health
- name: FPM Dev
run: |
docker run -d --name ilios-fpm-dev -e ILIOS_SECRET -e ILIOS_DATABASE_URL -e ILIOS_FILE_SYSTEM_STORAGE_PATH fpm-dev:testing
docker ps | grep -q ilios-fpm-dev
docker exec ilios-fpm-dev php bin/console monitor:health
- name: Admin
run: |
docker run -d --name ilios-admin admin:testing
docker ps | grep -q ilios-admin
- name: MySQL
run: |
docker run -d --name ilios-mysql mysql:testing
docker ps | grep -q ilios-mysql
- name: MySQL Demo
run: |
docker run -d --name ilios-mysql-demo mysql-demo:testing
docker ps | grep -q ilios-mysql-demo
- name: OpenSearch
run: |
docker run -d --name ilios-opensearch opensearch:testing
docker ps | grep -q ilios-opensearch
- name: REdis
run: |
docker run -d --name ilios-redis redis:testing
docker ps | grep -q ilios-redis
- name: Output Docker Logs
if: failure()
run: |
docker logs ilios-php-apache
docker logs ilios-nginx
docker logs ilios-fpm
docker logs ilios-fpm-dev
docker logs ilios-admin
docker logs ilios-update-frontend
docker logs ilios-consume-messages
docker logs ilios-mysql
docker logs ilios-mysql-demo
docker logs ilios-opensearch
docker logs ilios-redis
check_setup_command:
name: Setup Command
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: Run Setup Command
run: bin/setup
check_update_frontend_command:
name: Update Frontend Command
needs: code_style
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.2, 8.3]
steps:
- uses: actions/checkout@v4
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: apcu
- name: install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run Update Frontend
run: bin/console ilios:update-frontend
coverage:
name: Upload Code Coverage
runs-on: ubuntu-latest
if: ${{ always() }}
needs: tests
steps:
- uses: actions/checkout@v4
- name: Download Coverage Report
uses: actions/download-artifact@v4
with:
name: coverage-output
- run: ls -lh coverage.xml
- name: Upload to CodeClimate
uses: paambaati/codeclimate-action@v6.0.0
with:
coverageLocations:
coverage.xml:clover
env:
CC_TEST_REPORTER_ID: c2e072c72320901c23741e4c25bfd28e149441b5a19ba9abb8cf80ca0363ff9a