From 66b88bc5f0b93e9a259c1223e5a6320103e6960f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 5 Sep 2026 20:00:20 +0000 Subject: [PATCH] Add lint CI gate; fix the two clippy findings it surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .github/workflows/ci.yml already installs rustfmt/clippy components but never runs either — this workspace has had no lint gate at all. Add .github/workflows/lint.yml with a format job (cargo fmt --all --check) and a clippy job (cargo clippy --all-targets -- -D warnings), using actions-rust-lang/setup-rust-toolchain so the pinned version lives in exactly one place (rust-toolchain.toml). Resolve the two clippy::assertions_on_constants findings this surfaces in ogar-dismech: both assertions check DISMECH_CONCEPT_ID against compile-time constant bounds, so the invariant belongs at compile time. Convert each to `const _: () = assert!(...)`, keeping the existing messages verbatim. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V --- .github/workflows/ci.yml | 2 ++ .github/workflows/lint.yml | 46 ++++++++++++++++++++++++++++++++++ crates/ogar-dismech/src/lib.rs | 4 +-- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e90182..7732183 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,8 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: 1.98.1 + # rustfmt/clippy are actually exercised in the sibling `lint.yml` + # workflow, not here — this job only needs the compiler. components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - name: cargo check --workspace --all-targets diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..61e5673 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,46 @@ +name: lint + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + format: + name: cargo fmt --check + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + # No `toolchain:` input — the action reads `rust-toolchain.toml`, so the + # pinned version lives in exactly ONE place. + components: rustfmt, clippy + - name: cargo fmt --all --check + run: cargo fmt --all --check + + clippy: + name: cargo clippy -D warnings + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + # No `toolchain:` input — the action reads `rust-toolchain.toml`, so the + # pinned version lives in exactly ONE place. + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + - name: cargo clippy --all-targets -- -D warnings + run: cargo clippy --all-targets -- -D warnings diff --git a/crates/ogar-dismech/src/lib.rs b/crates/ogar-dismech/src/lib.rs index 1266760..25adf82 100644 --- a/crates/ogar-dismech/src/lib.rs +++ b/crates/ogar-dismech/src/lib.rs @@ -832,12 +832,12 @@ mod concept_id_collision_guard { #[test] fn stays_in_the_0x03_ontology_domain_clear_of_documented_bands() { assert_eq!(DISMECH_CONCEPT_ID >> 8, 0x03); - assert!( + const _: () = assert!( DISMECH_CONCEPT_ID > 0x0321, "must clear the documented private-consumer odd-stride run \ (live through 0x031D, retired through 0x0321)" ); - assert!( + const _: () = assert!( DISMECH_CONCEPT_ID < 0x0340, "must clear META_STUDY_SPINE (0x0340..=0x0347)" );