build: F5 E-gate — add pre-commit hook (frontend lint + JS tests)
scripts/githooks/pre-commit runs scripts/lint-frontend.sh and the JS test
runner, blocking the commit on any failure (no-PR workflow, gates run
locally). Activated via core.hooksPath; documented in CONTRIBUTING with the
one-time `git config core.hooksPath scripts/githooks` and the --no-verify
bypass. Verified both directions: passes on a clean tree, and blocks a commit
carrying a lint violation (tested with a native-dialog call).
Now unblocked because the token-coverage lint is clean (F5 T).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 files changed,
+36 insertions,
-0 deletions
| 232 |
232 |
|
|
| 233 |
233 |
|
Node.js test runner at `src-tauri/frontend/js/tests/run.js` with browser API mocks. Run with `node src-tauri/frontend/js/tests/run.js`.
|
| 234 |
234 |
|
|
|
235 |
+ |
### Pre-commit gate
|
|
236 |
+ |
|
|
237 |
+ |
`scripts/githooks/pre-commit` runs the frontend lint (`scripts/lint-frontend.sh`) and the JS tests, and blocks the commit on any failure (no-PR workflow: gates run locally). Activate once per clone:
|
|
238 |
+ |
|
|
239 |
+ |
```sh
|
|
240 |
+ |
git config core.hooksPath scripts/githooks
|
|
241 |
+ |
```
|
|
242 |
+ |
|
|
243 |
+ |
Bypass a work-in-progress commit with `git commit --no-verify`.
|
|
244 |
+ |
|
| 235 |
245 |
|
### Full Pipeline
|
| 236 |
246 |
|
|
| 237 |
247 |
|
Always verify: plugin fetch → DB upsert → command response → JS render. A bug in any layer can appear as a symptom in another.
|
|
1 |
+ |
#!/bin/bash
|
|
2 |
+ |
# Balanced Breakfast pre-commit gate: frontend design-system lint + JS tests.
|
|
3 |
+ |
# Blocks the commit if either fails (per the no-PR workflow; run locally).
|
|
4 |
+ |
#
|
|
5 |
+ |
# Activate in a fresh clone (one-time):
|
|
6 |
+ |
# git config core.hooksPath scripts/githooks
|
|
7 |
+ |
#
|
|
8 |
+ |
# Bypass for a work-in-progress commit: git commit --no-verify
|
|
9 |
+ |
set -euo pipefail
|
|
10 |
+ |
|
|
11 |
+ |
ROOT="$(git rev-parse --show-toplevel)"
|
|
12 |
+ |
cd "$ROOT"
|
|
13 |
+ |
|
|
14 |
+ |
echo "pre-commit: frontend lint..."
|
|
15 |
+ |
if ! bash scripts/lint-frontend.sh; then
|
|
16 |
+ |
echo "pre-commit: lint failed — commit aborted (use --no-verify to bypass)."
|
|
17 |
+ |
exit 1
|
|
18 |
+ |
fi
|
|
19 |
+ |
|
|
20 |
+ |
echo "pre-commit: JS tests..."
|
|
21 |
+ |
if ! node src-tauri/frontend/js/tests/run.js; then
|
|
22 |
+ |
echo "pre-commit: JS tests failed — commit aborted (use --no-verify to bypass)."
|
|
23 |
+ |
exit 1
|
|
24 |
+ |
fi
|
|
25 |
+ |
|
|
26 |
+ |
echo "pre-commit: clean."
|