CI #4188
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
env: | |
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/** | |
- 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 examples/Cargo.toml | |
- 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 tools/crates-validator/Cargo.toml | |
- run: cargo fmt --all --check --manifest-path bonsai/examples/governance/Cargo.toml | |
- run: cargo sort --workspace --check | |
- run: cargo sort --workspace --check examples | |
- run: cargo sort --workspace --check benchmarks | |
- run: cargo sort --workspace --check bonsai | |
- run: cargo sort --workspace --check tools/crates-validator | |
- run: cargo sort --workspace --check bonsai/examples/governance | |
- 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: | |
CUDA_LIBRARY_PATH: /usr/lib/cuda | |
FEATURE: ${{ matrix.feature }} | |
RISC0_BUILD_LOCKED: 1 | |
RUST_BACKTRACE: full | |
RUSTC_WRAPPER: sccache | |
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 | |
# Recursive checkout required to build Solidity contracts and bindings. | |
submodules: recursive | |
- uses: ./.github/actions/rustup | |
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f | |
- 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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo test -F $FEATURE -F fault-proof -F profiler -F prove --workspace --exclude doc-test | |
- 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 | |
- 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-r0vm -F $FEATURE | |
- 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 -p substrate-minimal-runtime | |
- 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: | |
CUDA_LIBRARY_PATH: /usr/lib/cuda | |
FEATURE: ${{ matrix.feature }} | |
RISC0_BUILD_LOCKED: 1 | |
RISC0_EXECUTOR: ipc | |
RISC0_PROVER: ipc | |
RISC0_SERVER_PATH: ${{ github.workspace }}/target/release/r0vm | |
RUST_BACKTRACE: full | |
RUSTC_WRAPPER: sccache | |
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 }}-${{ matrix.feature }} | |
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo build --release -p risc0-r0vm -F $FEATURE | |
- run: cargo test --locked -F $FEATURE | |
working-directory: examples | |
- run: cargo run --locked -F $FEATURE && ls "${{ github.workspace }}/fibonacci.pb" | |
env: { RISC0_PPROF_OUT: "${{ github.workspace }}/fibonacci.pb" } | |
working-directory: examples/profiling | |
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 | |
- uses: ./.github/actions/sccache | |
with: | |
key: macOS-default | |
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo doc --no-deps --exclude=risc0-zkvm-methods --workspace | |
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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo check | |
working-directory: benchmarks | |
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] | |
env: | |
RISC0_SERVER_PATH: ${{ github.workspace }}/target/release/r0vm | |
RUSTC_WRAPPER: sccache | |
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 run --bin cargo-risczero -- risczero install --version $RISC0_TOOLCHAIN_VERSION | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo build --release -p risc0-r0vm | |
- run: | | |
cargo run --bin cargo-risczero 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 | |
crates-validator: | |
if: needs.changes.outputs.crates-validator == 'true' | |
needs: changes | |
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}"] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [Linux, macOS] | |
env: | |
RISC0_BUILD_LOCKED: 1 | |
RUSTC_WRAPPER: sccache | |
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 | |
- 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 | |
web: | |
if: needs.changes.outputs.web == 'true' | |
needs: changes | |
runs-on: ubuntu-latest-8-cores | |
env: | |
RISC0_BUILD_LOCKED: 1 | |
RUSTC_WRAPPER: sccache | |
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 | |
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo xtask install | |
- run: cargo xtask gen-receipt | |
- run: | | |
npm install | |
npm test -- --firefox | |
working-directory: examples/browser-verify | |
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 | |
- run: cargo run --bin cargo-risczero --no-default-features -- risczero install --version $RISC0_TOOLCHAIN_VERSION | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: cargo test -p risc0-build -F docker | |
- run: cargo test -p risc0-zkvm -F docker -F prove -- "docker::" | |
env: | |
RISC0_USE_DOCKER: "1" |