diff --git a/.github/actions/rust-cache/toolchain.yml b/.github/actions/rust-cache/toolchain.yml new file mode 100644 index 00000000..484624eb --- /dev/null +++ b/.github/actions/rust-cache/toolchain.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 c36f5234..6a683f2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,71 +6,36 @@ on: branches: - main -# Define the cache configuration as an anchor -cache-config: &cache-config - uses: actions/cache@v4.0.2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - 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 - - *cache-config # Use the cache configuration - - 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 - - run: cargo check -p example --target=riscv32i-unknown-none-elf - - run: cd nova-benches && cargo check --benches + - uses: ./.github/actions/toolchain + - run: cargo fmt --all --check + - run: cargo check --bins --examples --tests --benches --all-targets --all-features cargo-clippy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - *cache-config - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable + - uses: ./.github/actions/toolchain - run: cargo clippy --all-targets --all-features - test: + cargo-test: needs: check-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - *cache-config - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - run: cargo test -r --all-features + - uses: ./.github/actions/toolchain + - run: cargo test --bins --examples --tests --benches --all-targets --all-features test-smoke: needs: check-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - *cache-config - - run: rustup target add riscv32i-unknown-none-elf + - uses: ./.github/actions/toolchain - run: assets/scripts/smoke.sh examples/src/bin/fib3_profiling.rs - run: assets/scripts/smoke.sh examples/src/bin/hello.rs @@ -79,8 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - *cache-config - - run: rustup target add riscv32i-unknown-none-elf + - uses: ./.github/actions/toolchain - run: assets/scripts/test_sdk.sh examples/src/bin/hello.rs detect-unused-crate: