-
Notifications
You must be signed in to change notification settings - Fork 7
215 lines (186 loc) · 7.24 KB
/
application_e2e_tests.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
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
name: Application E2E Tests
on:
workflow_run:
workflows:
- "Application Build"
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
jobs:
e2e_test:
name: Run E2E tests
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# Run 10 copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUPPETEER_SKIP_DOWNLOAD: "true"
VITE_CYPRESS_PORT: 8880
steps:
- name: "Download 'workflow_share' artifact"
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GH_PAT }}
name: workflow_share
repository: MTES-MCT/monitorfish
run-id: ${{ github.event.workflow_run.id }}
- name: Set STATUS_CHECK_ID environment variable
run: |
echo "STATUS_CHECK_ID=$(cat workflow_share/cypress_job_check_id)" >> $GITHUB_ENV
- name: Update job status check
uses: LouisBrunner/checks-action@v2.0.0
if: ${{ always() }}
with:
check_id: ${{ env.STATUS_CHECK_ID }}
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}"
sha: ${{ github.event.workflow_run.head_commit.id }}
status: in_progress
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_commit.id }}
- name: Set version and environment profile
uses: ./.github/actions/set-version-and-environment-profile
- name: Set MONITORFISH_VERSION environment variable
run: echo "MONITORFISH_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Download image
uses: ishworkh/container-image-artifact-download@v1.0.0
with:
commit_sha: ${{ github.event.workflow_run.head_commit.id }}
image: monitorfish-app:${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
workflow: "Application Build"
- name: Run docker images
run: make docker-compose-up
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./frontend/package-lock.json
node-version: 20
- name: Setup Firefox
uses: browser-actions/setup-firefox@latest
with:
firefox-version: 119.0.1
- name: Check versions
run: |
cat /etc/lsb-release
node -v
npm -v
docker -v
docker compose version
firefox -v
which firefox
- name: Run Cypress E2E tests
id: run_cypress_e2e_tests
continue-on-error: true
uses: cypress-io/github-action@v6
with:
browser: firefox
config-file: config/cypress.config.ts
env: PORT=8880
install: true
install-command: npm ci
parallel: true
record: true
wait-on: "http://localhost:8880"
working-directory: ./frontend
- name: set final job status check
uses: LouisBrunner/checks-action@v2.0.0
if: ${{ always() }}
with:
check_id: ${{ env.STATUS_CHECK_ID }}
conclusion: ${{ steps.run_cypress_e2e_tests.outcome }}
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}"
sha: ${{ github.event.workflow_run.head_commit.id }}
status: completed
token: ${{ secrets.GITHUB_TOKEN }}
e2e_multi_windows_test:
name: Run E2E multi windows tests
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUPPETEER_SKIP_DOWNLOAD: "true"
VITE_CYPRESS_PORT: 8880
steps:
- name: "Download 'workflow_share' artifact"
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GH_PAT }}
name: workflow_share
repository: MTES-MCT/monitorfish
run-id: ${{ github.event.workflow_run.id }}
- name: Set STATUS_CHECK_ID environment variable
run: |
echo "STATUS_CHECK_ID=$(cat workflow_share/puppeteer_job_check_id)" >> $GITHUB_ENV
- name: Update job status check
uses: LouisBrunner/checks-action@v2.0.0
if: ${{ always() }}
with:
check_id: ${{ env.STATUS_CHECK_ID }}
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}"
sha: ${{ github.event.workflow_run.head_commit.id }}
status: in_progress
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_commit.id }}
- name: Set version and environment profile
uses: ./.github/actions/set-version-and-environment-profile
- name: Set MONITORFISH_VERSION environment variable
run: echo "MONITORFISH_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Download image
uses: ishworkh/container-image-artifact-download@v1.0.0
with:
commit_sha: ${{ github.event.workflow_run.head_commit.id }}
image: monitorfish-app:${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
workflow: "Application Build"
- name: Docker login
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./frontend/package-lock.json
node-version: 20
- name: Install Node.js dependencies
run: npm ci
working-directory: ./frontend
- name: Run docker images
run: make docker-compose-puppeteer-up
- name: Install Firefox
run: npx puppeteer browsers install firefox
- name: Run multi-windows tests
id: run_puppeteer_e2e_tests
continue-on-error: true
run: npm run test:multi-windows:run
working-directory: ./frontend
- name: Set final job status check
uses: LouisBrunner/checks-action@v2.0.0
if: ${{ always() }}
with:
check_id: ${{ env.STATUS_CHECK_ID }}
conclusion: ${{ steps.run_puppeteer_e2e_tests.outcome }}
details_url: "https://github.com/MTES-MCT/monitorfish/actions/runs/${{ github.run_id }}/job/${{ github.job_id }}"
sha: ${{ github.event.workflow_run.head_commit.id }}
status: completed
token: ${{ secrets.GITHUB_TOKEN }}