forked from risc0/risc0
-
Notifications
You must be signed in to change notification settings - Fork 0
622 lines (600 loc) · 21.1 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
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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
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_RUST_TOOLCHAIN_VERSION: r0.1.81.0
RISC0_CPP_TOOLCHAIN_VERSION: 2024.01.05
defaults:
run:
# This ensures `-eo pipefail`, which is important for catching errors
shell: bash
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
browser: ${{ steps.filter.outputs.browser }}
check-external: ${{ steps.filter.outputs.check-external }}
check-semver: ${{ steps.filter.outputs.check-semver }}
check-template: ${{ steps.filter.outputs.check-template }}
crates-validation: ${{ steps.filter.outputs.crates-validation }}
crates-validator: ${{ steps.filter.outputs.crates-validator }}
doc: ${{ steps.filter.outputs.doc }}
examples: ${{ steps.filter.outputs.examples }}
risc0: ${{ steps.filter.outputs.risc0 }}
test: ${{ steps.filter.outputs.test }}
test-crates: ${{ steps.filter.outputs.test-crates }}
web: ${{ steps.filter.outputs.web }}
steps:
- uses: actions/checkout@v4
- uses: risc0/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
with:
filters: |
base: &base
- .github/actions/**
- .github/workflows/main.yml
- Cargo.toml
- rust-toolchain.toml
- Cargo.lock
- rzup/**
browser:
- *base
- examples/browser-verify/**
- risc0/**
- xtask/**
check-external:
- *base
- external/**
- risc0/**
check-semver:
- *base
- risc0/**
check-template:
- *base
- risc0/**
- templates/**
crates-validation:
- *base
- risc0/**
- tools/crates-validator/**
crates-validator:
- *base
- tools/crates-validator/**
doc:
- *base
- bonsai/sdk/**
- risc0/**
examples:
- *base
- examples/**
- risc0/**
risc0:
- *base
- risc0/**
test:
- *base
- bonsai/sdk/**
- compact_proof/**
- external/**
- risc0/**
test-crates:
- *base
- risc0/**
web:
- web/**
# see: https://github.com/orgs/community/discussions/26822
main-status-check:
if: always()
needs:
- browser
- check
- check-external
- check-template
- clippy
- crates-validator
- crates-validation
- doc
- docs-rs
- examples
- docker
- test
# - test-crates
- 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@9f6037ed331dcf7da101461a20656273fa72abf0
with:
crate: cargo-sort
version: "1.0"
- name: Install cargo-rdme
uses: risc0/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0
with:
crate: cargo-rdme
version: "1.4.3"
- uses: actions/setup-node@v4
with:
node-version: 20
- run: cargo fmt --all --check
- run: cargo fmt --all --check --manifest-path benchmarks/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 examples
- run: cargo sort --workspace --check tools/crates-validator
- name: cargo rdme in bonsai/sdk
run: cargo rdme -c
working-directory: bonsai/sdk
- name: cargo rdme in risc0/zkvm
run: cargo rdme -c
working-directory: risc0/zkvm
- name: cargo rdme in risc0/groth16
run: cargo rdme -c
working-directory: risc0/groth16
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: python license-check.py
- name: check for "D0 NOT MERGE" comments
run: |
[ "$(grep -re 'DO[_ ]\?NOT[_ ]\?MERGE' $(git ls-tree --full-tree --name-only -r HEAD) | tee /dev/fd/2 | wc -l)" -eq "0" ]
- name: Compare circom hashes to golden values
run: bash ./.github/scripts/circom_stable.sh
clippy:
if: needs.changes.outputs.risc0 == 'true'
needs: changes
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.arch }}"]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
arch: X64
feature: default
- os: Linux
arch: X64
feature: cuda
- os: macOS
arch: ARM64
feature: default
env:
FEATURE: ${{ matrix.feature }}
RISC0_SKIP_BUILD: 1
RISC0_SKIP_BUILD_KERNELS: 1
steps:
- 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 }}
- name: "root: cargo clippy"
run: cargo clippy -F $FEATURE --all-targets
- name: "benchmarks: cargo clippy"
run: cargo clippy -F $FEATURE --all-targets
working-directory: benchmarks
- name: "examples: cargo clippy"
run: cargo clippy -F $FEATURE --all-targets
working-directory: examples
test:
if: needs.changes.outputs.test == 'true'
needs: changes
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.arch }}", "${{ matrix.device }}"]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
arch: X64
feature: default
device: cpu
- os: Linux
arch: X64
feature: cuda
device: nvidia_rtx_a5000
- os: macOS
arch: ARM64
feature: default
device: apple_m2_pro
env:
FEATURE: ${{ matrix.feature }}
RISC0_BUILD_LOCKED: 1
RUST_BACKTRACE: full
steps:
- 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 rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_TOOLCHAIN_VERSION
- name: build workspace
run: cargo test -F $FEATURE -F prove -F redis --workspace --timings --no-run --exclude doc-test
- name: test workspace
run: cargo test -F $FEATURE -F prove -F redis --workspace --timings --exclude doc-test
- uses: actions/upload-artifact@v4
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: build risc0-zkvm tests without the prove feature
run: cargo test -p risc0-zkvm -F $FEATURE --no-run
- name: build risc0-zkvm tests with the metal feature
if: matrix.os == 'macOS'
run: cargo test -p risc0-zkvm -F metal --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
- name: run fibonacci benchmark
run: cargo run -F $FEATURE -- fibonacci
working-directory: benchmarks
- name: run datasheet generator
run: cargo run -F $FEATURE -F prove --example datasheet -- --json tmp/datasheet.json lift
- name: check benches
run: cargo check -F $FEATURE --benches --workspace --exclude doc-test
- run: cargo check -p risc0-build
- run: cargo check -p risc0-circuit-rv32im -F $FEATURE
- run: cargo check -p risc0-core
- 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: sccache --show-stats
examples:
if: needs.changes.outputs.examples == 'true'
needs: changes
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.arch }}", "${{ matrix.device }}"]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
arch: X64
feature: default
device: cpu
- os: Linux
arch: X64
feature: cuda
device: nvidia_rtx_a5000
- os: macOS
arch: ARM64
feature: default
device: apple_m2_pro
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:
- 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 rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_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 in dev mode
run: RISC0_DEV_MODE=1 cargo test --locked -F $FEATURE --workspace --exclude prover-example
working-directory: examples
- name: test prover example
run: cargo test --locked -F $FEATURE -p prover-example
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
# test-crates:
# if: needs.changes.outputs.test-crates == 'true'
# needs: changes
# runs-on: [self-hosted, prod, Linux, cpu]
# strategy:
# fail-fast: false
# steps:
# - uses: actions/checkout@v4
# with:
# path: 'risc0'
# - uses: actions/checkout@v4
# with:
# repository: risc0/RustCrypto-crypto-bigint
# path: 'RustCrypto-crypto-bigint'
# - uses: ./risc0/.github/actions/rustup
# - uses: ./risc0/.github/actions/sccache
# with:
# key: Linux-default
# - name: Install risczero toolchain
# run: |
# cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION
# cargo install --force --path risc0/cargo-risczero -F experimental
# working-directory: risc0
# - name: run cargo risczero test
# working-directory: ${{ github.workspace }}/RustCrypto-crypto-bigint
# run: cargo risczero test
# - run: sccache --show-stats
doc:
if: needs.changes.outputs.doc == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: macOS-default
- run: cargo run --bin rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_TOOLCHAIN_VERSION
- run: cargo doc --no-deps --exclude=risc0-zkvm-methods --workspace
- run: sccache --show-stats
# Run as a separate job because we need to install a different set of tools.
# In particular, it uses nightly Rust and _does not_ install cargo risczero.
docs-rs:
if: needs.changes.outputs.doc == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
with:
# Building with docs.rs config requires the nightly toolchain.
toolchain: nightly-2024-09-04
- uses: ./.github/actions/sccache
with:
key: macOS-nightly
- run: cargo +nightly-2024-09-04 doc -p risc0-zkvm -Fclient,prove,getrandom,std --no-deps
- run: cargo +nightly-2024-09-04 doc -p risc0-zkp -Fprove,std --no-deps
- run: cargo +nightly-2024-09-04 doc -p cargo-risczero -Fdocker,r0vm --no-deps
- run: cargo +nightly-2024-09-04 doc -p risc0-binfmt -p risc0-core -p risc0-groth16 -p risc0-zkvm-platform --all-features --no-deps
- run: sccache --show-stats
check-external:
if: needs.changes.outputs.check-external == 'true'
needs: changes
runs-on: [self-hosted, prod, macOS, cpu]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: macOS-default
- run: cargo check
working-directory: external/substrate
- run: sccache --show-stats
check-semver:
if: needs.changes.outputs.check-semver == 'true'
needs: changes
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}", "${{ matrix.arch }}"]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
arch: X64
- os: macOS
arch: ARM64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: ${{ matrix.os }}-default
- name: Install cargo-semver-checks
uses: risc0/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0
with:
crate: cargo-semver-checks
version: "0.31.0"
- name: run cargo semverchecks on ${{ github.event.pull_request.base.sha }}
run: |
cargo semver-checks --default-features --baseline-rev ${{ github.event.pull_request.base.sha }} \
--exclude cargo-risczero \
--exclude doc-test \
--exclude fibonacci-methods \
--exclude risc0-bigint2 \
--exclude risc0-bigint2-methods \
--exclude risc0-circuit-bigint \
--exclude risc0-circuit-bigint-test-methods \
--exclude risc0-zkvm-receipts \
--exclude risc0-zkvm-methods
- run: sccache --show-stats
check-template:
if: needs.changes.outputs.check-template == 'true'
needs: changes
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}", "${{ matrix.arch }}"]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
arch: X64
- os: macOS
arch: ARM64
steps:
- 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 run --bin rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_TOOLCHAIN_VERSION
- run: |
cargo risczero new \
--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: |
cargo risczero new \
--path $(pwd) \
--dest ${{ runner.temp }} \
--guest-name test_method \
--no-std \
template-test-no-std
shell: bash
- run: cargo run --release --manifest-path ${{ runner.temp }}/template-test-no-std/Cargo.toml
- 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:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: macOS-default
- run: cargo test
working-directory: tools/crates-validator
- run: sccache --show-stats
crates-validation:
if: needs.changes.outputs.crates-validation == 'true'
needs: changes
runs-on: [self-hosted, prod, Linux, X64, cpu]
env:
RUST_BACKTRACE: full
RUST_LOG: info
TOP_N_CRATES: 10
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
- run: cargo install --force --path risc0/cargo-risczero
- run: cargo run --bin rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_TOOLCHAIN_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: cargo build --release
working-directory: tools/crates-validator/
- name: Create working directory
run: mkdir -p ${{ runner.temp }}/crate-validation/
- name: Generate the profile
run: |
target/release/gen-profiles \
-P ${{ github.workspace }}/tools/crates-validator/profiles/config.yml \
-o ${{ runner.temp }}/crate-validation/profiles.yaml \
-c $TOP_N_CRATES
working-directory: tools/crates-validator/
- name: Validate profiles
run: |
target/release/main \
-p ${{ github.workspace }} \
-P ${{ runner.temp }}/crate-validation/profiles.yaml \
-o ${{ runner.temp }}/crate-validation/profile-results.json &> ${{ runner.temp }}/crate-validation/crate-results.log
shell: bash
working-directory: tools/crates-validator/
- name: Delete input profile
run: rm ${{ runner.temp }}/crate-validation/profiles.yaml
- run: tail -n 1 ${{ runner.temp }}/crate-validation/crate-results.log
if: always()
- run: sccache --show-stats
browser:
if: needs.changes.outputs.browser == 'true'
needs: changes
runs-on: [self-hosted, prod, Linux, X64, cpu]
env:
RISC0_BUILD_LOCKED: 1
steps:
- uses: actions/checkout@v4
- uses: browser-actions/setup-firefox@v1
- run: firefox --version
- uses: ./.github/actions/rustup
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: ./.github/actions/sccache
with:
key: Linux-default
- run: cargo run --bin rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_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
docker:
if: needs.changes.outputs.test == 'true'
needs: changes
runs-on: [self-hosted, prod, Linux, X64, cpu, docker]
steps:
- uses: actions/checkout@v4
with:
lfs: true
- run: git lfs pull
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
with:
key: Linux-default
- run: cargo run --bin rzup -- --verbose install rust $RISC0_RUST_TOOLCHAIN_VERSION
- run: cargo run --bin rzup -- --verbose install cpp $RISC0_CPP_TOOLCHAIN_VERSION
- run: cargo test -p risc0-build -F docker
- run: cargo test -p risc0-groth16 -F prove --release
- run: cargo test -p risc0-zkvm -F docker -F prove -- docker
env:
RISC0_USE_DOCKER: "1"
- run: sccache --show-stats
web:
if: needs.changes.outputs.web == 'true'
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 🍞 Setup Bun
uses: risc0/[email protected]
with:
bun-version: 1.1.34
- run: bun install
working-directory: web
- run: bun run ci
working-directory: web
- run: bun run typecheck
working-directory: web
- run: bun run test
working-directory: web