Skip to content

Commit 56b328d

Browse files
author
Janne Rönkkö
committed
DEV: Inline setup e2e action
1 parent 0bbdf07 commit 56b328d

File tree

1 file changed

+246
-19
lines changed

1 file changed

+246
-19
lines changed

.github/workflows/shared-run-e2e.yml

Lines changed: 246 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,253 @@ jobs:
153153
matrix:
154154
containers: [1, 2, 3, 4]
155155
steps:
156-
- name: Start e2e env
157-
id: start-e2e-env
158-
uses: HSLdevcom/jore4-tools/github-actions/setup-e2e-environment@setup-e2e-environment-v9
156+
#- name: Start e2e env
157+
# id: start-e2e-env
158+
# uses: HSLdevcom/jore4-tools/github-actions/setup-e2e-environment@setup-e2e-environment-v9
159+
# with:
160+
# docker_compose_bundle_gha_artifact: "${{ inputs.docker_compose_bundle_gha_artifact }}"
161+
# ui_version: "${{ inputs.ui_version }}"
162+
# cypress_version: "${{ inputs.cypress_version }}"
163+
# hasura_version: "${{ inputs.hasura_version }}"
164+
# auth_version: "${{ inputs.auth_version }}"
165+
# mbtiles_version: "${{ inputs.mbtiles_version }}"
166+
# jore3importer_version: "${{ inputs.jore3importer_version }}"
167+
# testdb_version: "${{ inputs.testdb_version }}"
168+
# mssqltestdb_version: "${{ inputs.mssqltestdb_version }}"
169+
# mapmatching_version: "${{ inputs.mapmatching_version }}"
170+
# mapmatchingdb_version: "${{ inputs.mapmatchingdb_version }}"
171+
# hastus_version: "${{ inputs.hastus_version }}"
172+
# timetablesapi_version: "${{ inputs.timetablesapi_version }}"
173+
# tiamat_version: "${{ inputs.tiamat_version }}"
174+
# custom_docker_compose: "${{ inputs.custom_docker_compose }}"
175+
# start_jore3_importer: "${{ inputs.start_jore3_importer }}"
176+
- name: Create directory for Docker Compose bundle
177+
shell: bash
178+
run: |
179+
mkdir -p ${{ github.workspace }}/docker
180+
181+
- name: Download docker-compose bundle from GHA artifact
182+
if: ${{ inputs.docker_compose_bundle_gha_artifact }}
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: jore4-docker-compose-bundle
186+
path: ${{ github.workspace }}/docker
187+
188+
- name: Download e2e docker-compose bundle from jore4-docker-compose-bundle repository
189+
if: ${{ !inputs.docker_compose_bundle_gha_artifact }}
190+
run: |
191+
curl -s -L https://github.com/HSLdevcom/jore4-docker-compose-bundle/archive/refs/heads/main.tar.gz \
192+
| tar \
193+
-xz \
194+
-C ${{ github.workspace }}/docker \
195+
--strip-components 2 \
196+
--wildcards 'jore4-docker-compose-bundle-main/docker-compose/*'
197+
shell: bash
198+
199+
- name: Start e2e environment
200+
# use environment variables within the docker-compose bundle to override some images
201+
env:
202+
UI_DOCKER_IMAGE: ${{ inputs.ui_version }}
203+
HASURA_DOCKER_IMAGE: ${{ inputs.hasura_version }}
204+
AUTH_DOCKER_IMAGE: ${{ inputs.auth_version }}
205+
MBTILES_DOCKER_IMAGE: ${{ inputs.mbtiles_version }}
206+
JORE3IMPORTER_DOCKER_IMAGE: ${{ inputs.jore3importer_version }}
207+
TESTDB_DOCKER_IMAGE: ${{ inputs.testdb_version }}
208+
MSSQLTESTDB_DOCKER_IMAGE: ${{ inputs.mssqltestdb_version }}
209+
MAPMATCHING_DOCKER_IMAGE: ${{ inputs.mapmatching_version }}
210+
MAPMATCHINGDB_DOCKER_IMAGE: ${{ inputs.mapmatchingdb_version }}
211+
CYPRESS_DOCKER_IMAGE: ${{ inputs.cypress_version }}
212+
HASTUS_DOCKER_IMAGE: ${{ inputs.hastus_version }}
213+
TIMETABLESAPI_DOCKER_IMAGE: ${{ inputs.timetablesapi_version }}
214+
TIAMAT_DOCKER_IMAGE: ${{ inputs.tiamat_version }}
215+
run: |
216+
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
217+
shell: bash
218+
219+
- name: Show which versions of the docker images are spun up
220+
run: docker ps
221+
shell: bash
222+
223+
- name: Verify that UI is up and running standalone
224+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
225+
with:
226+
command: "curl --fail http://localhost:3302 --output /dev/null --silent"
227+
228+
- name: Verify that UI is up and running through proxy
229+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
159230
with:
160-
docker_compose_bundle_gha_artifact: "${{ inputs.docker_compose_bundle_gha_artifact }}"
161-
ui_version: "${{ inputs.ui_version }}"
162-
cypress_version: "${{ inputs.cypress_version }}"
163-
hasura_version: "${{ inputs.hasura_version }}"
164-
auth_version: "${{ inputs.auth_version }}"
165-
mbtiles_version: "${{ inputs.mbtiles_version }}"
166-
jore3importer_version: "${{ inputs.jore3importer_version }}"
167-
testdb_version: "${{ inputs.testdb_version }}"
168-
mssqltestdb_version: "${{ inputs.mssqltestdb_version }}"
169-
mapmatching_version: "${{ inputs.mapmatching_version }}"
170-
mapmatchingdb_version: "${{ inputs.mapmatchingdb_version }}"
171-
hastus_version: "${{ inputs.hastus_version }}"
172-
timetablesapi_version: "${{ inputs.timetablesapi_version }}"
173-
tiamat_version: "${{ inputs.tiamat_version }}"
174-
custom_docker_compose: "${{ inputs.custom_docker_compose }}"
175-
start_jore3_importer: "${{ inputs.start_jore3_importer }}"
231+
command: "curl --fail http://localhost:3300 --output /dev/null --silent"
232+
233+
- name: Verify that postgresql is up and running
234+
id: verify_postgresql_started
235+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
236+
with:
237+
command: "pg_isready -h localhost -p 6432"
238+
# it takes a while for the database to start
239+
retries: 50
240+
241+
- name: Show PostgreSQL logs
242+
if: ${{ failure() && steps.verify_postgresql_started.outcome == 'failure' }}
243+
run: |
244+
docker logs testdb
245+
shell: bash
246+
247+
- name: Verify that mssql testdb is up and running
248+
id: verify_mssql_started
249+
if: ${{ inputs.start_jore3_importer == 'true' }}
250+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
251+
env:
252+
SA_PASSWORD: "P@ssw0rd"
253+
with:
254+
# The IP address of MS SQL Docker container is retrieved using docker inspect because the container
255+
# does not have a predefined or predictable hostname. A predefined hostname could be added in docker
256+
# compose bundle.
257+
command:
258+
docker run
259+
--rm
260+
--network docker_jore4
261+
$(docker inspect mssqltestdb | jq -r '.[0].Config.Image')
262+
/opt/mssql-tools18/bin/sqlcmd
263+
-C
264+
-S $(docker inspect mssqltestdb | jq -r '.[0].NetworkSettings'.Networks.docker_jore4.IPAddress)
265+
-U sa
266+
-P "$SA_PASSWORD"
267+
-d master
268+
-Q "SELECT ''OK'';"
269+
# it takes a while for the database to start
270+
retries: 50
271+
272+
# on some rare occasions unfortunately this is failing...
273+
- name: Show MSSQL logs
274+
if: ${{ failure() && steps.verify_mssql_started.outcome == 'failure' }}
275+
run: |
276+
docker logs mssqltestdb
277+
shell: bash
278+
279+
- name: Verify that hasura is up and running standalone
280+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
281+
with:
282+
command: "curl --fail http://localhost:3201/healthz --output /dev/null --silent"
283+
284+
- name: Verify that hasura is up and running through proxy
285+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
286+
with:
287+
command: "curl --fail http://localhost:3300/api/graphql/healthz --output
288+
/dev/null --silent"
289+
290+
- name: Verify that auth backend is up and running standalone
291+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
292+
with:
293+
command:
294+
"curl --fail http://localhost:3200/actuator/health --output /dev/null
295+
--silent"
296+
297+
- name: Verify that auth backend has access to database
298+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
299+
with:
300+
command:
301+
"curl --fail http://localhost:3200/public/v1/login --output /dev/null
302+
--silent"
303+
304+
- name: Verify that auth backend is up and running through proxy
305+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
306+
with:
307+
command:
308+
"curl --fail http://localhost:3300/api/auth/actuator/health --output
309+
/dev/null --silent"
310+
311+
- name: Verify that mbtiles server is up and running standalone
312+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
313+
with:
314+
command: "curl --fail http://localhost:3203/services --output /dev/null
315+
--silent"
316+
317+
- name: Verify that mbtiles server is up and running through proxy
318+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
319+
with:
320+
command:
321+
"curl --fail http://localhost:3300/api/mbtiles/services --output
322+
/dev/null --silent"
323+
324+
- name: Verify that jore3 importer is up and running standalone
325+
if: ${{ inputs.start_jore3_importer == 'true' }}
326+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
327+
with:
328+
command:
329+
"curl --fail http://localhost:3004/actuator/health --output /dev/null
330+
--silent"
331+
332+
- name: Verify that map matching database is up and running standalone
333+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
334+
with:
335+
command: "pg_isready -h localhost -p 6433"
336+
337+
- name: Verify that map matching server is up and running standalone
338+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
339+
with:
340+
command:
341+
"curl --fail http://localhost:3005/actuator/health --output /dev/null
342+
--silent"
343+
344+
- name: Verify that map matching server is up and running through proxy
345+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
346+
with:
347+
command:
348+
"curl --fail http://localhost:3300/api/mapmatching/actuator/health
349+
--output /dev/null --silent"
350+
351+
- name: Verify that cypress test container is up and running standalone
352+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
353+
with:
354+
command: "docker exec cypress yarn cypress --version"
355+
356+
- name: Verify that hastus importer is up and running standalone
357+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
358+
with:
359+
command:
360+
"curl --fail http://localhost:3008/actuator/health --output /dev/null
361+
--silent"
362+
363+
- name: Verify that hastus importer is up and running through proxy
364+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
365+
with:
366+
command:
367+
"curl --fail http://localhost:3300/api/hastus/actuator/health --output
368+
/dev/null --silent"
369+
370+
- name: Verify that timetables-api is up and running standalone
371+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
372+
with:
373+
command: "curl --fail http://localhost:3009/actuator/health --output
374+
/dev/null --silent"
375+
376+
- name: Verify that tiamat is up and running standalone
377+
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
378+
with:
379+
command: "curl --fail http://localhost:3010/actuator/health --output
380+
/dev/null --silent"
381+
382+
- name: Reload Hasura metadata to re-establish connection to Tiamat
383+
# Hasura remote schema will break if it cannot establish connection on startup. Force reload after everything is running.
384+
env:
385+
HASURA_PASSWORD: "hasura"
386+
run: |
387+
curl --header "Content-Type: application/json" \
388+
--header "x-hasura-admin-secret: $HASURA_PASSWORD" \
389+
--request POST \
390+
--data '{"type":"reload_metadata","args":{"reload_remote_schemas":true,"reload_sources":true}}' \
391+
localhost:3201/v1/metadata
392+
shell: bash
393+
394+
- name: Verify that all containers are healthy
395+
run: '[ -z "$(docker ps -q --filter health=unhealthy)" ]'
396+
shell: bash
397+
398+
- name: Extract metadata
399+
id: extract-metadata
400+
shell: bash
401+
run: |
402+
echo e2e_source_commit_sha=$(docker inspect cypress -f '{{ .Config.Labels.git_sha }}') >> ${GITHUB_OUTPUT}
176403
177404
- name: Seed infrastructure links
178405
uses: HSLdevcom/jore4-tools/github-actions/seed-infrastructure-links@seed-infrastructure-links-v3

0 commit comments

Comments
 (0)