-
Notifications
You must be signed in to change notification settings - Fork 273
477 lines (401 loc) · 14.3 KB
/
pull-request.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
475
476
477
name: Run all tests
on:
push:
branches:
- develop
pull_request:
jobs:
build-all-artifacts:
runs-on: ubuntu-latest
strategy:
matrix:
env: [prod, hydrogen]
extension_type: [chrome, firefox]
environment: ${{ matrix.env }}
env:
# FEATURE flags
FEATURE_PRIVACY_SETTINGS: "true"
FEATURE_EXPERIMENTAL_SETTINGS: "false"
FEATURE_BETA_FEATURES: "true"
FEATURE_BANXA: "true"
FEATURE_LAYERSWAP: "true"
FEATURE_ORBITER: "true"
FEATURE_VERIFIED_DAPPS: "true"
FEATURE_MULTISIG: "true"
# API URLs
ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }}
ARGENT_X_STATUS_URL: ${{ vars.ARGENT_X_STATUS_URL }}
# API ENVIRONMENT
ARGENT_X_ENVIRONMENT: ${{ matrix.env }}
# Sentry
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ENVIRONMENT: "staging"
# Misc
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
RAMP_API_KEY: ${{ secrets.RAMP_API_KEY }}
SAFE_ENV_VARS: false
MULTICALL_MAX_BATCH_SIZE: 20
# Refresh intervals
FAST: 20 # 20s
MEDIUM: 60 # 60s
SLOW: 60 * 5 # 5m
VERY_SLOW: 24 * 60 * 60 # 1d
steps:
# Setup Project
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup project
run: pnpm run setup
- name: Build extension for ${{ matrix.extension_type }}
run: |
if [[ "${{ matrix.extension_type }}" == "firefox" ]]; then
MANIFEST_VERSION=v2 pnpm run build:extension
else
MANIFEST_VERSION=v3 pnpm run build:extension
fi
- name: Check bundlesize for ${{ matrix.extension_type }}
run: pnpm bundlewatch
- name: Use Cache
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}-${{ matrix.extension_type }}-${{ matrix.env }}
- name: Set filename prefix
run: echo "FILENAME_PREFIX=$(echo argent-x-${{ matrix.env }}-${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV
- name: Create ${{ matrix.extension_type }} zip
run: (cd ./packages/extension/dist && zip -r "../../../${{ env.FILENAME_PREFIX }}-${{ matrix.extension_type }}" .)
- name: Upload ${{ matrix.extension_type }} extension
uses: actions/upload-artifact@v3
with:
name: ${{ env.FILENAME_PREFIX }}-${{ matrix.extension_type }}
path: "*-${{ matrix.extension_type }}.zip"
retention-days: 3
test-unit:
runs-on: ubuntu-latest
needs: [build-all-artifacts]
environment: "hydrogen" # test-unit is always run against hydrogen
env:
ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }}
ARGENT_X_STATUS_URL: ${{ vars.ARGENT_X_STATUS_URL }}
ARGENT_X_ENVIRONMENT: "hydrogen"
services:
devnet:
image: shardlabs/starknet-devnet:latest-seed0
ports:
- 5050:5050
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Restore pnpm cache
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore cached build
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}-chrome-hydrogen # test-unit is always run against chrome-hydrogen build
- name: Lint
run: pnpm run lint
- name: Run tests
run: pnpm run test:ci
- name: SonarCloud Scan
# TODO replace with master as soon as sonarcloud fixes the issue with action https://community.sonarsource.com/t/sonarsource-sonarcloud-github-action-failing-with-node-js-12-error/89664/2
uses: SonarSource/[email protected]
with:
projectBaseDir: ./packages/extension
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
test-e2e:
runs-on: ubuntu-latest
needs: [build-all-artifacts]
strategy:
matrix:
project: [ArgentX]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8]
env:
ARGENT_X_ENVIRONMENT: "hydrogen"
E2E_TESTNET_SEED1: ${{ secrets.E2E_TESTNET_SEED1 }}
E2E_TESTNET_SEED2: ${{ secrets.E2E_TESTNET_SEED2 }}
E2E_TESTNET_SEED3: ${{ secrets.E2E_TESTNET_SEED3 }}
E2E_ACCOUNT_1_SEED2: ${{ secrets.E2E_ACCOUNT_1_SEED2 }}
E2E_ACCOUNT_1_SEED3: ${{ secrets.E2E_ACCOUNT_1_SEED3 }}
## BANK ACCOUNT, USED FOR FUND OTHER ACCOUNTS
E2E_SENDER_ADDRESS: ${{ secrets.E2E_SENDER_ADDRESS }}
E2E_SENDER_PRIVATEKEY: ${{ secrets.E2E_SENDER_PRIVATEKEY }}
E2E_SENDER_SEED: ${{ secrets.E2E_SENDER_SEED }}
STARKNET_TESTNET_URL: ${{ secrets.STARKNET_TESTNET_URL }}
STARKSCAN_TESTNET_URL: ${{ secrets.STARKSCAN_TESTNET_URL }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Restore pnpm cache
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore cached build
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}-chrome-${{ env.ARGENT_X_ENVIRONMENT }} # test-e2e is always run against chrome-hydrogen build
- name: Install Playwright Browsers
run: npx playwright install chromium
- name: Run e2e tests
run: xvfb-run --auto-servernum pnpm test:e2e:extension --project=${{ matrix.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: test-artifacts
path: |
packages/e2e/artifacts/playwright/
retention-days: 5
- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: all-blob-reports
path: packages/e2e/blob-report/
retention-days: 5
merge-reports:
needs: [test-e2e, test-webwallet]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "16"
cache: "pnpm"
- name: Restore pnpm cache
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: all-blob-reports
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
add_pr_comments:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'}} # Run only for pull requests and if not triggered by dependabot
needs: [build-all-artifacts, test-unit, test-e2e]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Restore pnpm cache
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Set GHA_BRANCH
run: echo "GHA_BRANCH=$(echo $GITHUB_REF | awk -F / '{print $3}')" >> $GITHUB_ENV
- name: Comment PR
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ env.GHA_BRANCH }} --body "[Builds for local testing](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
create_sentry_release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'}} # Run only for pull requests and if not triggered by dependabot
needs: [build-all-artifacts, test-unit, test-e2e]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Restore cached build
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}-chrome-hydrogen
- name: Get Extension version
id: package-version
run: |
PACKAGE_VERSION=$(cat ./packages/extension/package.json | jq -r '.version')
echo "current-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
- name: Check sourcemaps
run: |
ls -l ./packages/extension
if [ ! -d "./packages/extension/sourcemaps" ]; then
echo "No sourcemaps found"
exit 0
fi
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_LOG_LEVEL: debug
with:
environment: ${{ env.SENTRY_ENVIRONMENT }}
sourcemaps: "./packages/extension/dist ./packages/extension/sourcemaps"
url_prefix: "~/"
version: ${{ steps.package-version.outputs.current-version }}-rc__${{ github.sha }}
ignore_missing: true
test-webwallet:
runs-on: ubuntu-latest
needs: [build-all-artifacts]
continue-on-error: true
environment: hydrogen
env:
NEXT_PUBLIC_NETWORK: "testnet"
NEXT_PUBLIC_RAMP_API_KEY: ${{ secrets.RAMP_API_KEY }}
NEXT_PUBLIC_FEATURE_COSIGNER: "true"
NEXT_PUBLIC_ARGENT_API_BASE_URL: ${{ vars.ARGENT_API_BASE_URL }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Restore cached build
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}
- name: Build webwallet
run: pnpm run build:web
- name: Install Playwright Browsers
run: pnpm playwright install --with-deps
- name: Run tests
run: |
pnpm run --filter @argent/web start:ci &
sleep 10 &&
curl http://localhost:3005 &&
pnpm run test:e2e:webwallet
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: test-artifacts
path: |
packages/e2e/artifacts/playwright/
retention-days: 5
- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: all-blob-reports
path: packages/e2e/blob-report/
retention-days: 5
slack_notif:
runs-on: ubuntu-latest
if: always()
needs: [test-unit, test-e2e, test-webwallet]
steps:
- name: Send notification to Slack
uses: 8398a7/[email protected]
with:
status: custom
custom_payload: |
{
text: "*ArgentX* - ${{ env.BUILD_TYPE }} - ${{ env.BUILD_STATUS == 'good' && 'SUCCESS' || 'FAILED' }}",
attachments: [{
fallback: 'fallback',
color: '${{ env.BUILD_STATUS }}',
title: 'Artifacts for testing ${{ env.BUILD_TYPE }} <${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number }}|${{ github.event.number }} ${{ github.event.pull_request.title }}>',
text: '<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts|Artifacts link>',
fields: [{},],
actions: [{}]}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_TYPE: ${{ github.event_name == 'pull_request' && 'pull request' || 'develop' }}
BUILD_STATUS: ${{ needs.test-unit.result == 'success' && needs.test-e2e.result == 'success' && needs.test-webwallet.result == 'success' && 'good' || 'danger' }}