-
Notifications
You must be signed in to change notification settings - Fork 339
387 lines (372 loc) · 14.3 KB
/
main.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
name: CI
on:
merge_group:
pull_request:
branches: [main, "release-*"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# this is needed to gain access via OIDC to the S3 bucket for caching
permissions:
id-token: write
contents: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_TOOLCHAIN_VERSION: test-release-2
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
check-benchmarks: ${{ steps.filter.outputs.check-benchmarks }}
check-template: ${{ steps.filter.outputs.check-template }}
crates-validator: ${{ steps.filter.outputs.crates-validator }}
doc: ${{ steps.filter.outputs.doc }}
examples: ${{ steps.filter.outputs.examples }}
test: ${{ steps.filter.outputs.test }}
web: ${{ steps.filter.outputs.web }}
steps:
- uses: actions/checkout@v4
- uses: risc0/paths-filter@4067d885736b84de7c414f582ac45897079b0a78
id: filter
with:
filters: |
base: &base
- .github/actions/**
- Cargo.toml
check-benchmarks:
- *base
- benchmarks/**
- risc0/**
check-template:
- *base
- risc0/**
- templates/**
crates-validator:
- *base
- tools/crates-validator/**
doc:
- *base
- bonsai/sdk/**
- risc0/**
examples:
- *base
- examples/**
- risc0/**
test:
- *base
- bonsai/sdk/**
- external/**
- risc0/**
web:
- *base
- examples/browser-verify/**
- risc0/**
- xtask/**
# see: https://github.com/orgs/community/discussions/26822
main-status-check:
if: always()
needs:
- check
- check-benchmarks
- check-template
- crates-validator
- doc
- examples
- reproducible-build
- test
- web
runs-on: ubuntu-latest
steps:
- name: Check all job status
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
# see https://stackoverflow.com/a/67532120/4907315
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Full history is required by license-check.py
fetch-depth: 0
- uses: ./.github/actions/rustup
- name: Install cargo-sort
uses: risc0/cargo-install@2cfb0024938d23011106cbf127b393bc83fddba1
with:
crate: cargo-sort
version: "1.0"
- uses: actions/setup-node@v3
with:
node-version: 18
- run: cargo fmt --all --check
- run: cargo fmt --all --check --manifest-path benchmarks/Cargo.toml
- run: cargo fmt --all --check --manifest-path bonsai/Cargo.toml
- run: cargo fmt --all --check --manifest-path bonsai/examples/governance/Cargo.toml
- run: cargo fmt --all --check --manifest-path examples/Cargo.toml
- run: cargo fmt --all --check --manifest-path tools/crates-validator/Cargo.toml
- run: cargo sort --workspace --check
- run: cargo sort --workspace --check benchmarks
- run: cargo sort --workspace --check bonsai
- run: cargo sort --workspace --check bonsai/examples/governance
- run: cargo sort --workspace --check examples
- run: cargo sort --workspace --check tools/crates-validator
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: python license-check.py
test:
if: needs.changes.outputs.test == 'true'
needs: changes
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.device }}"]
strategy:
fail-fast: false
matrix:
os: [Linux, macOS]
feature: [default]
device: [cpu]
include:
- os: Linux
feature: cuda
device: nvidia_rtx_a5000
env:
FEATURE: ${{ matrix.feature }}
RISC0_BUILD_LOCKED: 1
RUST_BACKTRACE: full
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
with:
lfs: true
- if: matrix.feature == 'cuda'
uses: ./.github/actions/cuda
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: ${{ matrix.os }}-${{ matrix.feature }}
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- name: build workspace
run: |
cargo test -F $FEATURE -F fault-proof -F prove --workspace --timings --no-run \
--exclude doc-test \
--exclude bonsai-ethereum-contracts \
--exclude bonsai-ethereum-relay \
--exclude bonsai-rest-api-mock
- name: test workspace
run: |
cargo test -F $FEATURE -F fault-proof -F prove --workspace --timings \
--exclude doc-test \
--exclude bonsai-ethereum-contracts \
--exclude bonsai-ethereum-relay \
--exclude bonsai-rest-api-mock
- uses: actions/upload-artifact@v3
with:
name: cargo-timings-${{ matrix.os }}-${{ matrix.device }}
path: target/cargo-timings/
retention-days: 5
- name: build risc0-r0vm
run: cargo test -p risc0-r0vm -F $FEATURE -F disable-dev-mode --no-run
- name: test risc0-r0vm
run: cargo test -p risc0-r0vm -F $FEATURE -F disable-dev-mode
- run: cargo test -p cargo-risczero -F experimental
if: matrix.device == 'cpu'
- run: |
cargo check -F $FEATURE --benches --workspace \
--exclude doc-test \
--exclude bonsai-ethereum-contracts \
--exclude bonsai-ethereum-relay \
--exclude bonsai-rest-api-mock
- run: cargo check -p risc0-build
if: matrix.device == 'cpu'
- run: cargo check -p risc0-circuit-rv32im -F $FEATURE
- run: cargo check -p risc0-core
if: matrix.device == 'cpu'
- run: cargo check -p risc0-sys -F $FEATURE
- run: cargo check -p risc0-zkp -F $FEATURE
- run: cargo check -p risc0-zkvm -F $FEATURE
- run: cargo check
working-directory: external/substrate
- uses: risc0/clippy-action@main
with:
reporter: "github-pr-check"
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --features $FEATURE --all-targets
- run: sccache --show-stats
examples:
if: needs.changes.outputs.examples == 'true'
needs: changes
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.device }}"]
strategy:
fail-fast: false
matrix:
os: [Linux, macOS]
feature: [default]
device: [cpu]
include:
- os: Linux
feature: cuda
device: nvidia_rtx_a5000
env:
FEATURE: ${{ matrix.feature }}
RISC0_BUILD_LOCKED: 1
RISC0_EXECUTOR: ipc
RISC0_PROVER: ipc
RISC0_SERVER_PATH: ${{ github.workspace }}/target/release/r0vm
RUST_BACKTRACE: full
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- if: matrix.feature == 'cuda'
uses: ./.github/actions/cuda
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: ${{ matrix.os }}-${{ matrix.feature }}
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: cargo build --release -p risc0-r0vm -F $FEATURE
- name: build
run: cargo test --locked -F $FEATURE --no-run
working-directory: examples
- name: test
run: cargo test --locked -F $FEATURE
working-directory: examples
- run: cargo run --locked -F $FEATURE
env:
RISC0_PPROF_OUT: ${{ github.workspace }}/fibonacci.pb
working-directory: examples/profiling
- run: sccache --show-stats
doc:
if: needs.changes.outputs.doc == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
with:
version: nightly-34f684ddfacc5b2ed371353ba6f730c485616ffe
- uses: ./.github/actions/sccache
with:
key: macOS-default
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: cargo doc --no-deps --exclude=risc0-zkvm-methods --workspace
- run: sccache --show-stats
check-benchmarks:
if: needs.changes.outputs.check-benchmarks == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v3
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: macOS-default
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: cargo check
working-directory: benchmarks
- run: sccache --show-stats
check-template:
if: needs.changes.outputs.check-template == 'true'
needs: changes
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}"]
strategy:
fail-fast: false
matrix:
os: [Linux, macOS]
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: ${{ matrix.os }}-default
- run: cargo install --force --path risc0/cargo-risczero
- run: cargo risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: |
cargo risczero new \
--template templates/rust-starter \
--templ-subdir="" \
--path $(pwd) \
--dest ${{ runner.temp }} \
--guest-name test_method \
template-test
shell: bash
- run: cargo run --release --manifest-path ${{ runner.temp }}/template-test/Cargo.toml
- run: ${{ runner.temp }}/template-test/target/release/host
- run: sccache --show-stats
crates-validator:
if: needs.changes.outputs.crates-validator == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
env:
RISC0_BUILD_LOCKED: 1
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: macOS-default
- uses: risc0/clippy-action@main
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --manifest-path tools/crates-validator/Cargo.toml
- run: cargo test
working-directory: tools/crates-validator
- run: sccache --show-stats
web:
if: needs.changes.outputs.web == 'true'
needs: changes
runs-on: [self-hosted, prod, Linux, cpu]
env:
RISC0_BUILD_LOCKED: 1
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- uses: browser-actions/setup-firefox@v1
- run: firefox --version
- uses: ./.github/actions/rustup
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: ./.github/actions/sccache
with:
key: Linux-default
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: cargo xtask install
- run: cargo xtask gen-receipt
- run: |
npm install
npm test -- --firefox
working-directory: examples/browser-verify
- run: sccache --show-stats
reproducible-build:
if: needs.changes.outputs.test == 'true'
needs: changes
runs-on: [self-hosted, prod, Linux, cpu, docker]
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: Linux-default
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
- run: cargo test -p risc0-build -F docker
- run: cargo test -p risc0-zkvm -F docker -F prove -- "docker::"
env:
RISC0_USE_DOCKER: "1"
- run: sccache --show-stats