|
1 | 1 | # Glob patterns below mirror the `changes` job's dorny/paths-filter groups in |
2 | | -# .github/workflows/ci.yml — keep the two in sync. Deliberate deviations: |
| 2 | +# .github/workflows/ci.yml — keep the two in sync. Each globbed pre-push lane |
| 3 | +# also sets `files: git diff --name-only origin/main...HEAD` so its file set is |
| 4 | +# the branch's merge-base diff against origin/main — the same semantics as CI's |
| 5 | +# dorny/paths-filter and `scripts/check-file-sizes-core.mjs` `resolveBaseRef`. |
| 6 | +# Without it lefthook derives files from `git diff HEAD @{push}`, which after a |
| 7 | +# rebase or `git merge origin/main` includes everything main changed since the |
| 8 | +# branch's last push (firing mobile/desktop/rust lanes on unrelated pushes), and |
| 9 | +# on a brand-new branch falls back to a stale remote's tip (a full-suite run). |
| 10 | +# The three-dot diff scopes every lane to what this branch actually changed. |
| 11 | +# Both the three-dot diff and lefthook's stock discovery inspect the checked-out |
| 12 | +# HEAD, so pushing a non-HEAD ref (explicit refspec, `--all`) validates HEAD's |
| 13 | +# tree, not the pushed commit — the always-on `push-head-scope` lane warns when |
| 14 | +# they diverge and CI remains the authoritative gate for that ref. |
| 15 | +# Deliberate deviations: |
3 | 16 | # - The `.github/workflows/ci.yml` path CI adds to its `rust`/`mobile` filters |
4 | 17 | # is omitted; a CI-workflow-only edit doesn't need a local test run. |
5 | 18 | # - `desktop-check`/`desktop-typecheck`/`desktop-test` don't trigger on `rust` |
|
16 | 29 | # - `commit-msg` has no glob: it rewrites the commit message, not files. Note |
17 | 30 | # Git only runs it for `git commit` and `git merge` — other flows need their own |
18 | 31 | # flag: `git rebase --signoff`, `git cherry-pick -s`. |
| 32 | +# |
| 33 | +# `rc` points `lefthook install` at `bin/.lefthookrc`, which the generated |
| 34 | +# `.git/hooks/*` dispatchers source before their `$LEFTHOOK_BIN`-first lookup. It |
| 35 | +# (1) sets `LEFTHOOK_BIN` to the Hermit-pinned `bin/lefthook` (2.1.3) so a push |
| 36 | +# from any worktree runs the pinned binary even when a different lefthook is on |
| 37 | +# PATH, and (2) prepends the repo's Hermit `bin/` to `PATH` so every lane |
| 38 | +# subprocess (`just mobile-check` -> flutter/dart, etc.) resolves the pinned |
| 39 | +# toolchain regardless of the invoking shell — the hook self-pins, so a Homebrew |
| 40 | +# flutter/dart ahead on PATH can no longer cause false lane failures. |
| 41 | +rc: bin/.lefthookrc |
| 42 | + |
19 | 43 | pre-commit: |
20 | 44 | parallel: true |
21 | 45 | commands: |
@@ -56,33 +80,46 @@ pre-push: |
56 | 80 | commands: |
57 | 81 | branch-skew: |
58 | 82 | run: ./scripts/check-branch-skew.sh |
| 83 | + push-head-scope: |
| 84 | + # Warn-only: the scoped lanes below validate the checked-out HEAD, so a |
| 85 | + # non-HEAD ref push (explicit refspec, --all) relies on CI for its |
| 86 | + # path-scoped checks. This lane reads the pushed refs from stdin and |
| 87 | + # warns when any pushed commit is not HEAD. It never fails the push. |
| 88 | + use_stdin: true |
| 89 | + run: ./scripts/check-push-head-scope.sh |
59 | 90 | file-size-check: |
60 | 91 | # The ratchet computes its own merge-base diff, so path filtering here |
61 | 92 | # would only duplicate policy and create another place for coverage drift. |
62 | 93 | run: just file-size-check |
63 | 94 | rust-tests: |
| 95 | + files: git diff --name-only origin/main...HEAD |
64 | 96 | glob: ["crates/**", "migrations/**", "schema/**", "Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "deny.toml", "scripts/run-tests.sh", "Justfile"] |
65 | 97 | run: just test-unit |
66 | 98 | desktop-check: |
| 99 | + files: git diff --name-only origin/main...HEAD |
67 | 100 | glob: ["desktop/**", "pnpm-lock.yaml"] |
68 | 101 | exclude: ["desktop/src-tauri/**"] |
69 | 102 | run: just desktop-check |
70 | 103 | desktop-typecheck: |
| 104 | + files: git diff --name-only origin/main...HEAD |
71 | 105 | glob: ["desktop/**", "pnpm-lock.yaml"] |
72 | 106 | exclude: ["desktop/src-tauri/**"] |
73 | 107 | run: just desktop-typecheck |
74 | 108 | desktop-test: |
| 109 | + files: git diff --name-only origin/main...HEAD |
75 | 110 | glob: ["desktop/**", "pnpm-lock.yaml"] |
76 | 111 | exclude: ["desktop/src-tauri/**"] |
77 | 112 | run: just desktop-test |
78 | 113 | desktop-tauri-checks: |
79 | 114 | # Keep local lint parity with Desktop Core CI for every path that can |
80 | 115 | # affect the Tauri crate or its path dependencies. Run clippy and tests |
81 | 116 | # serially so parallel pre-push hooks do not contend for Cargo's lock. |
| 117 | + files: git diff --name-only origin/main...HEAD |
82 | 118 | glob: ["desktop/src-tauri/**", "crates/**", "migrations/**", "schema/**", "Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "deny.toml", "scripts/run-tests.sh", "Justfile"] |
83 | 119 | run: just desktop-tauri-clippy && just desktop-tauri-test |
84 | 120 | mobile-checks: |
85 | 121 | # Run analysis and tests serially so parallel pre-push hooks do not |
86 | 122 | # contend for shared Flutter state (.dart_tool, shader bundle). |
| 123 | + files: git diff --name-only origin/main...HEAD |
87 | 124 | glob: ["mobile/**"] |
88 | 125 | run: just mobile-check && just mobile-test |
0 commit comments