Skip to content

Enforce Rust formatting: CI gate, pre-commit hook, rustfmt.toml - #327

Open
robinskil wants to merge 4 commits into
mainfrom
tooling/formatting
Open

Enforce Rust formatting: CI gate, pre-commit hook, rustfmt.toml#327
robinskil wants to merge 4 commits into
mainfrom
tooling/formatting

Conversation

@robinskil

@robinskil robinskil commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

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.

  • CI fmt job (.github/workflows/ci.yml) — runs cargo fmt --all -- --check on 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 with make hooks.
  • Makefilemake hooks (sets core.hooksPath) and make fmt targets.
  • CONTRIBUTING.md — documents prerequisites (toolchain, submodules, system libs), build/test, and the formatting/clippy/test checks CI enforces; linked from the README.
  • Workspace reformatcargo fmt --all applied 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

  1. Add rustfmt CI gate + pre-commit hook
  2. docs: add CONTRIBUTING.md
  3. style: format the workspace with rustfmt

Verification

  • cargo fmt --all -- --check exits 0 on the branch tip.
  • Pre-commit hook verified to both block unformatted staged Rust and pass on clean code.

robinskil added 2 commits July 9, 2026 14:38
- 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

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.30719% with 290 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.69%. Comparing base (ab1b6ab) to head (f117187).

Files with missing lines Patch % Lines
beacon-functions/src/geo/st_within_point.rs 20.00% 36 Missing ⚠️
beacon-mcp/src/catalog.rs 68.91% 23 Missing ⚠️
beacon-core/src/runtime.rs 90.90% 14 Missing ⚠️
...on-functions/src/metadata/view_statistics_cache.rs 0.00% 14 Missing ⚠️
...formats/beacon-arrow-zarr/src/datafusion/source.rs 53.57% 13 Missing ⚠️
...eacon-file-formats/beacon-arrow-tiff/src/reader.rs 36.84% 12 Missing ⚠️
beacon-core/src/statement_plan/physical.rs 64.28% 10 Missing ⚠️
...-functions/src/metadata/view_dataset_statistics.rs 0.00% 10 Missing ⚠️
beacon-core/src/statement_plan/actions.rs 33.33% 8 Missing ⚠️
...acon-arrow-netcdf/src/datafusion/table_function.rs 0.00% 8 Missing ⚠️
... and 49 more
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
beacon-api/src/axum/admin/datasets.rs 88.05% <ø> (ø)
beacon-api/src/axum/admin/mod.rs 87.87% <100.00%> (ø)
beacon-api/src/axum/client/mod.rs 95.12% <100.00%> (ø)
beacon-api/src/axum/client/query.rs 7.35% <ø> (ø)
beacon-api/src/flight_sql/auth.rs 77.35% <100.00%> (-0.83%) ⬇️
beacon-api/src/flight_sql/service.rs 76.97% <100.00%> (+0.46%) ⬆️
beacon-api/src/flight_sql/storage.rs 98.03% <ø> (ø)
beacon-auth/src/basic.rs 97.93% <100.00%> (+0.02%) ⬆️
beacon-auth/src/composite.rs 100.00% <100.00%> (ø)
beacon-auth/src/role.rs 97.79% <100.00%> (+<0.01%) ⬆️
... and 124 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
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