-
Notifications
You must be signed in to change notification settings - Fork 0
370 lines (341 loc) · 13.2 KB
/
shared-run-e2e.yml
File metadata and controls
370 lines (341 loc) · 13.2 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
---
name: Run E2E Tests
on:
workflow_call:
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.
type: string
required: false
default: null
ui_version:
description:
Version of ui to use (docker image tag). Set to "" if using the default
version.
type: string
required: false
default: ""
hasura_version:
description:
Version of hasura to use (docker image tag). Set to "" if using the
default version.
type: string
required: false
default: ""
auth_version:
description:
Version of auth to use (docker image tag). Set to "" if using the default
version.
type: string
required: false
default: ""
mbtiles_version:
description:
Version of mbtiles server to use (docker image tag). Set to "" if using
the default version.
type: string
required: false
default: ""
jore3importer_version:
description:
Version of jore3importer to use (docker image tag). Set to "" if using the
default version.
type: string
required: false
default: ""
testdb_version:
description:
Version of testdb to use (docker image tag). Set to "" if using the
default version.
type: string
required: false
default: ""
mssqltestdb_version:
description:
Version of mssqltestdb to use (docker image tag). Set to "" if using the
default version.
type: string
required: false
default: ""
mapmatching_version:
description:
Version of map matching service to use (docker image tag). Set to "" if
using the default version.
type: string
required: false
default: ""
mapmatchingdb_version:
description:
Version of map matching database to use (docker image tag). Set to "" if
using the default version.
type: string
required: false
default: ""
cypress_version:
description:
Version of cypress tests to use (docker image tag). Set to "" if using the
default version.
type: string
required: false
default: ""
hastus_version:
description:
Version of hastus importer to use (docker image tag). Set to "" if using
the default version.
type: string
required: false
default: ""
timetablesapi_version:
description:
Version of timetables api to use (docker image tag). Set to "" if using
the default version.
type: string
required: false
default: ""
tiamat_version:
description: Version of tiamat to use (docker image tag). Set to "" if using
the default version.
type: string
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
type: string
required: false
default: ""
start_jore3_importer:
description: Should Jore3 importer be started along the rest of the e2e environment.
type: string
required: false
default: "false"
test-tags:
description:
Specify a string of tags for tests to be run in format '@smoke'. To
specify multiple tags, use format '@routes @smoke'. To run all tests, set
it to ''.
type: string
required: false
default: "@smoke"
video:
description:
Turn video on or off. Supported values are 'true' and 'false'.
type: string
required: false
default: 'false'
update_e2e_test_durations:
description: |
Should the E2E test durations be updated to jore4-ci-data repository's e2e-test-durations branch
based on the run.
When set to true, jore4_ci_data_repo_ssh_key must also be set.
required: false
type: boolean
default: false
secrets:
jore4_ci_data_repo_ssh_key:
description:
SSH key that can be used to write to HSLdevcom/jore4-ci-data repository.
required: false
jobs:
run_e2e_tests:
name: Run e2e tests
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Start e2e env
id: start-e2e-env
uses: HSLdevcom/jore4-tools/github-actions/setup-e2e-environment@setup-e2e-environment-v9
with:
docker_compose_bundle_gha_artifact: "${{ inputs.docker_compose_bundle_gha_artifact }}"
ui_version: "${{ inputs.ui_version }}"
cypress_version: "${{ inputs.cypress_version }}"
hasura_version: "${{ inputs.hasura_version }}"
auth_version: "${{ inputs.auth_version }}"
mbtiles_version: "${{ inputs.mbtiles_version }}"
jore3importer_version: "${{ inputs.jore3importer_version }}"
testdb_version: "${{ inputs.testdb_version }}"
mssqltestdb_version: "${{ inputs.mssqltestdb_version }}"
mapmatching_version: "${{ inputs.mapmatching_version }}"
mapmatchingdb_version: "${{ inputs.mapmatchingdb_version }}"
hastus_version: "${{ inputs.hastus_version }}"
timetablesapi_version: "${{ inputs.timetablesapi_version }}"
tiamat_version: "${{ inputs.tiamat_version }}"
custom_docker_compose: "${{ inputs.custom_docker_compose }}"
start_jore3_importer: "${{ inputs.start_jore3_importer }}"
- name: Seed infrastructure links
uses: HSLdevcom/jore4-tools/github-actions/seed-infrastructure-links@seed-infrastructure-links-v3
with:
seed_data_commit_sha: "${{ steps.start-e2e-env.outputs.e2e_source_commit_sha }}"
- name: Seed municipalities and fare zones
uses: HSLdevcom/jore4-tools/github-actions/seed-municipalities-and-fare-zones@seed-municipalities-and-fare-zones-v2
with:
seed_data_commit_sha: "${{ steps.start-e2e-env.outputs.e2e_source_commit_sha }}"
- name: Download E2E Test Durations
# The cypress-split plugin currently (2025-06) includes all the timings from the input durations file and calculates
# the new duration as (new_duration + (N - 1) * old_duration) / N and also includes also the specs that are no
# longer present.
# Therefore to only include existing specs and use the actual test duration, the durations are not given as input
# for cypress-split when durations are going to be updated
#
# The following describe where you can find the implementation details so you can check if the details have changed
#
# You can find the cypress-split-merge from https://github.com/bahmutov/cypress-split/blob/0ba18be998f9d21eee27c1d78a06c33bc60a6d05/bin/merge.js
# which is calling mergeSplitTimings function (https://github.com/bahmutov/cypress-split/blob/0ba18be998f9d21eee27c1d78a06c33bc60a6d05/src/timings.js#L111)
# to merge durations.
#
# The implementation keeping all durations from the input duration files can be found from
# https://github.com/bahmutov/cypress-split/blob/0ba18be998f9d21eee27c1d78a06c33bc60a6d05/src/index.js#L213
if: ${{ ! inputs.update_e2e_test_durations }}
shell: bash
run: |
curl \
-O \
https://raw.githubusercontent.com/HSLdevcom/jore4-ci-data/e2e-test-durations/e2e-test-durations.json
cat e2e-test-durations.json
docker cp e2e-test-durations.json cypress:/e2e/cypress/e2e-test-durations.json
- name: Run the tests
shell: bash
run: |
docker exec \
-e TEST_TAGS="${{ inputs.test-tags }}" \
-e TEST_VIDEO="${{ inputs.video }}" \
-e JORE4_CYPRESS_GENERATE_CTRF_REPORT=true \
-e SPLIT="${{ strategy.job-total }}" \
-e SPLIT_INDEX="${{ strategy.job-index }}" \
-e SPLIT_FILE=/e2e/cypress/e2e-test-durations.json \
-e SPLIT_OUTPUT_FILE=/e2e/cypress/e2e-test-durations.out.json \
cypress /e2e/cypress/run_cypress_in_4K_xvfb.sh
- name: Copy test durations from Docker container
shell: bash
run: |
docker cp cypress:/e2e/cypress/e2e-test-durations.out.json ${{ github.workspace }}/durations.out.json
cat ${{ github.workspace }}/durations.out.json
- name: Upload test durations
uses: actions/upload-artifact@v4
with:
name: "e2e-test-durations-${{ strategy.job-index }}"
path: ${{ github.workspace }}/durations.out.json
- name: Copy test results
id: copy_test_results
# Should be run especially when tests fail
if: always()
shell: bash
run: |
docker cp cypress:/e2e/cypress/ctrf/ctrf-report.json ${{ github.workspace }}/ctrf-report.json
- name: Upload test reports as an artifact
# Should be run especially when tests fail
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-test-results-${{ strategy.job-index }}
path: ${{ github.workspace }}/ctrf-report.json
- name: Copy test reports from Cypress container
id: copy_test_reports
# Should be run especially when tests fail
if: always()
shell: bash
run: |
docker cp cypress:/e2e/cypress/reports ${{ github.workspace }}/test-reports || true
if [[ -d test-reports ]]
then
# List files in test-reports directory
find test-reports -type f
test_reports_exist=true
else
test_reports_exist=false
fi
echo "test_reports_exist=${test_reports_exist}" >> $GITHUB_OUTPUT
- name: Upload test reports as an artifact
if: always() && steps.copy_test_reports.outputs.test_reports_exist == 'true'
uses: actions/upload-artifact@v4
with:
name: cypress-docker-reports-${{ strategy.job-index }}
path: ${{ github.workspace }}/test-reports
publish_e2e_test_results:
name: Publish E2E Test Results
runs-on: ubuntu-24.04
needs:
- run_e2e_tests
steps:
- name: Download E2E Test Results
uses: actions/download-artifact@v4
continue-on-error: true
with:
pattern: cypress-test-results-*
path: ${{ github.workspace }}/ctrf
- name: Publish Test Report
uses: ctrf-io/github-test-reporter@27b97adba93f02142c573c8a710045cac0d874ae # v1.0.14
with:
report-path: 'ctrf/*/*.json'
summary-report: true
failed-report: true
flaky-report: true
skipped-report: true
test-report: false
update_e2e_test_durations:
name: Update E2E Test Durations
runs-on: ubuntu-24.04
if: ${{ inputs.update_e2e_test_durations }}
needs:
- run_e2e_tests
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: 'HSLdevcom/jore4-ci-data'
ref: e2e-test-durations
ssh-key: ${{ secrets.jore4_ci_data_repo_ssh_key }}
- name: Download E2E Test Durations
uses: actions/download-artifact@v4
with:
pattern: e2e-test-durations-*
path: ${{ github.workspace }}/split-durations
- name: Merge duration files
shell: bash
run: |
docker run \
-i \
--rm \
-v $(pwd):$(pwd) \
-w /tmp \
node:24-alpine \
sh <<EOF
npm install cypress-split
./node_modules/.bin/cypress-split-merge --parent-folder $(pwd) --split-file durations.out.json --output $(pwd)/e2e-test-durations.json
EOF
- name: Check if timings have updates
shell: bash
run: |
if test -z "$(git status --porcelain)"
then
status=no-changes
else
status=changes
git diff
fi
echo "Git work tree status: ${status}"
echo GIT_WORK_TREE_STATUS=${status} >> ${GITHUB_ENV}
- name: Release updated files
if: ${{ env.GIT_WORK_TREE_STATUS == 'changes' }}
env:
GIT_AUTHOR_NAME: Jore4 E2E Tests
GIT_AUTHOR_EMAIL: noreply@vincit.fi
GIT_COMMITTER_NAME: Jore4 E2E Tests
GIT_COMMITTER_EMAIL: noreply@vincit.fi
shell: bash
run: |
git add e2e-test-durations.json
git commit -m "Update E2E Test Timings
The source of E2E test durations is GHA Workflow run
${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
"
git push origin HEAD:refs/heads/e2e-test-durations