-
Notifications
You must be signed in to change notification settings - Fork 42
281 lines (230 loc) · 10 KB
/
ci.yaml
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
name: Integration and Functional tests
on:
pull_request:
branches:
- master
- staging
- dev
jobs:
setup:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php-versions: ['7.4']
steps:
# REMOVE RESIDUAL CONTAINERS ( for local debug with act only )
- name: Remove all mysql containers when working with act
if: ${{ env.ACT }}
run: |
CONTAINERS=$(docker ps -a -q --filter ancestor=mariadb:10.4.10)
if [ ! -z "$CONTAINERS" ]; then
docker rm -f $CONTAINERS
else
echo "No containers to remove."
fi
- name: Checkout code
uses: actions/checkout@v4
# INSTALL DEPENDENCIES ----------------
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@verbose
with:
php-version: ${{ matrix.php-versions }}
tools: composer:2.2
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.11.0'
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: |
${{ env.dir }}
./vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# INSTALL PACKAGES ----------------
- name: Clean node_modules
run: rm -rf node_modules
- name: Install NPM packages
run: npm ci
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
# UPLOAD CACHED DIRECTORIES ----------------
- name: Upload Vendor Directory as Artifact
uses: actions/upload-artifact@v4
with:
name: vendor-dir
path: vendor/
phpStan:
needs: setup
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# GET CACHED DIRECTORIES ----------------
- name: Download Vendor Directory
uses: actions/download-artifact@v4
with:
name: vendor-dir
path: vendor/
# INSTALL DEPENDENCIES ----------------
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@verbose
with:
php-version: ${{ matrix.php-versions }}
tools: composer:2.2
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json
- name: Set executable permissions for PHPStan
run: chmod +x ./vendor/bin/phpstan
# RUN PHPSTAN ----------------
- name: Run PHPStan
run: ./vendor/bin/phpstan analyse src
symfony-tests:
needs: setup
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# GET CACHED DIRECTORIES ----------------
- name: Download Vendor Directory
uses: actions/download-artifact@v4
with:
name: vendor-dir
path: vendor/
# INSTALL DEPENDENCIES ----------------
- name: Install MySQL Client
run: sudo apt-get update && sudo apt-get install -y mysql-client
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@verbose
with:
php-version: ${{ matrix.php-versions }}
tools: composer:2.2
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json
# SET ENVIRONMENT VARIABLES ----------------
- name: Set up test environment variables
run: cp .env.test .env
# START SERVICES ----------------
- name: Set up MySQL
uses: getong/[email protected]
with:
host port: 3306 # Optional, default value is 3306. The port of host
container port: 3306 # Optional, default value is 3306. The port of container
character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
mariadb version: '10.4.10' # Optional, default value is "latest". The version of the MySQL
mysql database: 'symfony' # Optional, default value is "test". The specified database which will be created
mysql root password: 'secret' # Required if "mysql user" is empty, default is empty. The root superuser password
mysql user: 'user' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
mysql password: 'password' # Required if "mysql user" exists. The password for the "mysql user"
- name: Wait for MySQL to become available
run: |
until mysql -h 127.0.0.1 -u root -psecret -e "SELECT 1"; do
echo 'Waiting for MySQL...'
sleep 1
done
# RUN MIGRATIONS ----------------
- name: Run migrations
run: php bin/console doctrine:migrations:migrate --no-interaction
# RUN TESTS ----------------
- name: Run unit and functional tests
run: |
php ./vendor/bin/phpunit --configuration phpunit.xml.dist
cypress-tests:
needs: setup
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# GET CACHED DIRECTORIES ----------------
- name: Download Vendor Directory
uses: actions/download-artifact@v4
with:
name: vendor-dir
path: vendor/
# INSTALL DEPENDENCIES ----------------
- name: Install MySQL Client
run: sudo apt-get update && sudo apt-get install -y mysql-client
- name: Install Cypress dependencies
run: sudo apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@verbose
with:
php-version: ${{ matrix.php-versions }}
tools: composer:2.2
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.11.0'
- name: Install Symfony CLI globally
run: |
curl -sS https://get.symfony.com/cli/installer | bash
sudo mv /home/runner/.symfony5/bin/symfony /usr/local/bin/symfony
# SET ENVIRONMENT VARIABLES ----------------
- name: Set up test environment variables
run: cp .env.test .env
# START SERVICES ----------------
- name: Set up MySQL
uses: getong/[email protected]
with:
host port: 3306 # Optional, default value is 3306. The port of host
container port: 3306 # Optional, default value is 3306. The port of container
character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
mariadb version: '10.4.10' # Optional, default value is "latest". The version of the MySQL
mysql database: 'symfony' # Optional, default value is "test". The specified database which will be created
mysql root password: 'secret' # Required if "mysql user" is empty, default is empty. The root superuser password
mysql user: 'user' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
mysql password: 'password' # Required if "mysql user" exists. The password for the "mysql user"
- name: Wait for MySQL to become available
run: |
until mysql -h 127.0.0.1 -u root -psecret -e "SELECT 1"; do
echo 'Waiting for MySQL...'
sleep 1
done
- name: Start Symfony server
run: symfony server:start --no-tls -d --port=8000
# RUN MIGRATIONS ----------------
- name: Run migrations
run: php bin/console doctrine:migrations:migrate --no-interaction
# FILL DATABASE ----------------
- name: Run fixture
run: php bin/console doctrine:fixtures:load --no-interaction
# BUILD FRONT ----------------
- name : install packages
run: npm install
- name: Enable verbose npm logging
run: npm config set loglevel verbose
- name: Build front-end assets
run: ./node_modules/.bin/encore production --progress
# RUN CYPRESS TESTS ----------------
- name: Run Cypress tests
run: CYPRESS_BASE_URL=http://localhost:8000 npm run cy:test:main
# CHANGE ENV VARIABLES ----------------
- name: Set up test environment variables
run: cp .env.oidc.test .env.test
# START KEYCLOAK ----------------
- name: Start Keycloak
run: |
docker run -d \
--name keycloak \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=admin \
-e DB_VENDOR=h2 \
-e KEYCLOAK_IMPORT=/config/realm-export.json \
-v ${{ github.workspace }}/.docker/keycloak/config/realm-export.localhost.json:/config/realm-export.json \
-p 8080:8080 \
--user root \
jboss/keycloak:16.1.1
# Wait for Keycloak to start
- name: Wait for Keycloak to be ready
run: |
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/auth); do
printf '.'
sleep 5
done
# RUN CYPRESS TESTS ----------------
- name: Run Cypress tests
run: CYPRESS_BASE_URL=http://localhost:8000 CYPRESS_KEYCLOAK_URL=http://localhost:8080 npm run cy:test:oidc