-
Notifications
You must be signed in to change notification settings - Fork 41
297 lines (263 loc) · 10.5 KB
/
e2e-tests.yml
File metadata and controls
297 lines (263 loc) · 10.5 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
name: E2E Tests
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, labeled]
merge_group:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
permissions: {}
jobs:
check-e2e-changes:
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
e2e-or-config-changed: ${{ steps.change.outputs.e2e }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: change
with:
filters: |
e2e:
- playwright.config.ts
- .env.e2e
- canister_e2e_ids.json
- e2e/**/*
oisy-backend-wasm:
runs-on: ubuntu-24.04
if: ${{(github.event_name != 'pull_request' && github.event_name != 'merge_group') ||
((github.event_name == 'pull_request' || github.event_name == 'merge_group') && (needs.check-e2e-changes.outputs.e2e-or-config-changed == 'true' || contains(github.event.pull_request.labels.*.name, 'run-e2e-snapshots')))}}
needs: check-e2e-changes
permissions:
contents: write
packages: write
steps:
- name: Checkout
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Checkout for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false
- name: Build oisy-backend WASM
uses: ./.github/actions/oisy-backend
with:
network: local
define-matrix:
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
os-matrix: ${{ steps.set-matrix.outputs.os-matrix }}
steps:
- name: Set OS Matrix
id: set-matrix
run: |
MATRIX='["ubuntu-24.04"]'
if [[ "$ALL_RUNNERS" == "true" ]]; then
MATRIX='["ubuntu-24.04", "macos-14"]'
fi
echo "os-matrix=$MATRIX" >> $GITHUB_OUTPUT
env:
ALL_RUNNERS: ${{ contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name) || contains(github.event.pull_request.labels.*.name, 'run-e2e-snapshots') }}
e2e:
runs-on: ${{ matrix.os }}
permissions:
contents: read
needs: ['oisy-backend-wasm', 'check-e2e-changes', 'define-matrix']
strategy:
matrix:
os: ${{ fromJson(needs.define-matrix.outputs.os-matrix) }}
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
if: ${{(github.event_name != 'pull_request' && github.event_name != 'merge_group') ||
((github.event_name == 'pull_request' || github.event_name == 'merge_group') && (needs.check-e2e-changes.outputs.e2e-or-config-changed == 'true' || contains(github.event.pull_request.labels.*.name, 'run-e2e-snapshots')))}}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.shardIndex }}
cancel-in-progress: true
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
- name: Checkout
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Checkout for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Download WASM artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: backend.wasm.gz
path: out/
- name: Prepare macOS
if: runner.os == 'macOS'
uses: ./.github/actions/prepare-macos
- name: Set Environment Variables
run: |
echo "VITE_ETHERSCAN_API_KEY=${{ secrets.VITE_ETHERSCAN_API_KEY_E2E }}" >> $GITHUB_ENV
echo "VITE_ALCHEMY_API_KEY=${{ secrets.VITE_ALCHEMY_API_KEY_E2E }}" >> $GITHUB_ENV
- name: Deploy the backend
uses: ./.github/actions/deploy-backend
- name: Prepare
uses: ./.github/actions/prepare
- name: Test
run: npm run e2e:ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload Playwright Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always()
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}
path: playwright-report/
retention-days: 3
- name: Upload Playwright Results
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always()
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}
path: test-results/
retention-days: 3
- name: Check if snapshots changed
id: check_snapshots
run: |
if [ -n "$(git status --porcelain e2e)" ]; then
echo "CHANGES=true" >> $GITHUB_OUTPUT
else
echo "CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: Set snapshot output
id: set_snapshot_output
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
echo "os_suffix=linux" >> $GITHUB_OUTPUT
elif [ "$RUNNER_OS" = "macOS" ]; then
echo "os_suffix=darwin" >> $GITHUB_OUTPUT
fi
env:
CHANGES: ${{ steps.check_snapshots.outputs.CHANGES }}
- name: Save changed snapshots
if: steps.check_snapshots.outputs.CHANGES == 'true'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: snapshots-${{ matrix.os }}-${{ matrix.shardIndex }}
path: e2e/snapshots/**/*.spec.ts-snapshots/**/*-${{ steps.set_snapshot_output.outputs.os_suffix }}.png
retention-days: 3
finalize-snapshots-update:
name: Finalize Snapshots Update
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
needs: [e2e]
outputs:
e2e-snapshots-changed: ${{ steps.e2e-check-snapshots.outputs.e2e-snapshots-changed }}
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
- name: Checkout
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Checkout for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Download All Snapshot Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: snapshots-*
merge-multiple: true
path: e2e/snapshots
- name: Check for Final Changes
id: e2e-check-snapshots
run: |
if [ -n "$(git status --porcelain e2e)" ]; then
echo "FINAL_CHANGES=true" >> $GITHUB_ENV
echo "e2e-snapshots-changed=true" >> $GITHUB_OUTPUT
else
echo "FINAL_CHANGES=false" >> $GITHUB_ENV
echo "e2e-snapshots-changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push updates
uses: ./.github/actions/add-and-commit
if: env.FINAL_CHANGES == 'true' && github.ref != 'refs/heads/main'
with:
add: e2e
message: '🤖 Update E2E snapshots'
token: ${{ steps.app-token.outputs.token }}
- name: Stage Changes on main
if: env.FINAL_CHANGES == 'true' && github.ref == 'refs/heads/main'
run: git add e2e
- name: Check the Changed Files
if: env.FINAL_CHANGES == 'true' && github.ref == 'refs/heads/main'
run: |
MODIFIED_FILES=$(git diff --cached --name-only)
echo "MODIFIED_FILES<<EOF" >> $GITHUB_ENV
echo "$MODIFIED_FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create Pull Request (if changes and on main)
if: env.FINAL_CHANGES == 'true' && github.ref == 'refs/heads/main'
uses: ./.github/actions/create-pr
with:
token: ${{ steps.app-token.outputs.token }}
branch: bot-e2e-update-snapshots
paths: e2e/
title: 'chore(e2e): Update Playwright E2E Snapshots'
body: |
The following E2E snapshots have been updated:
```
${{ env.MODIFIED_FILES }}
```
e2e-tests-pass:
if: always()
needs: ['check-e2e-changes', 'e2e', 'finalize-snapshots-update']
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Cleared for merging
run: |
if [ "$E2E_OR_CONFIG_CHANGED" == "false" ]; then
echo "No E2E or config changes detected. PR is cleared for merging."
elif [[ "$E2E_RESULT" == "success" ]] && [[ "$E2E_SNAPSHOTS_CHANGED" == "false" ]]; then
echo "This PR is cleared for merging"
else
echo "This PR is not cleared for merging"
exit 1
fi
env:
E2E_OR_CONFIG_CHANGED: ${{ needs.check-e2e-changes.outputs.e2e-or-config-changed }}
E2E_SNAPSHOTS_CHANGED: ${{ needs.finalize-snapshots-update.outputs.e2e-snapshots-changed }}
E2E_RESULT: ${{ needs.e2e.result }}