diff --git a/.github/actions/rust-setup/action.yml b/.github/actions/rust-setup/action.yml new file mode 100644 index 00000000..484624eb --- /dev/null +++ b/.github/actions/rust-setup/action.yml @@ -0,0 +1,12 @@ +name: Rust toolchain +description: Set up Rust toolchain +runs: + using: composite + steps: + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rustfmt, clippy + target: riscv32i-unknown-none-elf + - uses: Swatinem/rust-cache@v2 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe3a910b..6d7e2d2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,54 +8,33 @@ on: - main jobs: - check-fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - run: cargo fmt --all --check - - run: cd nova-benches && cargo fmt --check - check-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - target: riscv32i-unknown-none-elf - - run: cargo check --all-features - - run: cargo check --all-features --examples + - name: Setup Rust cache and install tooling + uses: ./.github/actions/rust-setup + - run: cargo fmt --all --check - run: cargo check -p example --target=riscv32i-unknown-none-elf + - run: cargo check --bins --examples --tests --benches --all-features - run: cd nova-benches && cargo check --benches - cargo-clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - run: cargo clippy --all-targets --all-features - - test: + cargo-test: needs: check-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - run: cargo test -r --all-features + - name: Setup Rust cache and install tooling + uses: ./.github/actions/rust-setup + - run: cargo test -r --bins --examples --all-features test-smoke: needs: check-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup target add riscv32i-unknown-none-elf + - name: Setup Rust cache and install tooling + uses: ./.github/actions/rust-setup - run: assets/scripts/smoke.sh examples/src/bin/fib3_profiling.rs test-sdk: @@ -63,7 +42,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup target add riscv32i-unknown-none-elf + - name: Setup Rust cache and install tooling + uses: ./.github/actions/rust-setup - run: assets/scripts/test_sdk.sh examples/src/bin/fib3_profiling.rs detect-unused-crate: @@ -72,6 +52,7 @@ jobs: - uses: bnjbvr/cargo-machete@main bench-riscv: + needs: check-build runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'benchmark') steps: @@ -90,6 +71,7 @@ jobs: cargo bench --bench riscv_machine bench-nova-public-params: + needs: check-build runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'benchmark') steps: diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml new file mode 100644 index 00000000..df72350b --- /dev/null +++ b/.github/workflows/rust-clippy.yml @@ -0,0 +1,48 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# rust-clippy is a tool that runs a bunch of lints to catch common +# mistakes in your Rust code and help improve your Rust code. +# More details at https://github.com/rust-lang/rust-clippy +# and https://rust-lang.github.io/rust-clippy/ + +name: rust-clippy analyze + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + +jobs: + rust-clippy-analyze: + name: Run rust-clippy analyzing + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust cache and install tooling + uses: ./.github/actions/rust-setup + + - name: Install required cargo + run: cargo install clippy-sarif sarif-fmt + + - name: Run rust-clippy + run: + cargo clippy + --all-features + --all-targets + --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt + continue-on-error: true + + - name: Upload analysis results to GitHub + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: rust-clippy-results.sarif + wait-for-processing: true \ No newline at end of file