sonobe/.github/workflows/ci.yml
.github/workflows/ci.ymlRaw
1name: CI Check
2on:
3 merge_group:
4 pull_request:
5 push:
6 branches:
7 - main
8env:
9 CARGO_TERM_COLOR: always
10 # Disable incremental compilation.
11 #
12 # Incremental compilation is useful as part of an edit-build-test-edit cycle,
13 # as it lets the compiler avoid recompiling code that hasn't changed. However,
14 # on CI, we're not making small edits; we're almost always building the entire
15 # project from scratch. Thus, incremental compilation on CI actually
16 # introduces *additional* overhead to support making future builds
17 # faster...but no future builds will ever occur in any given CI environment.
18 #
19 # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
20 # for details.
21 CARGO_INCREMENTAL: 0
22 # Allow more retries for network requests in cargo (downloading crates) and
23 # rustup (installing toolchains). This should help to reduce flaky CI failures
24 # from transient network timeouts or other issues.
25 CARGO_NET_RETRY: 10
26 RUSTUP_MAX_RETRIES: 10
27 # Don't emit giant backtraces in the CI logs.
28 RUST_BACKTRACE: short
29
30# Jobs launched for a PR event cancel the ongoing one for the same workflow + PR,
31# Only retries (of the same run) for a Push event cancel the prior one.
32concurrency:
33 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
34 cancel-in-progress: true
35
36jobs:
37 test:
38 if: github.event.pull_request.draft == false
39 name: Test
40 runs-on: ubuntu-latest
41 strategy:
42 matrix:
43 feature_set: [basic]
44 include:
45 - feature_set: basic
46 features: --features default,light-test
47 steps:
48 - uses: actions/checkout@v2
49 - uses: actions-rs/toolchain@v1
50 - uses: noir-lang/noirup@v0.1.3
51 with:
52 toolchain: nightly
53 - name: Download Circom
54 run: |
55 mkdir -p $HOME/bin
56 curl -sSfL https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64 -o $HOME/bin/circom
57 chmod +x $HOME/bin/circom
58 echo "$HOME/bin" >> $GITHUB_PATH
59 - name: Download solc
60 run: |
61 curl -sSfL https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-static-linux -o /usr/local/bin/solc
62 chmod +x /usr/local/bin/solc
63 - name: Execute compile.sh to generate .r1cs and .wasm from .circom
64 run: ./frontends/src/circom/test_folder/compile.sh
65 - name: Execute compile.sh to generate .json from noir
66 run: ./frontends/src/noir/test_folder/compile.sh
67 - name: Run tests
68 uses: actions-rs/cargo@v1
69 with:
70 command: test
71 args: --release --workspace --no-default-features ${{ matrix.features }}
72 - name: Run Doc-tests
73 uses: actions-rs/cargo@v1
74 with:
75 command: test
76 args: --doc
77
78 build:
79 if: github.event.pull_request.draft == false
80 name: Build target ${{ matrix.target }}
81 runs-on: ubuntu-latest
82 strategy:
83 matrix:
84 target:
85 - wasm32-unknown-unknown
86 - wasm32-wasi
87 # Ignoring until clear usage is required
88 # - wasm32-unknown-emscripten
89
90 steps:
91 - uses: actions/checkout@v3
92 - uses: actions-rs/toolchain@v1
93 with:
94 override: false
95 default: true
96 - name: Add target
97 run: rustup target add ${{ matrix.target }}
98 - name: Wasm-compat frontends build
99 uses: actions-rs/cargo@v1
100 with:
101 command: build
102 args: -p frontends --no-default-features --target ${{ matrix.target }} --features "wasm, parallel"
103 - name: Wasm-compat folding-schemes build
104 uses: actions-rs/cargo@v1
105 with:
106 command: build
107 args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "default,light-test"
108 - name: Run wasm-compat script
109 run: |
110 chmod +x .github/scripts/wasm-target-test-build.sh
111 .github/scripts/wasm-target-test-build.sh
112 shell: bash
113
114 examples:
115 if: github.event.pull_request.draft == false
116 name: Run examples & examples tests
117 runs-on: ubuntu-latest
118 steps:
119 - uses: actions/checkout@v2
120 - uses: actions-rs/toolchain@v1
121 - uses: noir-lang/noirup@v0.1.3
122 with:
123 toolchain: nightly
124 - name: Download Circom
125 run: |
126 mkdir -p $HOME/bin
127 curl -sSfL https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64 -o $HOME/bin/circom
128 chmod +x $HOME/bin/circom
129 echo "$HOME/bin" >> $GITHUB_PATH
130 - name: Download solc
131 run: |
132 curl -sSfL https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-static-linux -o /usr/local/bin/solc
133 chmod +x /usr/local/bin/solc
134 - name: Execute compile.sh to generate .r1cs and .wasm from .circom
135 run: ./frontends/src/circom/test_folder/compile.sh
136 - name: Execute compile.sh to generate .json from noir
137 run: ./frontends/src/noir/test_folder/compile.sh
138 - name: Run examples tests
139 run: cargo test --examples
140 - name: Run examples
141 run: cargo run --release --example 2>&1 | grep -E '^ ' | xargs -n1 cargo run --release --example
142
143 fmt:
144 if: github.event.pull_request.draft == false
145 name: Rustfmt
146 timeout-minutes: 30
147 runs-on: ubuntu-latest
148 steps:
149 - uses: actions/checkout@v2
150 - uses: actions-rs/toolchain@v1
151 - uses: Swatinem/rust-cache@v2
152 - run: rustup component add rustfmt
153 - uses: actions-rs/cargo@v1
154 with:
155 command: fmt
156 args: --all --check
157
158 clippy:
159 if: github.event.pull_request.draft == false
160 name: Clippy lint checks
161 runs-on: ubuntu-latest
162 strategy:
163 matrix:
164 feature_set: [basic, wasm]
165 include:
166 - feature_set: basic
167 features: --features default,light-test
168 # We only want to test `frontends` package with `wasm` feature.
169 - feature_set: wasm
170 features: -p frontends --features wasm,parallel --target wasm32-unknown-unknown
171 steps:
172 - uses: actions/checkout@v2
173 - uses: actions-rs/toolchain@v1
174 with:
175 components: clippy
176 - uses: Swatinem/rust-cache@v2
177 - name: Add target
178 run: rustup target add wasm32-unknown-unknown
179 - name: Run clippy
180 uses: actions-rs/cargo@v1
181 with:
182 command: clippy
183 args: --no-default-features ${{ matrix.features }} -- -D warnings
184
185 typos:
186 if: github.event.pull_request.draft == false
187 name: Spell Check with Typos
188 runs-on: ubuntu-latest
189 steps:
190 - uses: actions/checkout@v4
191 - name: Use typos with config file
192 uses: crate-ci/typos@master
193 with:
194 config: .github/workflows/typos.toml