arnaucube
arnaucube/sonobePublic Self-hosted repository
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: ./folding-schemes/src/frontend/circom/test_folder/compile.sh
 65      - name: Execute compile.sh to generate .json from noir
 66        run: ./folding-schemes/src/frontend/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 build
 99        uses: actions-rs/cargo@v1
100        with:
101          command: build
102          args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "wasm, parallel"
103      - name: Run wasm-compat script
104        run: |
105          chmod +x .github/scripts/wasm-target-test-build.sh
106          .github/scripts/wasm-target-test-build.sh          
107        shell: bash
108
109  examples:
110    if: github.event.pull_request.draft == false
111    name: Run examples & examples tests
112    runs-on: ubuntu-latest
113    steps:
114      - uses: actions/checkout@v2
115      - uses: actions-rs/toolchain@v1
116      - uses: noir-lang/noirup@v0.1.3
117        with:
118          toolchain: nightly
119      - name: Download Circom
120        run: |
121          mkdir -p $HOME/bin
122          curl -sSfL https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64 -o $HOME/bin/circom
123          chmod +x $HOME/bin/circom
124          echo "$HOME/bin" >> $GITHUB_PATH          
125      - name: Download solc
126        run: |
127          curl -sSfL https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-static-linux -o /usr/local/bin/solc
128          chmod +x /usr/local/bin/solc          
129      - name: Execute compile.sh to generate .r1cs and .wasm from .circom
130        run: ./folding-schemes/src/frontend/circom/test_folder/compile.sh
131      - name: Execute compile.sh to generate .json from noir
132        run: ./folding-schemes/src/frontend/noir/test_folder/compile.sh
133      - name: Run examples tests
134        run: cargo test --examples
135      - name: Run examples
136        run: cargo run --release --example 2>&1 | grep -E '^ ' | xargs -n1 cargo run --release --example
137
138  fmt:
139    if: github.event.pull_request.draft == false
140    name: Rustfmt
141    timeout-minutes: 30
142    runs-on: ubuntu-latest
143    steps:
144      - uses: actions/checkout@v2
145      - uses: actions-rs/toolchain@v1
146      - uses: Swatinem/rust-cache@v2
147      - run: rustup component add rustfmt
148      - uses: actions-rs/cargo@v1
149        with:
150          command: fmt
151          args: --all --check
152
153  clippy:
154    if: github.event.pull_request.draft == false
155    name: Clippy lint checks
156    runs-on: ubuntu-latest
157    strategy:
158      matrix:
159        feature_set: [basic, wasm]
160        include:
161          - feature_set: basic
162            features: --features default,light-test
163            # We only want to test `folding-schemes` package with `wasm` feature.
164          - feature_set: wasm
165            features: -p folding-schemes --features wasm,parallel --target wasm32-unknown-unknown
166    steps:
167      - uses: actions/checkout@v2
168      - uses: actions-rs/toolchain@v1
169        with:
170          components: clippy
171      - uses: Swatinem/rust-cache@v2
172      - name: Add target
173        run: rustup target add wasm32-unknown-unknown
174      - name: Run clippy
175        uses: actions-rs/cargo@v1
176        with:
177          command: clippy
178          args: --no-default-features ${{ matrix.features }} -- -D warnings
179
180  typos:
181    if: github.event.pull_request.draft == false
182    name: Spell Check with Typos
183    runs-on: ubuntu-latest
184    steps:
185      - uses: actions/checkout@v4
186      - name: Use typos with config file
187        uses: crate-ci/typos@master
188        with:
189          config: .github/workflows/typos.toml