-
Notifications
You must be signed in to change notification settings - Fork 58
474 lines (401 loc) · 13.5 KB
/
ci.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
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
name: CI
on:
push:
branches:
- develop
- master
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
- master
schedule:
- cron: '0 0 * * *'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Check how tests should be executed
runs-on: ubuntu-20.04
if: false
outputs:
uuid: ${{ steps.uuid.outputs.value }}
commit-message: ${{ steps.commit-message.outputs.value }}
is-label-present: ${{ steps.label-present.outputs.value }}
cypress: ${{ steps.cypress.outputs.value }}
synpress: ${{ steps.synpress.outputs.value }}
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Generate unique ID 💎
id: uuid
run: |
echo "value=sha-$GITHUB_SHA-time-$(date +"%s")" >> $GITHUB_OUTPUT
echo "sha-$GITHUB_SHA-time-$(date +"%s")"
- name: Get Commit Message
id: commit-message
run: |
MSG=$(git log --format=%B -n 1 ${{github.event.after}})
echo "value=$(printf "$MSG" | xargs)" >> $GITHUB_OUTPUT
- name: Echo commit message
run: echo "${{ steps.commit-message.outputs.value }}"
- uses: docker://agilepathway/pull-request-label-checker:latest
id: check-if-cypress-tests-should-run
continue-on-error: true
with:
one_of: ready-for-tests,QA
repo_token: ${{ secrets.GITHUB_TOKEN }}
- uses: docker://agilepathway/pull-request-label-checker:latest
id: check-if-synpress-tests-should-run
continue-on-error: true
with:
one_of: ready-for-synpress-tests,QA
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if cypress label is present
if: steps.check-if-cypress-tests-should-run.outcome == 'success'
id: cypress-label-present
run: |
echo "Label present"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if synpress label is present
if: steps.check-if-synpress-tests-should-run.outcome == 'success'
id: synpress-label-present
run: |
echo "Label present"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if cypress tests should be executed
id: cypress
if: ${{ ((github.event_name == 'push') || ((steps.cypress-label-present.outputs.value == 'true')&& !(github.actor == 'dependabot[bot]'))) }}
run: |
echo "Cypress tests should be executed"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if synpress tests should be executed
id: synpress
if: ${{ contains(steps.commit-message.outputs.value,'trigger-synpress') || github.event_name == 'push' || (steps.synpress-label-present.outputs.value == 'true') }}
run: |
echo "Synpress tests should be executed"
echo "value=true" >> $GITHUB_OUTPUT
install:
name: Install
runs-on: ubuntu-20.04
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: ⎔・Setup node
uses: actions/setup-node@v3
with:
node-version: lts/hydrogen
check-latest: true
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
env:
HUSKY: '0'
- name: Generate open-api
run: yarn codegen:socket
- name: Generate graphql
run: yarn codegen:graphql
- name: Compress workspace artifact
run: tar --create --use-compress-program='zstd -T0' --file=/tmp/workspace.tar.zst .
- name: Upload workspace artifact
uses: actions/upload-artifact@v3
with:
name: workspace
path: /tmp/workspace.tar.zst
retention-days: 3
lint:
name: 🔬 ・Lint
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run linter
run: yarn lint --quiet
test:
name: 🔎 ・Test
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run tests
run: yarn test
typecheck:
name: ⬡・Typecheck
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run typescript check
run: yarn typecheck
build:
name: ⚙️ ・Build
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Build app
env:
REACT_APP_ETHERSCAN_API_KEY: ${{ secrets.REACT_APP_ETHERSCAN_API_KEY }}
run: yarn ipfs-build
- name: Compress build artifact
run: tar --create --use-compress-program='zstd -T0' --file=/tmp/build.tar.zst build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: /tmp/build.tar.zst
retention-days: 3
synpress:
name: 👘 ・Synpress
runs-on: ubuntu-22.04
needs: prepare
if: ${{ needs.prepare.outputs.synpress }}
env:
PRIVATE_KEY: ${{ secrets.TEST_WALLET_PRIVATE_KEY }}
strategy:
fail-fast: false
matrix:
containers: [02transactionfull, 01transactionless]
steps:
- name: Setup chrome version
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: Set synpress default params
run: |
echo "TEST_PARAMS=-s 'tests/synpress/specs/${{ matrix.containers }}/*/*.ts'" >> "$GITHUB_ENV"
- name: Check if synpress should be reported to dashboard
if: ${{ (github.event_name == 'push') || !(contains(needs.prepare.outputs.commit-message,'skip-synpress-dashboard')) }}
run: |
echo "TEST_PARAMS=-s 'tests/synpress/specs/${{ matrix.containers }}/*/*.ts --record --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --tag SYNPRESS'" >> "$GITHUB_ENV"
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
cache: 'yarn'
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: yarn install --immutable
- name: Generate open-api
run: yarn codegen:socket
- name: Codegen socket
run: yarn codegen:socket
- name: Codegen GraphQl
run: yarn codegen:graphql
- name: Run synpress tests
run: |
sudo -E ./start-tests.sh
continue-on-error: true
env:
CI: true
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
TEST_PARAMS: ${{ env.TEST_PARAMS }}
PRIVATE_KEY: ${{ secrets.TEST_WALLET_PRIVATE_KEY }}
SLOW_MODE: true
DISPLAY: ':99'
CYPRESS_RESOURCES_WAIT: true
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.containers }}
path: |
docker/videos-ci
cypress:
name: 🎡 ・Cypress (${{ matrix.containers }})
needs: prepare
runs-on: ubuntu-20.04
if: ${{ needs.prepare.outputs.cypress }}
strategy:
fail-fast: false
matrix:
containers: [Container01, Container02, Container03, Container04]
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
cache: 'yarn'
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: yarn install --immutable
- name: Generate open-api
run: yarn codegen:socket
- name: Codegen socket
run: yarn codegen:socket
- name: Codegen GraphQl
run: yarn codegen:graphql
- name: Install dependencies
run: yarn install --immutable
- name: Verify Cypress
run: yarn cypress install
- name: Run cypress tests
if: ${{ !(github.event_name == 'push') }}
run: yarn cypress:ci 'yarn cypress run -r mochawesome --record --group electron --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --parallel --tag TESTS_FROM_PR --ci-build-id=${{ needs.prepare.outputs.uuid }}'
continue-on-error: true
env:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
- name: Run cypress tests after merge
if: ${{ (github.event_name == 'push') }}
run: yarn cypress:ci './node_modules/.bin/cypress run -r mochawesome --record --group electron --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --parallel }} --tag SMOKE_TESTS --ci-build-id=${{ needs.prepare.outputs.uuid }}'
continue-on-error: true
env:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
- name: Merge test results into one
run: |
yarn run report:merge
mv index.json ${{ matrix.containers }}.json
continue-on-error: true
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.containers }}
path: |
${{ matrix.containers }}.json
tests/screenshots
cypress-report:
name: ⬡・Merge and generate cypress reports
needs: [install, cypress, synpress]
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- uses: actions/download-artifact@v3
with:
name: Container01
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container02
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container03
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container04
path: mochawesome-report
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: 01transactionless
path: mochawesome-report
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: 02transactionfull
path: mochawesome-report
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Merge test results into one
run: yarn run report:merge
- name: Generate HTML report
run: yarn run report:generate
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: test-report
path: |
public-report
mochawesome-report/public-report/screenshots/**
mochawesome-report/public-report/videos/**
retention-days: 3
- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
Container01
Container02
Container03
Container04
depcleanup:
name: 🧹 Dependabot Cleanup
if: github.actor == 'dependabot[bot]'
needs: [install, lint, test, typecheck, build]
runs-on: ubuntu-20.04
steps:
- name: Delete workspace artifact
uses: geekyeggo/delete-artifact@v2
with:
name: workspace
cleanup:
name: 🧹 Cleanup
if: ${{ success() && github.actor != 'dependabot[bot]' }}
needs: [install, lint, test, typecheck, build]
runs-on: ubuntu-20.04
steps:
- name: Delete workspace artifact
uses: geekyeggo/delete-artifact@v2
with:
name: workspace