Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ce3f16
test(infra): ENG-4687 add pre-commit config invariant test (red)
jimbofreedman May 20, 2026
e302d5c
feat(infra): ENG-4687 add pre-commit config (cargo fmt --check + hygi…
jimbofreedman May 20, 2026
109c4af
docs: ENG-4687 document pre-commit install in CONTRIBUTING.md
jimbofreedman May 20, 2026
a62807e
style: ENG-4687 rustfmt pre_commit_config test (collapse array literal)
jimbofreedman May 20, 2026
b4f2660
fix(infra): ENG-4687 extend cargo-fmt-check hook to cover downstream_…
jimbofreedman May 20, 2026
2229cee
test(infra): ENG-4687 add pre-commit e2e tests (AC2-AC4)
jimbofreedman May 20, 2026
c58567a
fix(docs): ENG-4687 strip extra trailing newline from CODE_OF_CONDUCT.md
jimbofreedman May 20, 2026
d748d0c
test(infra): ENG-4687 tighten AC3 fallback to match `rustfmt` not `ca…
jimbofreedman May 20, 2026
b073a9d
docs: ENG-4687 reposition "Before opening a PR, run:" in CONTRIBUTING
jimbofreedman May 20, 2026
1c05494
ci: ENG-4687 add pre-commit job so AC2/AC3/AC4 are machine-verified
jimbofreedman May 20, 2026
5918e37
test(infra): ENG-4687 tighten AC4 clippy-invoked probe
jimbofreedman May 20, 2026
a3a3503
test(infra): ENG-4687 anchor AC4 negative check on seeded crate banner
jimbofreedman May 20, 2026
b0589a3
test(infra): ENG-4687 make python-hook absence check case-insensitive
jimbofreedman May 20, 2026
d1b3030
style: ENG-4687 rustfmt pre_commit_e2e (collapse multi-line let binding)
jimbofreedman May 20, 2026
bcb1333
fix(infra): ENG-4687 split cargo-fmt-check hook for cross-platform su…
jimbofreedman May 20, 2026
3afa7bb
test(infra): ENG-4687 harden e2e tests per Copilot review
jimbofreedman May 20, 2026
6410f35
docs: ENG-4687 add pre-commit install command to CONTRIBUTING.md
jimbofreedman May 20, 2026
a30afac
fix: ENG-4687 address second Copilot review on PR #8
jimbofreedman May 20, 2026
fd46d11
fix: ENG-4687 address third Copilot review on PR #8
jimbofreedman May 20, 2026
09f6266
test(infra): ENG-4687 address fourth Copilot review on PR #8
jimbofreedman May 20, 2026
8d19074
fix: ENG-4687 address fourth Copilot review on PR #8
jimbofreedman May 20, 2026
1611101
fix(test): ENG-4687 AC4 strip cargo ANSI colors so `Checking` matches
jimbofreedman May 20, 2026
bfb40f6
test(infra): ENG-4687 address fifth Copilot review on PR #8
jimbofreedman May 20, 2026
5a4e172
test+ci: ENG-4687 address sixth Copilot review on PR #8
jimbofreedman May 20, 2026
805d707
test(infra): ENG-4687 address seventh Copilot review on PR #8
jimbofreedman May 20, 2026
25e2b07
test(infra): ENG-4687 use Vec::contains over manual any() pattern
jimbofreedman May 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,36 @@ jobs:
with:
shared-key: docs
- run: cargo doc --no-deps --all-features

pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# Pin `pre-commit` so CI stays reproducible. The e2e tests assert
# on specific pre-commit diagnostic wording (e.g. "No hook with
# id ..."); an unpinned upstream release could change that
# wording and cause nondeterministic CI failures.
- run: pip install 'pre-commit==4.6.0'
- uses: Swatinem/rust-cache@v2
with:
shared-key: pre-commit
# `cargo test --test pre_commit_e2e` exercises pre-commit
# end-to-end: AC2 (`ac2_pre_commit_run_all_files_passes_on_current_tree`)
# runs `pre-commit run --all-files` on the repo root and also
# asserts the tree stays drift-free; AC3 covers the fmt-bad
# commit path; AC4 covers the manual-stage clippy hook and its
# default-stage absence. AC2 supersedes a standalone
# `pre-commit run --all-files` step here — it does the same hook
# invocation plus the drift check, so running both would
# duplicate the hook suite and burn CI time. Without pre-commit
# on PATH, the e2e tests silently skip — installing it above is
# what makes AC2/AC3/AC4 actually machine-verified rather than
# self-attested.
- run: cargo test --test pre_commit_e2e
71 changes: 71 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ENG-4687: local pre-commit gate for rustyroute.
#
# Mirrors the framework patterns from spotship/backend's config
# (top-level exclude, default_stages, rev: v5.0.0) and
# spotship/swiftsure's non-Python hygiene baseline. Substitutes
# `cargo fmt --check` for Python-specific linting. Clippy is opt-in
# via --hook-stage manual because it is too slow for every commit. CI
# (.github/workflows/ci.yaml) is the network-side enforcement; this
# file is the laptop-side early signal.
#
# Locked by tests/pre_commit_config.rs — see that file for the
# invariants asserted against silent drift.

exclude: |
(?x)(
^target/|
^data/|
^vendor/eurostat-marnet/.*\.gpkg$|
\.rkyv$
)
default_stages: [pre-commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-merge-conflict
- id: check-case-conflict
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-vcs-permalinks
- id: forbid-new-submodules
- id: mixed-line-ending
args: [--fix=lf]
- id: detect-private-key

- repo: local
hooks:
- id: cargo-fmt-check
# Checks the root crate. A second hook
# (`cargo-fmt-check-downstream`) covers the nested
# `tests/downstream_consumer/` sub-package, which is its own
# `[package]` (not a workspace member) — so the root
# `cargo fmt --check` does NOT traverse into it. The two
# invocations live in separate hooks rather than chaining a
# single shell command, so neither entry depends on a shell
# being available — relevant on Windows CI runners.
name: cargo fmt --check (root)
entry: cargo fmt --check
language: system
pass_filenames: false
types: [rust]
- id: cargo-fmt-check-downstream
name: cargo fmt --check (downstream_consumer)
entry: cargo fmt --manifest-path tests/downstream_consumer/Cargo.toml --check
language: system
pass_filenames: false
types: [rust]
- id: cargo-clippy
name: cargo clippy --no-deps
entry: cargo clippy --no-deps -- -D warnings
language: system
pass_filenames: false
always_run: true
stages: [manual]
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ For answers to common questions about this code of conduct, see the FAQ at [http
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

22 changes: 21 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,27 @@ See <https://developercertificate.org/> for the full text of the DCO.

## Local validation

Before opening a pull request, run:
First-time setup — install [pre-commit](https://pre-commit.com) itself
(via pipx, pip, or Homebrew), then enable the git hook so format and
file-hygiene checks run on every `git commit`:

```sh
pipx install pre-commit # or: pip install pre-commit / brew install pre-commit
pre-commit install
```

To run the managed hooks explicitly (e.g. before pushing):

```sh
pre-commit run --all-files
pre-commit run --hook-stage manual # runs cargo clippy --no-deps -- -D warnings
```

The pre-commit gate runs `cargo fmt --check` plus lightweight file
hygiene (trailing whitespace, EOF newlines, YAML/TOML/JSON syntax,
merge-conflict markers, private keys). Clippy and the rest of the
full local validation suite remain manual. Before opening a pull
request, run:

```sh
cargo fmt --check
Expand Down
4 changes: 2 additions & 2 deletions tests/downstream_consumer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub fn exercise_public_api() -> (u32, u32, u32) {
assert_eq!(loaded.resolution_km(), 50);

// Path 2: Graph::from_bytes via the static BYTES_50KM const.
let static_g = Graph::from_bytes(rustyroute::data::BYTES_50KM)
.expect("Graph::from_bytes(BYTES_50KM)");
let static_g =
Graph::from_bytes(rustyroute::data::BYTES_50KM).expect("Graph::from_bytes(BYTES_50KM)");

// Sanity: both observations agree on shape.
assert_eq!(loaded.node_count(), static_g.node_count());
Expand Down
Loading
Loading