-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (94 loc) · 3.24 KB
/
e2e_test.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
name: Run end-to-end tests
on:
workflow_call:
inputs:
spec-file-patterns:
type: string
default: 'integration_tests/integration/features/**/*.feature'
app_version:
description: App version
required: true
type: string
jobs:
get-timings:
uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/workflows/cypress_get_timings.yml@v1
with:
spec-file-patterns: ${{ inputs.spec-file-patterns }}
e2e-test:
runs-on: ubuntu-latest
needs: get-timings
env:
UI_IMAGE_TAG: ${{ inputs.app_version }}
strategy:
fail-fast: false
matrix:
container: [ 1, 2 ]
outputs:
timings-1: ${{ steps.timings.outputs.t1 }}
timings-2: ${{ steps.timings.outputs.t2 }}
steps:
- uses: actions/checkout@v4
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: build_image
path: ${{ runner.temp }}
- name: Load image
run: docker load --input ${{ runner.temp }}/build_image.tar
- name: restore cache
id: restore-cache
uses: actions/cache/restore@v4
env:
cache-name: node-modules
with:
path: |
./node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/actions/cypress/create_timings_file@v1
with:
timings: ${{ needs.get-timings.outputs.timings }}
- name: Stand up a test environment
run: make up
- name: Clear the visual regression diffs directory
run: rm -rf integration_tests/snapshots/diff
- name: Run the end-to-end tests
uses: cypress-io/github-action@v6
with:
publish-summary: false
browser: chrome
env:
SPEC: ${{ inputs.spec-file-patterns }}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
SPLIT_FILE: 'timings.json'
- name: Check for visual regression diffs
run: if test -d integration_tests/snapshots/diff; then exit 1; fi
- name: Output updated timings
if: success() || failure()
id: timings
run: |
cat timings.json
echo "t${{ matrix.container }}=$(jq -c . < timings.json)" >> $GITHUB_OUTPUT
- name: Export container logs
if: failure()
run: make save-logs OUTPUT_LOGS_DIR=${{ runner.temp }}/docker-logs
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: e2e_test_results_${{ matrix.container }}
path: |
test_results
integration_tests/screenshots
integration_tests/snapshots/diff
${{ runner.temp }}/docker-logs
save-timings:
uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/workflows/cypress_save_timings.yml@v1
if: success() || failure()
needs:
- get-timings
- e2e-test
with:
initial-timings: ${{ needs.get-timings.outputs.timings }}
updated-timings: ${{ toJSON(needs.e2e-test.outputs) }}