Skip to content

Commit

Permalink
ci: use reusable workflows (#6)
Browse files Browse the repository at this point in the history
* ci: use reusable workflows

* ci: use reusable workflow for check-lurk-compiles

* fix: clippy

* fix: inline lints minus wasm build
  • Loading branch information
huitseeker authored Jan 8, 2024
1 parent 311ec73 commit 880cc07
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 38 deletions.
18 changes: 16 additions & 2 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,38 @@
xclippy = [
"clippy", "--all-targets", "--",
"-Wclippy::all",
"-Wclippy::match_same_arms",
"-Wclippy::cast_lossless",
"-Wclippy::checked_conversions",
"-Wclippy::dbg_macro",
"-Wclippy::disallowed_methods",
"-Wclippy::derive_partial_eq_without_eq",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::from_iter_instead_of_collect",
"-Wclippy::inefficient_to_string",
"-Wclippy::large_stack_arrays",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::macro_use_imports",
"-Wclippy::manual_assert",
"-Wclippy::manual_ok_or",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::match_same_arms",
"-Wclippy::match_wild_err_arm",
"-Wclippy::needless_borrow",
"-Wclippy::needless_continue",
"-Wclippy::needless_for_each",
"-Wclippy::needless_pass_by_value",
"-Wclippy::option_option",
"-Wclippy::same_functions_in_if_condition",
"-Wclippy::single_match_else",
"-Wclippy::trait_duplication_in_bounds",
"-Wclippy::unnecessary_mut_passed",
"-Wclippy::unnecessary_wraps",
"-Wclippy::use_self",
"-Wnonstandard_style",
"-Wrust_2018_idioms",
"-Wtrivial_numeric_casts",
"-Wunused_lifetimes",
"-Wunused_qualifications",
]
]
12 changes: 12 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Show skipped tests in the CI output.
status-level = "skip"
# Do not cancel the test run on the first failure.
fail-fast = false
# Mark tests as slow after 5mins, kill them after 20mins
slow-timeout = { period = "300s", terminate-after = 4 }
# Retry failed tests once, marked flaky if test then passes
retries = 1
117 changes: 84 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,99 @@
name: Tests
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
name: Rust

on:
merge_group:
push:
branches: [dev, main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [dev, main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
env:
RUSTFLAGS: -D warnings
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache cargo build
uses: Swatinem/rust-cache@v1
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
# make sure benches don't bit-rot
- name: build benches & examples
run: cargo build --benches --examples --release
- name: cargo test
run: |
cargo nextest run --release --profile ci
- name: Doctests
run: |
cargo test --doc
- name: Setup Rust
uses: actions-rs/toolchain@v1
# Rustfmt, clippy, and doctests
lints:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt, clippy
target: wasm32-unknown-unknown

- name: Run cargo fmt
- uses: Swatinem/rust-cache@v2
- name: Check Rustfmt Code Style
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check clippy warnings
run: |
if $(cargo --list|grep -q xclippy); then
cargo xclippy -Dwarnings
else
cargo clippy -Dwarnings
fi
- name: Doctests
run: cargo test --doc --workspace

- name: Run cargo clippy
uses: actions-rs/cargo@v1
# Check MSRV in `Cargo.toml` is valid
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
command: clippy
args: --all-targets -- -D warnings

- name: Run tests
uses: actions-rs/cargo@v1
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- name: Install rustup
uses: actions-rs/toolchain@v1
with:
command: test

- name: Run grumpkin_msm example
run: cargo run --release --example grumpkin_msm
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- name: Install cargo-msrv
run: cargo install cargo-msrv
- name: Check Rust MSRV
run: cargo msrv verify

- name: Run pasta_msm example
run: cargo run --release --example pasta_msm
# Check documentation links aren't broken
link-checker:
uses: lurk-lab/ci-workflows/.github/workflows/links-check.yml@main
with:
fail-fast: true

- name: Check benches build
run: cargo check --benches
# Lint dependencies for licensing and auditing issues as per https://github.com/lurk-lab/bellpepper/blob/main/deny.toml
licenses-audits:
uses: lurk-lab/ci-workflows/.github/workflows/licenses-audits.yml@main
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include = [
"/build.rs",
"/README.md",
]
rust-version = "1.70"

[features]
# By default, compile with ADX extension if the host supports it.
Expand Down Expand Up @@ -44,6 +45,10 @@ which = "^4.0"
[dev-dependencies]
criterion = { version = "0.3", features = [ "html_reports" ] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# see https://github.com/rust-random/rand/pull/948
getrandom = { version = "0.2.0", default-features = false, features = ["js"] }

[[bench]]
name = "grumpkin_msm"
harness = false
Expand Down
7 changes: 4 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ fn common_build_configurations(cc: &mut cc::Build) {
}

fn determine_cc_def(target_arch: &str, default_def: &str) -> Option<String> {
if cfg!(feature = "portable") && cfg!(feature = "force-adx") {
panic!("Cannot compile with both `portable` and `force-adx` features");
}
assert!(
!(cfg!(feature = "portable") && cfg!(feature = "force-adx")),
"Cannot compile with both `portable` and `force-adx` features"
);

if cfg!(feature = "portable") {
return Some(default_def.to_string());
Expand Down
Loading

0 comments on commit 880cc07

Please sign in to comment.