Skip to content

Commit

Permalink
Add Github Action cache to improve CI time
Browse files Browse the repository at this point in the history
move to seperate github action

compact CI

rename file

fix name

add clippy as well

just check example

shorten the test time
  • Loading branch information
duc-nx committed Aug 21, 2024
1 parent 8bfae20 commit c446c46
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 33 deletions.
12 changes: 12 additions & 0 deletions .github/actions/rust-cache/action.yml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 12 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,41 @@ 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:
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/test_sdk.sh examples/src/bin/fib3_profiling.rs

detect-unused-crate:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c446c46

Please sign in to comment.