-
Notifications
You must be signed in to change notification settings - Fork 19
329 lines (309 loc) · 11 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
name: CI
on:
push:
branches:
- develop
- "[0-9].x"
pull_request:
env:
PHP_VERSION: 8.3
CYPRESS_PROJECT_ID: w8t3fx
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432
mariadb:
image: mariadb:11
ports:
- 3306
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Verify MariaDB connection
env:
PORT: ${{ job.services.mariadb.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Verify Postgres connection
env:
PORT: ${{ job.services.postgres.ports[5432] }}
run: |
while ! pg_isready -h"127.0.0.1" -p"$PORT" > /dev/null 2> /dev/null; do
sleep 1
done
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install pv mariadb-client
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ env.PHP_VERSION }}
extensions: bcmath, ctype, fileinfo, json, mbstring, dom, ldap, pdo, tokenizer, xml, mysql, sqlite
coverage: pcov
- name: Copy .env
run: php -r "copy('.env.ci', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install php dependencies
run: |
composer self-update
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Migrate Database
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
DB_DATABASE: test
DB_USERNAME: root
DB_PASSWORD: password
run: php artisan migrate --no-interaction -vvv --force
- name: Execute code style check via Laravel Pint
run: vendor/bin/pint --test -v
- name: Execute tests (Unit and Feature tests) via PHPUnit
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
DB_DATABASE: test
DB_USERNAME: root
DB_PASSWORD: password
LOG_CHANNEL: stack
run: php artisan test --parallel --testsuite=Unit,Feature --coverage-clover=coverage.xml
- name: Execute tests (Unit, Feature and Integration tests) via PHPUnit
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
DB_DATABASE: test
DB_USERNAME: root
DB_PASSWORD: password
LOG_CHANNEL: stack
BBB_TEST_SERVER_HOST: ${{ secrets.BBB_TEST_SERVER_HOST }}
BBB_TEST_SERVER_SECRET: ${{ secrets.BBB_TEST_SERVER_SECRET }}
run: php artisan test --parallel --testsuite=Unit,Feature --coverage-clover=coverage.xml
- name: Execute tests (Unit and Feature tests) via PHPUnit using Postgres
env:
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.postgres.ports[5432] }}
DB_DATABASE: test
DB_USERNAME: user
DB_PASSWORD: password
LOG_CHANNEL: stack
run: php artisan test --parallel --testsuite=Unit,Feature
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
- name: Upload laravel logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: laravel.log
path: storage/logs/laravel.log
frontend-code-style-check:
name: Frontend Code Style Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Copy .env
run: php -r "copy('.env.example', '.env');"
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v4
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Check code formatting
run: npm run prettier
- name: Linting
run: npm run lint
docker-build:
name: Docker Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v6
with:
file: docker/app/Dockerfile
context: .
load: true
tags: pilos:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/pilos-image.tar
build-args: |
VITE_COVERAGE=true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pilos-image
path: /tmp/pilos-image.tar
frontend-tests:
name: Frontend Tests
runs-on: ubuntu-latest
needs: docker-build
strategy:
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: pilos-image
path: /tmp
- name: Load image
run: |
docker load --input /tmp/pilos-image.tar
- name: Copy .env
run: docker run --rm pilos:latest cat ./.env.ci > .env
- name: Generate key
run: |
docker run --rm \
--mount type=bind,source=${{ github.workspace }}/.env,target=/var/www/html/.env \
--entrypoint /bin/bash \
pilos:latest \
-c "chown www-data:www-data .env && pilos-cli key:generate"
- name: Adjust .env
run: |
sed -i 's/CONTAINER_IMAGE=.*/CONTAINER_IMAGE=pilos:latest/g' .env
sed -i 's|APP_URL=.*|APP_URL=http://localhost:9080|g' .env
sed -i 's|BBB_TEST_SERVER_HOST=.*|BBB_TEST_SERVER_HOST=${{ secrets.BBB_TEST_SERVER_HOST }}|g' .env
sed -i 's|BBB_TEST_SERVER_SECRET=.*|BBB_TEST_SERVER_SECRET=${{ secrets.BBB_TEST_SERVER_SECRET }}|g' .env
- name: Start app
run: docker compose -f compose.test.yml -f compose.test.ci.yml up -d
- name: Cypress run frontend tests
uses: cypress-io/github-action@v6
with:
wait-on: "http://localhost:9080" # Waits for above
group: "Frontend tests"
parallel: true
record: true
tag: ${{ github.event_name }}
env:
CYPRESS_PROJECT_ID: ${{ env.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
APP_URL: "http://localhost:9080"
TZ: "America/New_York"
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-screenshots
path: tests/Frontend/screenshots
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: coverage
system-tests:
name: System Tests
runs-on: ubuntu-latest
needs: docker-build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: pilos-image
path: /tmp
- name: Load image
run: |
docker load --input /tmp/pilos-image.tar
docker image ls -a
- name: Copy .env
run: docker run --rm pilos:latest cat ./.env.ci > .env
- name: Generate key
run: |
docker run --rm \
--mount type=bind,source=${{ github.workspace }}/.env,target=/var/www/html/.env \
--entrypoint /bin/bash \
pilos:latest \
-c "chown www-data:www-data .env && pilos-cli key:generate"
- name: Adjust .env
run: |
sed -i 's/CONTAINER_IMAGE=.*/CONTAINER_IMAGE=pilos:latest/g' .env
sed -i 's|APP_URL=.*|APP_URL=http://localhost:9080|g' .env
sed -i 's|BBB_TEST_SERVER_HOST=.*|BBB_TEST_SERVER_HOST=${{ secrets.BBB_TEST_SERVER_HOST }}|g' .env
sed -i 's|BBB_TEST_SERVER_SECRET=.*|BBB_TEST_SERVER_SECRET=${{ secrets.BBB_TEST_SERVER_SECRET }}|g' .env
- name: Start app
run: docker compose -f compose.test.yml -f compose.test.ci.yml up -d
- name: Cypress run system tests
uses: cypress-io/github-action@v6
with:
wait-on: "http://localhost:9080" # Waits for above
group: "System tests"
record: true
tag: ${{ github.event_name }}
project: ./tests/System
env:
CYPRESS_PROJECT_ID: ${{ env.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
APP_URL: "http://localhost:9080"
TZ: "America/New_York"
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-screenshots
path: tests/System/screenshots