-
Notifications
You must be signed in to change notification settings - Fork 41
300 lines (279 loc) · 11.1 KB
/
frontend-checks.yml
File metadata and controls
300 lines (279 loc) · 11.1 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
name: Frontend Checks
on:
pull_request:
merge_group:
push:
branches:
- main
workflow_dispatch:
permissions: {}
jobs:
format:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
continue-on-error: true
id: app-token
with:
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
- name: Check if commits can be added
id: check_can_add_commit
run: |
echo "can_add_commit=$CAN_ADD_COMMIT" >> $GITHUB_OUTPUT
env:
CAN_ADD_COMMIT: ${{ steps.app-token.outputs.token != '' && github.event_name == 'pull_request' }}
- name: Checkout for pull request
if: steps.check_can_add_commit.outputs.can_add_commit == 'true'
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: Checkout
if: steps.check_can_add_commit.outputs.can_add_commit == 'false'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Restore Prettier Cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ./node_modules/.cache/prettier/.prettier-cache
key: ${{ runner.os }}-prettier-cache-format-${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('main-{0}', github.sha) || github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}
restore-keys: |
${{ runner.os }}-prettier-cache-format-main-
${{ runner.os }}-prettier-cache-format-
- name: Restore ESLint Cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: .eslintcache
key: ${{ runner.os }}-eslint-cache-format-${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('main-{0}', github.sha) || github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}
restore-keys: |
${{ runner.os }}-eslint-cache-format-main-
${{ runner.os }}-eslint-cache-format-
- name: Format
run: npm run format
- name: Check for Changes
id: check_changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changes_detected=true" >> $GITHUB_OUTPUT
else
echo "changes_detected=false" >> $GITHUB_OUTPUT
fi
- name: Commit format
if: steps.check_can_add_commit.outputs.can_add_commit == 'true' && steps.check_changes.outputs.changes_detected == 'true'
uses: ./.github/actions/add-and-commit
with:
message: '🤖 Apply formatting changes'
token: ${{ steps.app-token.outputs.token }}
- name: Fail for formatting issues without personal access token
if: steps.check_can_add_commit.outputs.can_add_commit == 'false' && steps.check_changes.outputs.changes_detected == 'true'
run: |
echo "Formatting changes are needed but couldn't be committed because the personal access token isn't available or this isn't a pull request."
exit 1
lint:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Restore Prettier Cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ./node_modules/.cache/prettier/.prettier-cache
key: ${{ runner.os }}-prettier-cache-lint-${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('main-{0}', github.sha) || github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}
restore-keys: |
${{ runner.os }}-prettier-cache-lint-main-
${{ runner.os }}-prettier-cache-lint-
- name: Restore ESLint Cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: .eslintcache
key: ${{ runner.os }}-eslint-cache-lint-${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('main-{0}', github.sha) || github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }}
restore-keys: |
${{ runner.os }}-eslint-cache-lint-main-
${{ runner.os }}-eslint-cache-lint-
- name: Lint
run: npm run lint -- --max-warnings 0
check:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Check
run: npm run check
- name: Check tests
run: npm run check:tests
test:
runs-on: ubuntu-24.04
permissions:
contents: read
strategy:
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
shardTotal: [20]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Set Environment Variables
run: echo "VITE_ALCHEMY_API_KEY=${{ secrets.VITE_ALCHEMY_API_KEY_TEST_FE }}" >> $GITHUB_ENV
- name: Test
# We disable the thresholds since we will check them in the next step, when all sharded reports are merged
run: npm run test:coverage -- --reporter=blob --reporter=default --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage.thresholds.0 --coverage.thresholds.autoUpdate=false
- name: Upload Blob Coverage Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always()
with:
name: vitest-coverage-${{ github.event_name }}-${{ github.run_id }}-${{ github.run_attempt }}-shard-${{ matrix.shardIndex }}
path: .vitest-reports/*
include-hidden-files: true
retention-days: 1
test-coverage:
runs-on: ubuntu-24.04
permissions:
contents: read
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Download Blob Coverage Reports
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: .vitest-reports
pattern: vitest-coverage-${{ github.event_name }}-${{ github.run_id }}-${{ github.run_attempt }}-shard-*
merge-multiple: true
- name: Merge Coverage Reports
run: npm run test:merge
- name: Upload Coverage Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always()
with:
name: vitest-coverage-merged-${{ github.event_name }}-${{ github.run_id }}-${{ github.run_attempt }}
path: coverage/
retention-days: 3
config-preparation:
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
network-matrix: ${{ steps.set-matrix.outputs.network-matrix }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Set Network Matrix
id: set-matrix
run: |
NETWORKS=$(scripts/build.ic-domains.test.list | jq -R . | jq -s -c .)
echo "network-matrix=$NETWORKS" >> $GITHUB_OUTPUT
config-build:
runs-on: ubuntu-24.04
needs: config-preparation
permissions:
contents: read
strategy:
matrix:
network: ${{ fromJson(needs.config-preparation.outputs.network-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Install dfx
uses: dfinity/setup-dfx@e50c04f104ee4285ec010f10609483cf41e4d365 # main
- name: Check ic-domains
continue-on-error: true
run: |
FILE="ic-domain.$NETWORK.txt"
echo "" > "$FILE"
dfx build frontend --network "$NETWORK" >/dev/null 2>/dev/null && \
cat build/.well-known/ic-domains > "$FILE" && \
echo " $NETWORK" >> "$FILE"
env:
NETWORK: ${{ matrix.network }}
- name: Upload Domain File
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ic-domains-${{ matrix.network }}
path: ic-domain.${{ matrix.network }}.txt
retention-days: 1
config:
runs-on: ubuntu-24.04
needs: config-build
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Download All Domain Files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: ic-domains
pattern: ic-domains-*
merge-multiple: true
- name: Merge All Domain Files
run: |
cat ic-domains/*.txt > combined.ic-domains.txt
- name: Run Domain Validation
run: scripts/build.ic-domains.test combined.ic-domains.txt
lockfile:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Prepare
uses: ./.github/actions/prepare
- name: Lint lock file
run: npm run lint:lockfile
frontend-checks-pass:
if: always()
needs: ['format', 'lint', 'check', 'test', 'test-coverage', 'config', 'lockfile']
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/needs_success
with:
needs: '${{ toJson(needs) }}'