-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
392 lines (352 loc) · 14.9 KB
/
action.yml
File metadata and controls
392 lines (352 loc) · 14.9 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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
name: "Start e2e environment"
description:
"Builds e2e environment with docker-compose and tests that services are
running."
inputs:
docker_compose_bundle_gha_artifact:
description:
Name of GitHub Actions artifact from which the Docker Compose bundle
can be found. If not set, the bundle is downloaded from jore4-docker-compose-bundle
Git repository's main branch.
required: false
default: null
ui_version:
description:
Version of ui to use (docker image tag). Set to "" if using the default
version.
required: false
default: ""
hasura_version:
description:
Version of hasura to use (docker image tag). Set to "" if using the
default version.
required: false
default: ""
auth_version:
description:
Version of auth to use (docker image tag). Set to "" if using the default
version.
required: false
default: ""
mbtiles_version:
description:
Version of mbtiles server to use (docker image tag). Set to "" if using
the default version.
required: false
default: ""
jore3importer_version:
description:
Version of jore3importer to use (docker image tag). Set to "" if using the
default version.
required: false
default: ""
testdb_version:
description:
Version of testdb to use (docker image tag). Set to "" if using the
default version.
required: false
default: ""
mssqltestdb_version:
description:
Version of mssqltestdb to use (docker image tag). Set to "" if using the
default version.
required: false
default: ""
mapmatching_version:
description:
Version of map matching service to use (docker image tag). Set to "" if
using the default version.
required: false
default: ""
mapmatchingdb_version:
description:
Version of map matching database to use (docker image tag). Set to "" if
using the default version.
required: false
default: ""
cypress_version:
description:
Version of cypress tests to use (docker image tag). Set to "" if using the
default version.
required: false
default: ""
hastus_version:
description:
Version of hastus importer to use (docker image tag). Set to "" if using
the default version.
required: false
default: ""
timetablesapi_version:
description:
Version of timetables api to use (docker image tag). Set to "" if using
the default version.
required: false
default: ""
tiamat_version:
description: Version of tiamat to use (docker image tag). Set to "" if using
the default version.
required: false
default: ""
custom_docker_compose:
description:
Path for an additional docker-compose file to be used when starting up the
environment. Can be used to e.g. run tests with the repository's own
docker-compose.custom.yml setup
required: false
default: ""
start_jore3_importer:
description: Should Jore3 importer be started along the rest of the e2e environment.
required: false
default: "false"
outputs:
e2e_source_commit_sha:
description: The commit SHA from which E2E tests were built from
value: ${{ steps.extract-metadata.outputs.e2e_source_commit_sha }}
runs:
using: "composite"
steps:
- name: Create directory for Docker Compose bundle
shell: bash
run: |
mkdir -p ${{ github.workspace }}/docker
- name: Download docker-compose bundle from GHA artifact
if: ${{ inputs.docker_compose_bundle_gha_artifact }}
uses: actions/download-artifact@v8
with:
name: jore4-docker-compose-bundle
path: ${{ github.workspace }}/docker
- name: Download e2e docker-compose bundle from jore4-docker-compose-bundle repository
if: ${{ !inputs.docker_compose_bundle_gha_artifact }}
run: |
curl -s -L https://github.com/HSLdevcom/jore4-docker-compose-bundle/archive/refs/heads/main.tar.gz \
| tar \
-xz \
-C ${{ github.workspace }}/docker \
--strip-components 2 \
--wildcards 'jore4-docker-compose-bundle-main/docker-compose/*'
shell: bash
- name: Set environment variables for Docker Compose bundle
shell: bash
run: |
cat >>${GITHUB_ENV} <<EOF
UI_DOCKER_IMAGE=${{ inputs.ui_version }}
HASURA_DOCKER_IMAGE=${{ inputs.hasura_version }}
AUTH_DOCKER_IMAGE=${{ inputs.auth_version }}
MBTILES_DOCKER_IMAGE=${{ inputs.mbtiles_version }}
JORE3IMPORTER_DOCKER_IMAGE=${{ inputs.jore3importer_version }}
TESTDB_DOCKER_IMAGE=${{ inputs.testdb_version }}
MSSQLTESTDB_DOCKER_IMAGE=${{ inputs.mssqltestdb_version }}
MAPMATCHING_DOCKER_IMAGE=${{ inputs.mapmatching_version }}
MAPMATCHINGDB_DOCKER_IMAGE=${{ inputs.mapmatchingdb_version }}
CYPRESS_DOCKER_IMAGE=${{ inputs.cypress_version }}
HASTUS_DOCKER_IMAGE=${{ inputs.hastus_version }}
TIMETABLESAPI_DOCKER_IMAGE=${{ inputs.timetablesapi_version }}
TIAMAT_DOCKER_IMAGE=${{ inputs.tiamat_version }}
EOF
# The services that take a long while to start are started first so they can start in the background while
# Docker images for the rest of the services are being downloaded
- name: Start e2e environment (pre)
run: |
docker compose \
-f ${{ github.workspace }}/docker/docker-compose.yml \
${{ inputs.custom_docker_compose != '' && format('-f {0}', inputs.custom_docker_compose) || '' }} \
${{ inputs.start_jore3_importer == 'true' && '--profile importer' || '' }} \
up -d \
jore4-testdb \
jore4-hasura \
jore4-tiamat \
jore4-auth \
shell: bash
- name: Start e2e environment (all remaining)
run: |
docker compose \
-f ${{ github.workspace }}/docker/docker-compose.yml \
${{ inputs.custom_docker_compose != '' && format('-f {0}', inputs.custom_docker_compose) || '' }} \
${{ inputs.start_jore3_importer == 'true' && '--profile importer' || '' }} \
up -d
shell: bash
- name: Show which versions of the docker images are spun up
run: docker ps
shell: bash
- name: Verify that UI is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail http://localhost:3302 --output /dev/null --silent"
- name: Verify that UI is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail https://e2e.local.jore.hsldev.com --output /dev/null --silent"
- name: Verify that postgresql is up and running
id: verify_postgresql_started
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "pg_isready -h localhost -p 6432"
# it takes a while for the database to start
retries: 50
- name: Show PostgreSQL logs
if: ${{ failure() && steps.verify_postgresql_started.outcome == 'failure' }}
run: |
docker logs testdb
shell: bash
- name: Verify that mssql testdb is up and running
id: verify_mssql_started
if: ${{ inputs.start_jore3_importer == 'true' }}
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
env:
SA_PASSWORD: "P@ssw0rd"
with:
# The IP address of MS SQL Docker container is retrieved using docker inspect because the container
# does not have a predefined or predictable hostname. A predefined hostname could be added in docker
# compose bundle.
command:
docker run
--rm
--network docker_jore4
$(docker inspect mssqltestdb | jq -r '.[0].Config.Image')
/opt/mssql-tools18/bin/sqlcmd
-C
-S $(docker inspect mssqltestdb | jq -r '.[0].NetworkSettings'.Networks.docker_jore4.IPAddress)
-U sa
-P "$SA_PASSWORD"
-d master
-Q "SELECT ''OK'';"
# it takes a while for the database to start
retries: 50
# on some rare occasions unfortunately this is failing...
- name: Show MSSQL logs
if: ${{ failure() && steps.verify_mssql_started.outcome == 'failure' }}
run: |
docker logs mssqltestdb
shell: bash
- name: Verify that hasura is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail http://localhost:3201/healthz --output /dev/null --silent"
- name: Verify that hasura is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail https://e2e.local.jore.hsldev.com/api/graphql/healthz --output
/dev/null --silent"
- name: Verify that auth backend is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail http://localhost:3200/actuator/health --output /dev/null
--silent"
- name: Verify that auth backend has access to database
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail http://localhost:3200/public/v1/login --output /dev/null
--silent"
- name: Verify that auth backend is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail https://e2e.local.jore.hsldev.com/api/auth/actuator/health --output
/dev/null --silent"
- name: Verify that jore3 importer is up and running standalone
if: ${{ inputs.start_jore3_importer == 'true' }}
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail http://localhost:3004/actuator/health --output /dev/null
--silent"
- name: Verify that cypress test container is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "docker exec cypress yarn cypress --version"
- name: Verify that mbtiles server is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail http://localhost:3203/services --output /dev/null
--silent"
- name: Verify that mbtiles server is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail https://e2e.local.jore.hsldev.com/api/mbtiles/services --output
/dev/null --silent"
- name: Verify that hastus importer is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail http://localhost:3008/actuator/health --output /dev/null
--silent"
- name: Verify that hastus importer is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail https://e2e.local.jore.hsldev.com/api/hastus/actuator/health --output
/dev/null --silent"
- name: Verify that timetables-api is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail http://localhost:3009/actuator/health --output
/dev/null --silent"
- name: Verify that map matching database is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "pg_isready -h localhost -p 6433"
- name: Verify that map matching server is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail http://localhost:3005/actuator/health --output /dev/null
--silent"
- name: Verify that map matching server is up and running through proxy
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
"curl --fail https://e2e.local.jore.hsldev.com/api/mapmatching/actuator/health
--output /dev/null --silent"
- name: Verify that tiamat is up and running standalone
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command: "curl --fail http://localhost:3010/actuator/health --output
/dev/null --silent"
- name: Reload Hasura metadata to re-establish connection to Tiamat
# Hasura remote schema will break if it cannot establish connection on startup. Force reload after everything is running.
env:
HASURA_PASSWORD: "hasura"
run: |
curl --header "Content-Type: application/json" \
--header "x-hasura-admin-secret: $HASURA_PASSWORD" \
--request POST \
--data '{"type":"reload_metadata","args":{"reload_remote_schemas":true,"reload_sources":true}}' \
localhost:3201/v1/metadata
shell: bash
- name: Show which versions of the docker images are spun up and healthy
run: docker ps
shell: bash
- name: Wait and make sure no container registers as unhealthy
run: |
unhealhtyContainerIds=""
# 30 tries, 10s wait time -> Max wait of 5 minutes
# Some of the services only report new HEALTH once per minute.
for i in {1..30}; do
unhealhtyContainerIds=$(docker ps -q --filter health=unhealthy)
if [[ -z "$unhealhtyContainerIds" ]]; then
echo "All containers are up and running fine"
exit 0
else
echo "One or more containers report an unhealthy status:"
docker container inspect "$unhealhtyContainerIds" | jq '.[] | { Name: .Name, Health: .State.Health }'
fi
echo "Wait for healthy services. Try $i/30. Waiting 10s for next try."
sleep 10s
done
for id in $unhealhtyContainerIds; do
echo "Container $id | $(docker container inspect $id | jq '.[0].Name') failed to register as healthy!"
echo "Container $id | logs start: ├─────────────────────────────────────────────────────"
docker logs $id
echo "Container $id | logs end: ─────────────────────────────────────────────────────┤"
done
exit 1
shell: bash
- name: Extract metadata
id: extract-metadata
shell: bash
run: |
echo e2e_source_commit_sha=$(docker inspect cypress -f '{{ .Config.Labels.git_sha }}') >> ${GITHUB_OUTPUT}