forked from hicommonwealth/commonwealth
-
Notifications
You must be signed in to change notification settings - Fork 0
590 lines (504 loc) · 17.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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
name: CI
env:
ROLLBAR_ENV: 'GitHubCI'
NODE_ENV: 'test'
TEST_WITHOUT_LOGS: 'true'
on:
pull_request:
merge_group:
push:
branches:
- master
jobs:
# These tests run slowly, so run them in a separate job. NOTE: if you change the name of this job, also change
# Its references in this file
e2e-tests-Parallel:
strategy:
matrix:
node: [ 20 ]
name: Commonwealth E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build CI
run: yarn build-ci
- name: Cache browsers
id: playwright-cache
uses: actions/cache@v3
with:
path: '~/.cache/ms-playwright/chromium-1045'
key: hashFiles('~/.cache/ms-playwright/chromium-1045') }}
- name: Install playwright browser drivers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium
- name: Install proxy
run: npm install -g local-ssl-proxy
- name: Add custom domain to /etc/hosts
run: sudo sh -c 'echo "127.0.0.1 customdomain.com" >> /etc/hosts'
- name: Run e2e tests (yarn test-e2e)
env:
PORT: 8080
IS_CI: true
USES_DOCKER_PGSQL: true
ETH_ALCHEMY_API_KEY: ${{ secrets.ETH_ALCHEMY_API_KEY }}
ENTITIES_URL: ${{ secrets.ENTITIES_URL }}
run: |
sudo local-ssl-proxy --source 443 --target 8080 &
yarn --cwd packages/commonwealth e2e-start-server --forbid-only &
yarn --cwd packages/commonwealth wait-server && yarn --cwd packages/commonwealth test-e2e --forbid-only
- name: Archive test status
uses: actions/upload-artifact@v3
with:
name: FlakySuiteStatus
path: packages/commonwealth/summary.json
- name: Upload e2e recordings on failure
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: Recordings
path: packages/commonwealth/test-results/
# The tests that this job runs should not be flaky. If they are, move them back into the regular suite.
e2e-tests-Mature:
strategy:
matrix:
node: [ 20 ]
name: Commonwealth Mature E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build CI
run: yarn build-ci
- name: Cache browsers
id: playwright-cache
uses: actions/cache@v3
with:
path: '~/.cache/ms-playwright/chromium-1045'
key: hashFiles('~/.cache/ms-playwright/chromium-1045') }}
- name: Install playwright browser drivers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium
- name: Install proxy
run: npm install -g local-ssl-proxy
- name: Add custom domain to /etc/hosts
run: sudo sh -c 'echo "127.0.0.1 customdomain.com" >> /etc/hosts'
- name: Run e2e tests (yarn test-e2e)
env:
PORT: 8080
IS_CI: true
USES_DOCKER_PGSQL: true
ETH_ALCHEMY_API_KEY: ${{ secrets.ETH_ALCHEMY_API_KEY }}
ENTITIES_URL: ${{ secrets.ENTITIES_URL }}
run: |
sudo local-ssl-proxy --source 443 --target 8080 &
yarn --cwd packages/commonwealth e2e-start-server --forbid-only &
yarn --cwd packages/commonwealth wait-server && yarn --cwd packages/commonwealth test-e2e-mature --forbid-only
- name: Archive test status
uses: actions/upload-artifact@v3
with:
name: MatureSuiteStatus
path: packages/commonwealth/summary.json
- name: Upload e2e recordings on failure
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: Recordings
path: packages/commonwealth/test-results/
e2e-tests-serial:
strategy:
matrix:
node: [ 20 ]
name: Commonwealth E2E Tests Serial
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build CI
run: yarn build-ci
- name: Cache browsers
id: playwright-cache
uses: actions/cache@v3
with:
path: '~/.cache/ms-playwright/chromium-1045'
key: hashFiles('~/.cache/ms-playwright/chromium-1045') }}
- name: Install playwright browser drivers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium
- name: Run serial e2e tests (yarn test-e2e-serial)
run: yarn --cwd packages/commonwealth e2e-start-server & (yarn --cwd packages/commonwealth wait-server && yarn --cwd packages/commonwealth test-e2e-serial --forbid-only)
env:
PORT: 8080
USES_DOCKER_PGSQL: true
ETH_ALCHEMY_API_KEY: ${{ secrets.ETH_ALCHEMY_API_KEY }}
ENTITIES_URL: ${{ secrets.ENTITIES_URL }}
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage
# Lint with recommendations
commonwealth-code-quality-recommendations:
strategy:
matrix:
node: [ 20 ]
name: Code Quality Recommendations
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Add node-gyp
run: yarn global add node-gyp
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn --ignore-engines
- name: Run linter
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
run: yarn lint-branch-warnings
# Lint and Typecheck
commonwealth-code-quality:
strategy:
matrix:
node: [ 20 ]
name: Code Quality checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Add node-gyp
run: yarn global add node-gyp
- name: Install dependencies
run: yarn --ignore-engines
- name: Assert yarn.lock is correct
run: |
if ! git diff --quiet; then
echo 'You need to update the yarn.lock file (potentially after running: yarn global add node-gyp)'
exit 1
fi
- name: Build
run: yarn build
- name: Run linter
env:
GITHUB_BASE_REF: ${{ github.base_ref }}
run: yarn lint-branch
# To disable eslint-diff just comment the following two lines
#- name: Run eslint-diff
# run: yarn workspace commonwealth run lint-diff
- name: Run eslint-diff-canary to make sure eslint-diff is functioning properly
run: yarn workspace commonwealth run lint-diff-canary
- name: Commonwealth Typecheck
run: yarn --cwd packages/commonwealth check-types
- name: Discord-Bot Typecheck
run: yarn --cwd packages/discord-bot check-types
- name: Snapshot-listener Typecheck
run: yarn --cwd packages/snapshot-listener check-types
# These tests run quickly, so run them in a separate job
commonwealth-unit-integration:
strategy:
matrix:
node: [ 20 ]
name: Commonwealth Unit And Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.11-management
ports:
- 5672:5672
- 15672:15672
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build CI
run: yarn build-ci
- name: Run unit tests
run: yarn workspaces run test
- name: Run API tests
run: yarn --cwd packages/commonwealth test-api --forbid-only
env:
NO_CLIENT: true
- name: Run util integration tests
run: yarn --cwd packages/commonwealth test-integration-util --forbid-only
env:
NO_CLIENT: true
# These tests run slowly, so run them in a separate job
commonwealth-devnet-tests:
name: Devnet Tests
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
matrix:
node: [ 20 ]
services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
evm_test_app:
image: irowan/common_chain_tests
ports:
- 3000:3000
cosmos_test_app:
image: mhagel1/csdk-v1
ports:
- 5051:5051
cosmos_beta_test_app:
image: mhagel1/csdk-beta
ports:
- 5050:5050
evmos_test_app:
image: mhagel1/evmos-dev
ports:
- 5052:5052
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Build CI
run: yarn build-ci
## EVM Section:
- name: Start EVM Testnet
run: |
/usr/bin/docker pull trufflesuite/ganache;
network_name=$(docker inspect -f '{{.HostConfig.NetworkMode}}' ${{ job.services.evm_test_app.id }})
echo "Network name: $network_name"
/usr/bin/docker run -d --name chain --network $network_name --network-alias chain -p 8545:8545 -e GITHUB_ACTIONS=true -e CI=true trufflesuite/ganache --fork --miner.blockTime 12 --wallet.unlockedAccounts 0xF977814e90dA44bFA03b6295A0616a897441aceC --wallet.unlockedAccounts 0xfA9b5f7fDc8AB34AAf3099889475d47febF830D7 --wallet.unlockedAccounts 0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8;
- name: Run EVM Devnet tests
run: yarn --cwd packages/commonwealth test-devnet evm --forbid-only
- name: Stop EVM Chain
run: docker stop chain
## Cosmos Section:
# We only run Cosmos devnet tests if any files in the following folders changes
- name: Get changed Cosmos devnet-related files
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: |
packages/commonwealth/test/devnet/cosmos/**/*
packages/commonwealth/server/cosmos-gov-notifications/**/*
packages/commonwealth/test/integration/cosmosGovNotifGenerator.spec.ts
packages/commonwealth/server/util/cosmosProxy.ts
packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/**/*
packages/commonwealth/test/util/cosmos-chain-testing/**/*
libs/chains/src/cosmos-ts/**/*
- name: Run following steps if any file(s) in the Cosmos folders change
if: steps.changed-files-specific.outputs.all_changed_files
run: |
echo "One or more Cosmos Devnet-related files has changed."
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
- name: Run Cosmos Devnet tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: yarn --cwd packages/commonwealth start & (yarn --cwd packages/commonwealth wait-server && yarn --cwd packages/commonwealth test-devnet cosmos --forbid-only)
env:
PORT: 8080
USES_DOCKER_PGSQL: true
REDIS_URL: redis://localhost:6379
snapshot-test:
strategy:
matrix:
node: [ 20 ]
name: Snapshot Tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
# We only run snapshot tests if any files in the following folders changes
- name: Get changed Snapshot package files
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: packages/snapshot-listener/**/*
- name: Run following steps if any file(s) in the snapshot package changes
if: steps.changed-files-specific.outputs.all_changed_files
run: |
echo "One or more snapshot pacakge files has changed."
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.node }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn global add node-gyp && yarn --ignore-engines
- name: Build
run: yarn --cwd packages/snapshot-listener build
- name: Run API tests
run: yarn --cwd packages/snapshot-listener test --forbid-only