Skip to content

ci(rust): add cargo build/test/clippy/fmt/doc workflow#12

Merged
montfort merged 3 commits into
mainfrom
chore/add-rust-ci
May 19, 2026
Merged

ci(rust): add cargo build/test/clippy/fmt/doc workflow#12
montfort merged 3 commits into
mainfrom
chore/add-rust-ci

Conversation

@montfort

Copy link
Copy Markdown
Contributor

Summary

Adds .github/workflows/rust-ci.yml to close the gap surfaced after PR #11 merged with only the CLA check running — no Rust verification on GitHub at all. Locally I ran cargo test, cargo clippy, etc., but none of that was recorded in the PR status. For a library published to crates.io this was a weak link.

Two commits, intentionally split:

  1. style: apply cargo fmt --all — pre-existing rustfmt drift across 38 files (+440/-209). No semantic changes. Done in its own commit so the upcoming fmt gate can land green from day one, and so git blame on reformatted lines points to a style commit instead of a CI-config commit.
  2. ci(rust): add cargo build/test/clippy/fmt/doc workflow — the new workflow itself (+124 lines).

Workflow design

Triggers: push to main, pull_request to main, manual workflow_dispatch. Path-filtered to **/*.rs, Cargo.toml, Cargo.lock, README.md (embedded in src/lib.rs via #![doc = include_str!]), and the workflow file itself. Changes under .straymark/, CLAUDE.md, STRAYMARK.md, etc. do not trigger Rust CI.

Concurrency: cancels in-progress runs on the same ref to save runner minutes during PR iteration.

Jobs:

Job OS Purpose
test (matrix) ubuntu-latest, macos-latest, windows-latest cargo build --all-features + cargo test --all-features. fail-fast: false so a Windows-only regression doesn't mask macOS failures.
build-minimal ubuntu cargo build --no-default-features to catch code that implicitly depends on a language feature.
clippy ubuntu cargo clippy --all-features --all-targets -- -D warnings
fmt ubuntu cargo fmt --all -- --check (blocking)
doc ubuntu cargo doc --all-features --no-deps with RUSTDOCFLAGS=-D warnings. Important: docs.rs will re-run this against the published crate; if it fails here it'll fail there.

All jobs cache via Swatinem/rust-cache@v2 with separate keys per job.

On using ubuntu-latest for Linux

For pure Rust code (or Rust + C deps compiled from source like tree-sitter), Ubuntu CI is a reliable proxy for any glibc-based Linux distro (Fedora, Debian, Arch, openSUSE, etc.). The ABI is shared via glibc; build-from-source insulates from glibc version differences. The one real divergence — musl libc (Alpine, distroless Docker) — would warrant a separate Alpine job in the future but is out of scope for v1.

Test plan

  • cargo build --no-default-features → ok (with 2 pre-existing unused_variable warnings in src/languages/mod.rs:170 when all language gates are off; non-fatal, candidate for a follow-up PR) (local)
  • cargo build --all-features → ok (local)
  • cargo test --all-features → 177 tests pass (local)
  • cargo clippy --all-features --all-targets -- -D warnings → clean (local)
  • cargo fmt --all -- --check → clean after the preceding commit (local)
  • RUSTDOCFLAGS=-D warnings cargo doc --all-features --no-deps → ok (local)
  • CI green on ubuntu-latest
  • CI green on macos-latest
  • CI green on windows-latest (first cross-platform run for this repo — surface any platform-specific issues)

Follow-ups (not in this PR)

  1. Address the unused-variable warning in src/languages/mod.rs:170 when no language features are enabled, then tighten build-minimal with RUSTFLAGS=-D warnings.
  2. Consider declaring a rust-version in Cargo.toml (MSRV) and adding a CI job that verifies it.
  3. Optional: add an Alpine/musl job if we ever want to certify the crate for that target.

🤖 Generated with Claude Code

montfort and others added 2 commits May 19, 2026 15:59
Pre-existing rustfmt drift across 38 files (+440/-209 lines) — multi-line
parameter lists collapsed where they fit on one line, long chained method
calls reflowed, etc. No semantic changes; verified with:

  * cargo test --all-features → 177 tests pass
  * cargo clippy --all-features --all-targets -- -D warnings → clean

Done in its own commit so the upcoming rust-ci workflow can enable
`cargo fmt --all -- --check` as a blocking gate from day one, and so
`git blame` on reformatted lines points here instead of a CI-config commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds .github/workflows/rust-ci.yml covering the gap surfaced when PR #11
merged with only the CLA check (no Rust verification on GitHub).

Triggers: push to main, pull_request to main, manual dispatch. Path-filtered
so changes to .straymark/, governance .md files, or auxiliary tooling do not
spin up Rust compilation. Concurrency group cancels in-progress runs on the
same ref to avoid wasted runner minutes during PR iteration.

Jobs:

  * test (matrix: ubuntu-latest, macos-latest, windows-latest) — runs
    `cargo build --all-features` then `cargo test --all-features`. fail-fast
    is disabled so a Windows-only regression does not mask a macOS failure.
  * build-minimal (ubuntu) — `cargo build --no-default-features` to catch
    code that implicitly depends on a language feature being enabled.
  * clippy (ubuntu) — `cargo clippy --all-features --all-targets -- -D warnings`.
  * fmt (ubuntu) — `cargo fmt --all -- --check`. The preceding commit
    reformatted the codebase so this gate is satisfiable from day one.
  * doc (ubuntu) — `cargo doc --all-features --no-deps` with
    `RUSTDOCFLAGS=-D warnings` so broken intra-doc links fail the build.
    Important because the crate is published to crates.io and docs.rs will
    re-run this against the published version.

All jobs use actions/checkout@v5, dtolnay/rust-toolchain@stable, and
Swatinem/rust-cache@v2 (separate cache keys per job to avoid contention).

Verified locally before commit:

  * cargo build --no-default-features → ok (emits 2 unused-variable warnings
    in src/languages/mod.rs:170 when all language gates are off; non-fatal,
    follow-up in a separate PR)
  * cargo build --all-features → ok
  * cargo test --all-features → 177 tests pass
  * cargo clippy --all-features --all-targets -- -D warnings → clean
  * cargo fmt --all -- --check → clean (after the preceding commit)
  * RUSTDOCFLAGS=-D warnings cargo doc --all-features --no-deps → ok

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@montfort montfort force-pushed the chore/add-rust-ci branch from e3fadeb to d43871d Compare May 19, 2026 21:59
The CI's `cargo test --all-features` runs in the dev (debug) profile.
On shared GitHub-hosted ubuntu and windows runners, the
`large_file_analysis_under_100ms` median for the 1000-line fixture exceeds
100ms in debug — not because of a real regression, but because debug builds
are 5-10× slower than release and shared VMs add variance. macOS runners
(M-class arm) happen to be fast enough and were passing.

The 100ms target in SC-002 is a release-profile guarantee. Marking the test
`#[cfg_attr(debug_assertions, ignore = "...")]` keeps it gated on release
runs, where its assertion is meaningful:

  * `cargo test --release` → runs, passes in ~0.2s locally
  * `cargo test` (debug) → ignored with explanatory message

Verified:

  * `cargo test --test performance_bench --all-features` → 0 passed, 1 ignored
  * `cargo test --release --test performance_bench --all-features` → 1 passed
  * `cargo fmt --all -- --check` → clean

Follow-up candidate: add a separate `cargo test --release --test performance_bench`
job to the CI matrix to retain release-profile coverage without doubling
overall PR time. Not in this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@montfort montfort merged commit 882a540 into main May 19, 2026
8 checks passed
@montfort montfort deleted the chore/add-rust-ci branch May 19, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant