mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
chore(hooks): standardize check/fix convention with auto-fix pre-commit (#776)
This commit is contained in:
@@ -95,13 +95,15 @@ unit tests + builds. Clippy passing does not mean fmt passes; run both.
|
||||
Run `just test` for integration tests if you touched `sprout-relay`,
|
||||
`sprout-db`, or `sprout-auth` — these require a running Postgres and Redis.
|
||||
|
||||
**Pre-commit and pre-push hooks** are installed automatically by `just setup`.
|
||||
Pre-commit runs 5 checks in parallel on every `git commit` (Rust fmt, Tauri Rust
|
||||
fmt, desktop lint, web lint, mobile fmt) — a commit will fail if any are dirty.
|
||||
Pre-push runs the full CI gate: all pre-commit checks plus clippy, unit tests,
|
||||
desktop build, Tauri check, web build, and mobile tests (~minutes). Run
|
||||
`just fmt-all` before committing to auto-fix all formatting in one shot. Run
|
||||
`just hooks` to re-install hooks after env changes.
|
||||
**Pre-commit hooks** are installed automatically by `just setup` and auto-fix
|
||||
formatting via `stage_fixed`. Pre-commit runs fix variants in parallel (Rust
|
||||
fmt, Tauri Rust fmt, desktop biome fix, web biome fix, mobile dart format).
|
||||
Auto-fixable issues are fixed and re-staged; unfixable lint issues block the
|
||||
commit. **Pre-push hooks** run clippy (workspace + Tauri) and fast unit tests
|
||||
in parallel (Rust, desktop JS, Tauri Rust, mobile Flutter) — no overlap with
|
||||
pre-commit. Builds are CI-only. Run `just fix-all` to auto-fix all formatting
|
||||
in one shot. Run `just ci` for the full local gate. Run `just hooks` to
|
||||
re-install hooks after env changes.
|
||||
|
||||
Additional rules:
|
||||
- No `unsafe` code
|
||||
@@ -206,7 +208,7 @@ See [TESTING.md](TESTING.md) for the full multi-agent E2E guide.
|
||||
3. **`messages search` must include `--kinds`** — an open-ended search (no kinds) hits the relay p-gate and returns 403. Pass at least `--kinds 9,45001,45003` to scope the query.
|
||||
4. **Worktrees: `cd` in the same command** — shell CWD doesn't persist between tool calls. Use `cd /path && cargo build` as one command.
|
||||
5. **Desktop crate excluded from root workspace** — `cargo test` at repo root does NOT run desktop tests. Use `cargo test --manifest-path desktop/src-tauri/Cargo.toml` explicitly.
|
||||
6. **Desktop fmt check fails in worktrees and blocks commits** — the pre-commit hook runs `just desktop-tauri-fmt-check`, which fails in git worktrees because `cargo fmt` resolves workspace paths relative to the worktree root. Run `just desktop-tauri-fmt` from the main checkout to apply the fix, then re-stage and commit. CI is unaffected.
|
||||
6. **Desktop Tauri fmt fails in worktrees and blocks commits** — the pre-commit hook runs `just desktop-tauri-fmt`, which fails in git worktrees because `cargo fmt` resolves workspace paths relative to the worktree root. Run `just desktop-tauri-fmt` from the main checkout to apply the fix, then re-stage and commit. CI is unaffected.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ reindex-kind0:
|
||||
cargo run --release -p sprout-relay --bin sprout-reindex-kind0
|
||||
|
||||
# Run repo lint and formatting checks
|
||||
check: fmt-check clippy desktop-check desktop-tauri-fmt-check web-check mobile-check
|
||||
check: fmt-check clippy desktop-check desktop-tauri-fmt-check desktop-tauri-clippy web-check mobile-check
|
||||
|
||||
# Format all Rust code
|
||||
fmt:
|
||||
@@ -82,6 +82,10 @@ desktop-install-ci:
|
||||
desktop-check:
|
||||
cd {{desktop_dir}} && pnpm check
|
||||
|
||||
# Fix desktop lint and format issues
|
||||
desktop-fix:
|
||||
cd {{desktop_dir}} && pnpm exec biome check --write . && pnpm check:file-sizes
|
||||
|
||||
# Run desktop TS helper unit tests
|
||||
desktop-test:
|
||||
cd {{desktop_dir}} && pnpm test
|
||||
@@ -105,6 +109,9 @@ desktop-tauri-fmt-check:
|
||||
# Format all code (Rust + Tauri Rust + Dart)
|
||||
fmt-all: fmt desktop-tauri-fmt mobile-fmt
|
||||
|
||||
# Fix all formatting and lint issues
|
||||
fix-all: fmt desktop-tauri-fmt desktop-fix web-fix mobile-fix
|
||||
|
||||
# Ensure sidecar placeholder binaries exist (Tauri validates externalBin at compile time)
|
||||
_ensure-sidecar-stubs:
|
||||
#!/usr/bin/env bash
|
||||
@@ -115,6 +122,10 @@ _ensure-sidecar-stubs:
|
||||
touch "desktop/src-tauri/binaries/${bin}-${TARGET}"
|
||||
done
|
||||
|
||||
# Run clippy on the desktop Tauri Rust crate
|
||||
desktop-tauri-clippy: _ensure-sidecar-stubs
|
||||
cargo clippy --manifest-path {{desktop_tauri_manifest}} --all-targets -- -D warnings
|
||||
|
||||
# Check the desktop Tauri Rust crate compiles
|
||||
desktop-tauri-check: _ensure-sidecar-stubs
|
||||
cargo check --manifest-path {{desktop_tauri_manifest}}
|
||||
@@ -267,6 +278,10 @@ web-install-ci:
|
||||
web-check:
|
||||
cd {{web_dir}} && pnpm check
|
||||
|
||||
# Fix web lint and format issues
|
||||
web-fix:
|
||||
cd {{web_dir}} && pnpm exec biome check --write . && pnpm check:file-sizes
|
||||
|
||||
# Run web TypeScript checks
|
||||
web-typecheck:
|
||||
cd {{web_dir}} && pnpm typecheck
|
||||
@@ -291,6 +306,10 @@ mobile-install:
|
||||
mobile-fmt:
|
||||
unset GIT_DIR GIT_WORK_TREE; cd {{mobile_dir}} && dart format .
|
||||
|
||||
# Fix mobile formatting and run analysis
|
||||
mobile-fix:
|
||||
unset GIT_DIR GIT_WORK_TREE; cd {{mobile_dir}} && dart format . && flutter analyze
|
||||
|
||||
# Run mobile lint and format checks
|
||||
mobile-check:
|
||||
unset GIT_DIR GIT_WORK_TREE; cd {{mobile_dir}} && dart format --output=none --set-exit-if-changed . && flutter analyze
|
||||
|
||||
+15
-26
@@ -2,44 +2,33 @@ pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
rust-fmt:
|
||||
run: just fmt-check
|
||||
run: just fmt
|
||||
stage_fixed: true
|
||||
desktop-tauri-fmt:
|
||||
run: just desktop-tauri-fmt-check
|
||||
desktop-check:
|
||||
run: just desktop-check
|
||||
desktop-test:
|
||||
run: just desktop-test
|
||||
web-check:
|
||||
run: just web-check
|
||||
mobile-check:
|
||||
run: just mobile-check
|
||||
run: just desktop-tauri-fmt
|
||||
stage_fixed: true
|
||||
desktop-fix:
|
||||
run: just desktop-fix
|
||||
stage_fixed: true
|
||||
web-fix:
|
||||
run: just web-fix
|
||||
stage_fixed: true
|
||||
mobile-fix:
|
||||
run: just mobile-fix
|
||||
stage_fixed: true
|
||||
|
||||
pre-push:
|
||||
parallel: true
|
||||
commands:
|
||||
rust-fmt:
|
||||
run: just fmt-check
|
||||
rust-clippy:
|
||||
run: just clippy
|
||||
desktop-tauri-clippy:
|
||||
run: just desktop-tauri-clippy
|
||||
rust-tests:
|
||||
run: just test-unit
|
||||
desktop-check:
|
||||
run: just desktop-check
|
||||
desktop-test:
|
||||
run: just desktop-test
|
||||
desktop-tauri-fmt:
|
||||
run: just desktop-tauri-fmt-check
|
||||
desktop-build:
|
||||
run: just desktop-build
|
||||
desktop-tauri-check:
|
||||
run: just desktop-tauri-check
|
||||
desktop-tauri-test:
|
||||
run: just desktop-tauri-test
|
||||
web-check:
|
||||
run: just web-check
|
||||
web-build:
|
||||
run: just web-build
|
||||
mobile-check:
|
||||
run: just mobile-check
|
||||
mobile-test:
|
||||
run: just mobile-test
|
||||
|
||||
Reference in New Issue
Block a user