Skip to content

Commit

Permalink
fix(ci): improve rust yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tiamo committed Nov 5, 2024
1 parent 8a0c5e5 commit f0d6ece
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
# Rust-specific tests
name: Rust
name: Rust Checks

on:
push:
pull_request:

jobs:
cargo-fmt:
rust-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install nightly --profile minimal
- uses: Swatinem/rust-cache@v2
- run: rustup component add rustfmt
- name: Cargo fmt
run: cargo +nightly fmt --all -- --check

cargo-clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: rustup component add clippy
- name: Cargo clippy
# We run clippy twice (once without tests), so that it accurately reports dead code in the non-test configuration.
# `manual_range_contains` is disabled because a >= x && a < y reads more clearly than (x..y).contains(a) and
# there are additional caveats for floating point numbers (https://github.com/rust-lang/rust-clippy/issues/6455)
run: |
cargo clippy -- -D clippy::all -D warnings -A clippy::manual_range_contains
cargo clippy --tests --benches -- -D clippy::all -D warnings -A clippy::manual_range_contains
check-lockfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2
# fails if lockfile is out of date
# https://users.rust-lang.org/t/check-if-the-cargo-lock-is-up-to-date-without-building-anything/91048/5
- name: Cargo Lockfile Check

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run Clippy (non-test)
run: cargo clippy -- -D clippy::all -D warnings -A clippy::manual_range_contains

- name: Run Clippy (tests and benches)
run: cargo clippy --tests --benches -- -D clippy::all -D warnings -A clippy::manual_range_contains

- name: Check Cargo.lock
run: cargo update --workspace --locked

0 comments on commit f0d6ece

Please sign in to comment.