-
Notifications
You must be signed in to change notification settings - Fork 41
351 lines (295 loc) · 12.5 KB
/
Copy pathci.yml
File metadata and controls
351 lines (295 loc) · 12.5 KB
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
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main
# Primes the new week's Rust cache on main right after the weekly `prefix-key` rolls
# over at UTC Sun 00:00. Without this, the first PR on Sunday pays a full cold-build
# cost and (since `save-if` requires main) doesn't save, so every subsequent Sunday
# PR keeps cold-building until something merges to main. See near/mpc#2828.
schedule:
- cron: "5 0 * * 0"
jobs:
# Downstream gates use `if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}`.
# `!cancelled()` overrides GitHub's implicit `success()` on `needs`, so a
# failed detector doesn't silently skip dependents (skipped checks satisfy
# required-check rules and could let a PR merge with zero CI signal). Only
# an explicit `'false'` (docs-only PR) skips the job. Unlike `always()`, it
# stops evaluating to true once the run is cancelled, so a new push cancels
# the in-progress run instead of queueing behind it.
changes:
name: "Detect non-docs changes"
permissions:
contents: read
pull-requests: read
uses: ./.github/workflows/changes.yml
docker-tee-build:
name: "Build MPC Node TEE Docker image"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-16x
timeout-minutes: 60
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Allow unprivileged user namespaces (needed by repro-env)
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Install repro-env
run: |
sudo apt-get update
sudo apt-get install -y repro-env
- name: Build MPC Node binary and image
run: |
export NODE_IMAGE_NAME=test_image_tag_ci
./deployment/build-images.sh --node
- name: Check mpc-node docker image can initialize and start
run: |
export NODE_IMAGE_NAME=test_image_tag_ci
./scripts/check-mpc-node-docker-starts.sh
docker-rust-launcher-build-and-verify:
name: "Build Rust Launcher Docker image and verify"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-8x
timeout-minutes: 60
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Allow unprivileged user namespaces (needed by repro-env)
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y liblzma-dev repro-env
- name: Build Rust launcher docker image
shell: bash
run: |
./deployment/build-images.sh --rust-launcher
- name: Run Rust launcher non-TEE runtime check
shell: bash
run: |
./scripts/check-mpc-node-docker-starts.sh --rust-launcher
mpc-unittests:
name: "Cargo test: ${{ matrix.group }}"
needs: changes
# Start (unless the run is cancelled) so GitHub expands the matrix and
# registers each check name ("Cargo test: node", etc.).
# Skipping at the job level only registers unexpanded template name and
# required checks will be stuck.
if: ${{ !cancelled() }}
runs-on: ${{ matrix.runner || 'warp-ubuntu-2604-x64-16x' }}
timeout-minutes: 60
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- group: "node"
nextest-args: "-p mpc-node"
- group: "contract"
nextest-args: "--profile=ci-contract -p mpc-contract"
extra-tools: true
runner: warp-ubuntu-2604-x64-32x
- group: "other"
nextest-args: "--profile=ci-other"
extra-tools: true
steps:
- name: Checkout repository
if: needs.changes.outputs.code_changed != 'false'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
if: needs.changes.outputs.code_changed != 'false'
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Restore /nix from cache
id: nix-cache
if: needs.changes.outputs.code_changed != 'false'
uses: ./.github/actions/restore-nix-cache
- run: echo "WEEK=$(date -u +%Y-%U)" >> "$GITHUB_ENV"
if: needs.changes.outputs.code_changed != 'false'
- name: Cache Rust dependencies
if: needs.changes.outputs.code_changed != 'false'
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-provider: "warpbuild"
prefix-key: v1-rust-tests-${{ matrix.group }}-week-${{ env.WEEK }}-nix-${{ steps.nix-cache.outputs.cache-key-hash }}
- name: Run cargo-nextest
if: needs.changes.outputs.code_changed != 'false'
run: nix develop --command cargo nextest run --cargo-profile=test-release --all-features --locked ${{ matrix.nextest-args }}
mpc-contract-reproducible-build:
name: "MPC contract reproducible build"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-16x
timeout-minutes: 60
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
# only save nix cache in this single job to avoid duplicate cache saves from other jobs
- name: Restore /nix from cache
uses: ./.github/actions/restore-nix-cache
with:
save: ${{ github.ref == 'refs/heads/main' }}
# Reproducible build that carries NEP-330 metadata; this is what the
# release artifact uses and what sourcescan.io / nearblocks replay.
- name: Build mpc-contract (reproducible, cargo-near)
run: nix develop --command cargo near build reproducible-wasm --manifest-path crates/contract/Cargo.toml
- name: Check contract WASM size
run: nix develop --command bash scripts/check-contract-wasm-size.sh target/near/mpc_contract/mpc_contract.wasm
# Independent reproducible path: the Nix derivation produces the contract WASM
# without a third-party Docker image. Kept exercised alongside the cargo-near
# build; see docs/reproducible-builds.md.
nix-build-mpc-contract:
name: "Nix build mpc-contract"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-16x
timeout-minutes: 60
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Restore /nix from cache
uses: ./.github/actions/restore-nix-cache
- name: Build mpc-contract (Nix)
run: nix build -L .#mpc-contract
nix-build-mpc-node:
name: "Nix build mpc-node"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
permissions:
contents: read
uses: ./.github/workflows/nix-build-mpc-node.yml
fast-ci-checks:
name: "Fast CI checks"
runs-on: warp-ubuntu-2604-x64-8x
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Restore /nix from cache
id: nix-cache
uses: ./.github/actions/restore-nix-cache
- run: echo "WEEK=$(date -u +%Y-%U)" >> "$GITHUB_ENV"
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-provider: "warpbuild"
prefix-key: v1-rust-week-${{ env.WEEK }}-nix-${{ steps.nix-cache.outputs.cache-key-hash }}
- name: Run cargo-make fast checks
run: nix develop --command cargo make check-all-fast
mpc-e2e-tests:
name: "MPC E2E tests"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-32x
timeout-minutes: 60
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Restore /nix from cache
id: nix-cache
uses: ./.github/actions/restore-nix-cache
- run: echo "WEEK=$(date -u +%Y-%U)" >> "$GITHUB_ENV"
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-provider: "warpbuild"
prefix-key: v1-rust-e2e-week-${{ env.WEEK }}-nix-${{ steps.nix-cache.outputs.cache-key-hash }}
- name: Build mpc-node
run: nix develop --command cargo make build-mpc-node-network-hardship-simulation
# Both build paths emit target/near/mpc_contract/mpc_contract.wasm, which
# MPC_CONTRACT_WASM points at. On main we exercise the fully reproducible
# (docker) build; on PRs the faster non-reproducible cargo-near build.
- name: Build mpc-contract
if: github.ref != 'refs/heads/main'
run: nix develop --command cargo make build-mpc-contract-optimized
- name: Build mpc-contract reproducibly
if: github.ref == 'refs/heads/main'
run: nix develop --command cargo near build reproducible-wasm --manifest-path crates/contract/Cargo.toml
- name: Build tee-verifier
run: nix develop --command cargo make build-tee-verifier-optimized
- name: Build test-parallel-contract
run: nix develop --command cargo make build-test-parallel-contract-optimized
- name: Build backup-cli
run: nix develop --command cargo build -p backup-cli --release --locked
- name: Run E2E tests
run: nix develop --command cargo make e2e-tests-skip-build
env:
RUST_LOG: info,e2e_tests=debug
ci-extra:
name: "Extra CI checks"
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code_changed != 'false' }}
runs-on: warp-ubuntu-2604-x64-2x
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Restore /nix from cache
uses: ./.github/actions/restore-nix-cache
- name: Run cargo-make extra checks
run: nix develop --command cargo make check-extra
check-todo-closed-issues:
name: "Check TODOs for issues closed by this PR"
if: github.event_name == 'pull_request'
runs-on: warp-ubuntu-2604-x64-2x
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Check TODOs for issues closed by this PR
run: bash .github/scripts/check-todo-closed-issues.sh
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}