-
Notifications
You must be signed in to change notification settings - Fork 12
452 lines (429 loc) · 16.6 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
name: Build & Test
run-name: 'Build & Test: ${{ github.head_ref || github.ref_name }}'
# Dockefile for the self-hosted runner:
# https://github.com/celo-org/infrastructure/blob/master/terraform/root-modules/gcp/integration-tests-gke/files/github-arc/Dockerfile-monorepo
on:
push:
branches:
- master
- changeset-release/master
- prerelease/*
- hotfixes
pull_request:
types: [opened, reopened, synchronize, edited, ready_for_review]
concurrency:
group: dev-tooling-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash --login -eo pipefail {0}
env:
# Increment these to force cache rebuilding
NODE_MODULE_CACHE_VERSION: 5
NODE_OPTIONS: '--max-old-space-size=4096'
TERM: dumb
# Supported Foundry version defined at celo-org (GitHub organisation) level, for consistency across workflows.
SUPPORTED_FOUNDRY_VERSION: ${{ vars.SUPPORTED_FOUNDRY_VERSION }}
# EXAMPLE on debug ssh step
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 20
# if: contains(matrix.command, 'common/') && false
# with:
# limit-access-to-actor: true
jobs:
install-dependencies:
name: Install dependencies
outputs:
# Propagate more outputs if you need https://github.com/tj-actions/changed-files#outputs
# Adding a initial comma so ',<path>' matches also for the first file
all_modified_files: ',${{ steps.changed-files.outputs.all_modified_files }}'
artifacts_to_cache: ${{ steps.get_artifacts_to_cache.outputs.artifacts_to_cache }}
# runs-on: ubuntu-latest
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
steps:
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'enable corepack for yarn'
run: sudo corepack enable yarn
- uses: actions/checkout@v4
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Restore node cache
uses: actions/cache@v4
id: cache_node
with:
# We need to cache all the artifacts generated by yarn install+build
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list
path: |
./.yarn/cache
./.yarn/install-state.gz
node_modules
packages/**/node_modules
key: node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-
- name: Install yarn dependencies
run: git config --global url."https://".insteadOf ssh:// && yarn install
if: steps.cache_node.outputs.cache-hit != 'true'
- name: Run yarn postinstall if cache hitted
run: yarn run postinstall
if: steps.cache_node.outputs.cache-hit == 'true'
- name: Build packages
run: yarn build
- name: Check licenses
if: steps.cache_node.outputs.cache-hit != 'true'
run: |
yarn check-licenses
# Get workdir local changes and fail if there are any change
# - name: Verify Changed files
# id: verify-changed-files
# uses: tj-actions/verify-changed-files@v17
# with:
# path: yarn.lock
# fail-if-changed: 'true'
# fail-message: 'Files changed during build. Please build locally and commit the changes.'
# files: |
# **/*
- run: |
echo "${{ steps.verify-changed-files.outputs.changed_files }}"
- name: Get the artifacts to cache
id: get_artifacts_to_cache
# there are too many files when listed individually.
run: |
artifacts_to_cache="$(git ls-files --others --ignored --exclude-standard | grep -v node_modules | grep -v .js.map | grep -v .d.ts.map | grep -v .yarn/cache)"
echo "artifacts_to_cache<<EOF" >> $GITHUB_OUTPUT
echo "$artifacts_to_cache" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# We use cache to share the build artifacts between jobs (gh artifacts are too slow...)
# For more context check https://github.com/actions/upload-artifact/issues/199
- name: Restore build artifacts cache
uses: actions/cache@v4
id: cache_build_artifacts
with:
# We need to cache all the artifacts generated by yarn install+build
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list
path: |
${{ steps.get_artifacts_to_cache.outputs.artifacts_to_cache }}
key: code-${{ github.sha }}
restore-keys: |
code-${{ github.sha }}
- name: Detect files changed in PR (or commit), and expose as output
id: changed-files
uses: tj-actions/changed-files@v44
with:
# Using comma as separator to be able to easily match full paths (using ,<path>)
separator: ','
# Checking if changed in the last 100 commits in PRs
fetch_depth: '150'
- run: echo ",${{ steps.changed-files.outputs.all_modified_files }}"
lint-checks:
name: Lint code
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
needs: install-dependencies
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: yarn run prettify:diff
- run: yarn run lint
general_test:
name: General jest test
runs-on: ['self-hosted', 'org', '8-cpu']
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: install-dependencies
steps:
- uses: actions/checkout@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.SUPPORTED_FOUNDRY_VERSION }}
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Run Jest Tests
run: |
mkdir -p test-results/jest
# Skipping packages that are tested in a specific job below
yarn workspaces foreach \
--all \
--exclude celo \
--exclude "@celo/{celocli,contractkit,wallet-*}" \
-ip \
run test --coverage
- name: Upload Jest Test Results
uses: actions/upload-artifact@v4
with:
name: Jest Test Results
path: test-results/jest
- uses: ./.github/actions/upload-codecov
with:
report-name: "general_test"
wallet-test:
name: Wallet test
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: install-dependencies
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Run Wallet tests
run: |
yarn workspaces foreach -ip --all --include '@celo/wallet-*' run test --coverage
- uses: ./.github/actions/upload-codecov
with:
report-name: "wallet"
contractkit-tests-anvil:
name: ContractKit Tests (Anvil)
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: [install-dependencies]
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9"
- name: Run tests
run: |
yarn workspace @celo/contractkit test-anvil --coverage
- uses: ./.github/actions/upload-codecov
with:
report-name: "contractkit-anvil"
contractkit-tests-ganache:
name: ContractKit Tests (Ganache)
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: [install-dependencies]
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9"
- name: Run tests
run: |
yarn workspace @celo/contractkit test-ganache --coverage
- uses: ./.github/actions/upload-codecov
with:
report-name: "contractkit-ganache"
cli-package-verification:
name: CeloCli Package Verification
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: [install-dependencies]
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Install globally as a package
run: |
npm install -g $RUNNER_WORKSPACE/developer-tooling/packages/cli
- name: Print out the current version
run: |
celocli --version
- name: Test that it prints out alfajores contracts
run: |
celocli network:info --node alfajores
celocli account:new
cli-tests-anvil:
name: CeloCli Tests (Anvil)
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: [install-dependencies]
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.SUPPORTED_FOUNDRY_VERSION }}
- name: Run tests
run: |
yarn workspace @celo/celocli test-ci-anvil --coverage
- name: Verify that a new account can be created
run: |
yarn workspace @celo/celocli run celocli account:new
- name: Test that releasecelo command topic is working
run: |
yarn workspace @celo/celocli run celocli releasecelo --help
- uses: ./.github/actions/upload-codecov
with:
report-name: "celocli-anvil"
cli-tests-ganache:
name: CeloCli Tests (Ganache)
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
permissions: # Must change the job token permissions to use Akeyless JWT auth
id-token: write
contents: read
needs: [install-dependencies]
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.SUPPORTED_FOUNDRY_VERSION }}
- name: Run tests
run: |
yarn workspace @celo/celocli test-ci-ganache --coverage
- uses: ./.github/actions/upload-codecov
with:
report-name: "celocli-ganache"
docs-tests:
name: Docs tests
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
needs: [install-dependencies]
if: |
github.base_ref == 'master' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/**') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/sdk') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Fail if someone forgot to commit docs
run: |
yarn docs
if [[ $(git status docs --porcelain) ]]; then
git --no-pager diff docs
echo "There are git differences after generating all docs"
git status
git diff
exit 1
fi
base-test:
name: SDK Base package Tests
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
needs: [install-dependencies]
if: |
github.base_ref == 'master' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/sdk') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/typescript') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Install and test the npm package
run: |
set -euo pipefail
cd packages/sdk/base
yarn pack
cd $RUNNER_TEMP
npm install $RUNNER_WORKSPACE/developer-tooling/packages/sdk/base/*.tgz
utils-test:
name: SDK Utils package Tests
runs-on: ['self-hosted', 'org', '8-cpu']
timeout-minutes: 30
needs: [install-dependencies]
if: |
github.base_ref == 'master' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/sdk') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/typescript') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
steps:
- uses: actions/checkout@v4
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- run: sudo corepack enable yarn
- name: Install and test the npm package
run: |
set -euo pipefail
cd packages/sdk/base
yarn pack
cd ../utils
yarn pack
cd $RUNNER_TEMP
npm install $RUNNER_WORKSPACE/developer-tooling/packages/sdk/base/*.tgz
npm install $RUNNER_WORKSPACE/developer-tooling/packages/sdk/utils/*.tgz
validate-renovate-config:
name: Validate Renovate Config
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Validate Team Config
uses: suzuki-shunsuke/[email protected]
with:
config_file_path: dt-renovate-base.json
strict: "false"
- name: Validate Repo Config
uses: suzuki-shunsuke/[email protected]
with:
config_file_path: renovate.json
strict: "false"