Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github Action cache to improve CI time #269

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/actions/rust-setup/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
46 changes: 14 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,42 @@ 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
duc-nx marked this conversation as resolved.
Show resolved Hide resolved

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:
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/test_sdk.sh examples/src/bin/fib3_profiling.rs

detect-unused-crate:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
@@ -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.
Comment on lines +1 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this sentence here? Depending on the reason, you might want the same sentence in .github/workflows/ci.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not our script. We should leave it as is in so in the future we get a fresh new one instead of fixing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a caveat emptor that you're using third-party code on GH Actions and if something breaks it's not GHs fault. No harm in keeping it or removing it either way, but might make it easier to track down the provenance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not our script.

Let's add a link to the source. Also, what's the license of the source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, it's from the Github action item, and I just click on it and make minor modification.
I'm pretty sure it's open license, because there are plenty projects use this, although I don't have time to find the exact original license of this source.

# 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
Loading