diff --git a/.github/actions/rust-cache/action.yml b/.github/actions/rust-cache/action.yml new file mode 100644 index 00000000..484624eb --- /dev/null +++ b/.github/actions/rust-cache/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..6081cf5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,54 +8,32 @@ 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: Install tooling and use Rust cache + uses: ./.github/actions/rust-cache + - run: cargo fmt --all --check - run: cargo check -p example --target=riscv32i-unknown-none-elf - - 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 + - run: cargo check --bins --examples --tests --benches --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: Install tooling and use Rust cache + uses: ./.github/actions/rust-cache + - run: cargo test --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: Install tooling and use Rust cache + uses: ./.github/actions/rust-cache - run: assets/scripts/smoke.sh examples/src/bin/fib3_profiling.rs test-sdk: @@ -63,7 +41,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup target add riscv32i-unknown-none-elf + - name: Install tooling and use Rust cache + uses: ./.github/actions/rust-cache - run: assets/scripts/test_sdk.sh examples/src/bin/fib3_profiling.rs detect-unused-crate: diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml new file mode 100644 index 00000000..07e9047f --- /dev/null +++ b/.github/workflows/rust-clippy.yml @@ -0,0 +1,51 @@ +# 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" ] + schedule: + - cron: '33 20 * * 4' + +jobs: + rust-clippy-analyze: + name: Run rust-clippy analyzing + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install tooling and use Rust cache + uses: ./.github/actions/rust-cache + + - 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