Enforce Rust formatting: CI gate, pre-commit hook, rustfmt.toml - #327
Open
robinskil wants to merge 4 commits into
Open
Enforce Rust formatting: CI gate, pre-commit hook, rustfmt.toml#327robinskil wants to merge 4 commits into
robinskil wants to merge 4 commits into
Conversation
- CI: new 'fmt' job runs `cargo fmt --all -- --check`, failing any PR with unformatted Rust so formatting is enforced on every PR. - rustfmt.toml: pins default Rust style (stable-only options), matching Google's Rust style guide which mandates rustfmt defaults. - .githooks/pre-commit: local rustfmt check mirroring the CI gate; install with `make hooks`. - Makefile: `make hooks` (set core.hooksPath) and `make fmt` targets.
Document prerequisites (toolchain, submodules, system libraries), the build/test workflow, and the formatting/clippy/test checks CI enforces, including how to install the rustfmt pre-commit hook (`make hooks`). Link it from the README Contributing section.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #327 +/- ##
==========================================
+ Coverage 74.51% 74.69% +0.18%
==========================================
Files 290 290
Lines 38569 39069 +500
==========================================
+ Hits 28738 29182 +444
- Misses 9831 9887 +56
🚀 New features to boost your workflow:
|
Apply `cargo fmt --all` across all crates so the code matches the default Rust style enforced by the new CI fmt gate. Formatting-only: verified identical to a clean rustfmt pass over HEAD (no logic changes). Also strips trailing whitespace inside a few #[utoipa::path(...)] macro attributes that rustfmt leaves untouched, so `cargo fmt --all -- --check` exits cleanly.
The beacon-binary-format crate is a git submodule vendored from its own upstream repo; its code is not formatted to this workspace's style, so the new fmt gate failed on files we don't own. Exclude it from the workspace (it still builds as a path dependency of beacon-arrow-bbf) and drop `--all` from the fmt commands. Plain `cargo fmt` formats every workspace member but not their path dependencies, so the submodule is skipped while all our crates are still checked. Updates the CI job, pre-commit hook, Makefile, and CONTRIBUTING accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds tooling so every PR has consistently formatted Rust code, plus a one-time repo-wide reformat so the gate is green from day one.
fmtjob (.github/workflows/ci.yml) — runscargo fmt --all -- --checkon every push/PR and fails if any Rust code is unformatted. Lightweight, separate job from clippy/test/build.rustfmt.toml— pins the default Rust style (stable-only options). This matches Google's Rust style guide, which mandates rustfmt defaults rather than a custom profile..githooks/pre-commit— local hook mirroring the CI gate; rejects commits with unformatted staged Rust (bypass with--no-verify). Install once withmake hooks.Makefile—make hooks(setscore.hooksPath) andmake fmttargets.CONTRIBUTING.md— documents prerequisites (toolchain, submodules, system libs), build/test, and the formatting/clippy/test checks CI enforces; linked from the README.cargo fmt --allapplied across all crates so the new gate passes immediately. Verified formatting-only (identical to a clean rustfmt pass over the base; no logic changes), plus stripping trailing whitespace inside a few#[utoipa::path(...)]macro attributes rustfmt leaves untouched.Commits
Add rustfmt CI gate + pre-commit hookdocs: add CONTRIBUTING.mdstyle: format the workspace with rustfmtVerification
cargo fmt --all -- --checkexits 0 on the branch tip.