-
Notifications
You must be signed in to change notification settings - Fork 337
158 lines (151 loc) · 5.75 KB
/
risc0-ethereum.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
name: risc0-ethereum CI
on:
merge_group:
pull_request:
branches: [main, "release-*"]
workflow_dispatch:
inputs:
risc0-ethereum-branch:
description: "risc0-ethereum branch to checkout"
required: false
default: 'main'
risc0-foundry-template-branch:
description: "risc0-foundry-template branch to checkout"
required: false
default: 'main'
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: v2024-04-22.0
RISC0_PATH: ${{ github.workspace }}/risc0
RISC0_ETHEREUM_PATH: ${{ github.workspace }}/risc0-ethereum
RISC0_FOUNDRY_TEMPLATE_PATH: ${{ github.workspace }}/risc0-foundry-template
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
test: ${{ steps.filter.outputs.test }}
steps:
- uses: actions/checkout@v4
- uses: risc0/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
with:
filters: |
base: &base
- .github/actions/**
- .github/cargo_local_patch.py
- .github/workflows/risc0-ethereum.yml
- Cargo.toml
- rust-toolchain.toml
- Cargo.lock
test:
- *base
- bonsai/**
- risc0/**
# see: https://github.com/orgs/community/discussions/26822
risc0-ethereum-status-check:
if: always()
needs:
- test
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
test:
if: ${{ needs.changes.outputs.test == 'true' || github.event_name == 'workflow_dispatch'}}
needs: changes
runs-on: [self-hosted, prod, Linux, cpu, docker]
env:
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) || :"
# Checkout risc0
- uses: actions/checkout@v4
with:
path: 'risc0'
# Checkout risc0-ethereum
- name: Checkout risc0-ethereum
uses: actions/checkout@v4
with:
repository: 'risc0/risc0-ethereum'
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
path: 'risc0-ethereum'
ref: ${{ github.event.inputs.risc0-ethereum-branch || 'main' }}
# Checkout risc0-foundry-template
- name: Checkout foundry-template
uses: actions/checkout@v4
with:
repository: 'risc0/risc0-foundry-template'
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
path: 'risc0-foundry-template'
ref: ${{ github.event.inputs.risc0-foundry-template-branch || 'dev' }}
- uses: ./risc0/.github/actions/rustup
- uses: ./risc0/.github/actions/sccache
with:
key: Linux-default
# Installing dev tooling
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install python dependencies
run: python -m pip install --upgrade toml
- name: Install risczero toolchain
run: |
cargo install --force --path risc0/cargo-risczero
cargo risczero install --version $RISC0_TOOLCHAIN_VERSION
working-directory: risc0
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
with:
version: nightly-cafc2606a2187a42b236df4aa65f4e8cdfcea970
# Apply local patch
- name: Local patch on risc0-ethereum
run: python ${{ env.RISC0_PATH }}/.github/cargo_local_patch.py .
working-directory: ${{ env.RISC0_ETHEREUM_PATH }}
- name: Local patch on risc0-foundry-template
run: python ${{ env.RISC0_PATH }}/.github/cargo_local_patch.py .
working-directory: ${{ env.RISC0_FOUNDRY_TEMPLATE_PATH }}
# Run Bootstrap-groth16 to update test receipt for checking
# the latest groth16 prover against the solidity verifier on risc0-ethereum
- name: Bootstrap-groth16 test receipt
run: cargo xtask bootstrap-groth16 --test-receipt-only
env:
RISC0_ETHEREUM_PATH: ${{ env.RISC0_ETHEREUM_PATH }}
working-directory: ${{ env.RISC0_PATH }}
# Build and test risc0-ethereum
- name: build risc0-ethereum
run: cargo test --workspace --no-run
working-directory: ${{ env.RISC0_ETHEREUM_PATH }}
- name: test risc0-ethereum
run: cargo test --workspace
working-directory: ${{ env.RISC0_ETHEREUM_PATH }}
- name: forge test on risc0-ethereum
run: forge test -vvv
working-directory: ${{ env.RISC0_ETHEREUM_PATH }}/contracts
# Build and test risc0-foundry-template
- name: build risc0-foundry-template
run: cargo build
working-directory: ${{ env.RISC0_FOUNDRY_TEMPLATE_PATH }}
- name: build risc0-foundry-template contracts
run: forge build
working-directory: ${{ env.RISC0_FOUNDRY_TEMPLATE_PATH }}
- name: run foundry tests in dev mode
env:
RISC0_DEV_MODE: true
run: forge test -vvv
working-directory: ${{ env.RISC0_FOUNDRY_TEMPLATE_PATH }}
- run: sccache --show-stats