-
Notifications
You must be signed in to change notification settings - Fork 44
455 lines (397 loc) · 12.4 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
name: CI
env:
APP_ENV: CI
IS_CI: true
CI: true # ensures Vitest allowOnly option is false so no tests are accidentally skipped
NODE_ENV: 'test'
ROLLBAR_ENV: 'GitHubCI'
TEST_WITHOUT_LOGS: 'true'
ALLOWED_EVENTS: 'ChainEventCreated,SnapshotProposalCreated,ThreadCreated,ThreadUpvoted,SubscriptionPreferencesUpdated,CommentCreated,UserMentioned'
PRIVATE_KEY: 'web3-pk'
USES_DOCKER_PGSQL: true
PORT: 8080
REDIS_URL: redis://localhost:6379
ENTITIES_URL: ${{ secrets.ENTITIES_URL }}
GITHUB_BASE_REF: ${{ github.base_ref }}
FEDERATION_POSTGRES_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
ALCHEMY_PRIVATE_APP_KEY: ${{ secrets.ALCHEMY_PRIVATE_APP_KEY }}
ALCHEMY_PUBLIC_APP_KEY: ${{ secrets.ALCHEMY_PUBLIC_APP_KEY }}
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:
name: Commonwealth E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 20
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
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- uses: ./.github/actions/e2e
- name: Run e2e tests
run: |
sudo local-ssl-proxy --source 443 --target 8080 &
pnpm -F commonwealth e2e-start-server --forbid-only &
pnpm -F commonwealth wait-server &&
pnpm -F 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:
name: Commonwealth Mature E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 30
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
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- uses: ./.github/actions/e2e
- name: Run e2e tests
run: |
sudo local-ssl-proxy --source 443 --target 8080 &
pnpm -F commonwealth e2e-start-server --forbid-only &
pnpm -F commonwealth wait-server &&
pnpm -F 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:
name: Commonwealth E2E Tests Serial
runs-on: ubuntu-latest
timeout-minutes: 10
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
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- uses: ./.github/actions/e2e
- name: Build server
run: pnpm -F commonwealth build
- name: Run serial e2e tests
run: |
pnpm -F commonwealth bootstrap-test-db &&
(cd packages/commonwealth && node --import=extensionless/register --enable-source-maps ./build/server.js) &
(pnpm -F commonwealth wait-server && pnpm -F commonwealth test-e2e-serial --forbid-only)
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage
# Lint with recommendations
commonwealth-code-quality-recommendations:
name: Code Quality Recommendations
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Run linter
run: pnpm lint-branch-warnings
# Lint and Typecheck
commonwealth-code-quality:
name: Code Quality checks
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Assert pnpm-lock.yaml is correct
run: |
if ! git diff --quiet; then
echo 'You need to update the pnpm-lock.yaml file (potentially after installing node-gyp)'
exit 1
fi
- name: build
run: pnpm -r build
- name: check-types
run: pnpm -r check-types
# To disable eslint-diff just comment the following two lines
- name: Run eslint-diff
run: pnpm -r run lint-diff
- name: Run eslint-diff-canary to make sure eslint-diff is functioning properly
run: pnpm -F commonwealth run lint-diff-canary
# fun the *old* linter last because I want to try to migrate away from
# this and JUST to eslint-diff but if this fails we still might be able
# to salvage the branch
- name: Run linter
run: pnpm lint-branch
detect-broken-ts-expect-error:
name: Detect Broken TS expect errors
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Assert pnpm-lock.yaml is correct
run: |
if ! git diff --quiet; then
echo 'You need to update the pnpm-lock.yaml file (potentially after installing node-gyp)'
exit 1
fi
- name: build
run: pnpm -r build
- name: run detect-broken-ts-expect-error.sh
run: cd packages/commonwealth && ./scripts/detect-broken-ts-expect-error.sh
# These tests run quickly, so run them in a separate job
commonwealth-integration-test:
name: Commonwealth Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
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
redis:
image: redis:latest
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.11-management
ports:
- 5672:5672
- 15672:15672
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
# TODO: use devmode instead to avoid building
- name: Build
run: pnpm -r build
- name: Run integration tests
run: pnpm -F commonwealth test-integration --allowOnly=false
commonwealth-unit-tests:
name: Commonwealth Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 20
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
redis:
image: redis:latest
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.11-management
ports:
- 5672:5672
- 15672:15672
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Run unit tests
run: pnpm -r test -- --allowOnly=false
- name: Change permissions of coverage files
run: |
chmod -R 755 ./libs/adapters/coverage/lcov.info
chmod -R 755 ./libs/core/coverage/lcov.info
chmod -R 755 ./libs/model/coverage/lcov.info
chmod -R 755 ./libs/sitemaps/coverage/lcov.info
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: unit-test-coverage
parallel: true
files: libs/adapters/coverage/lcov.info libs/core/coverage/lcov.info libs/model/coverage/lcov.info libs/sitemaps/coverage/lcov.info
commonwealth-evm-tests:
name: EVM Devnet Tests
runs-on: ubuntu-latest
timeout-minutes: 10
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
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false
report-coverage:
name: Upload Test Coverage Report
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ commonwealth-unit-tests ]
if: always()
strategy:
matrix:
node: [ 20 ]
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true