Skip to content

chore(bootstrap): verify lefthook hooks active end-to-end#10

Merged
mpiton merged 1 commit intomainfrom
chore/task-11-lefthook-hooks
May 3, 2026
Merged

chore(bootstrap): verify lefthook hooks active end-to-end#10
mpiton merged 1 commit intomainfrom
chore/task-11-lefthook-hooks

Conversation

@mpiton
Copy link
Copy Markdown
Owner

@mpiton mpiton commented May 3, 2026

Summary

Task 11 (Sprint 0) — verify Git pre-commit and pre-push hooks fire correctly on the empty Tauri scaffold. Adds missing lefthook devDependency and fixes two glob-pattern bugs that silently skipped TypeScript/Rust files during hook execution.

Why

Lefthook is referenced in lefthook.yml but was never added to package.json, causing pnpm exec lefthook install to fail with "Command not found". Additionally, gobwas/glob patterns src/**/*.{ts,tsx,...} only match files at depth ≥2, silently skipping direct children like src/App.tsx. This breaks pre-commit format validation. Finally, vitest 4.x exits code 1 on empty test scaffold, blocking pre-push on Sprint 0 which has zero tests.

Changes

  • Add lefthook ^2.1.6 as devDependency in package.json — enables hook installation and execution
  • Fix pre-commit glob patterns: src/**/*.{...}**/*.{...} and src-tauri/**/*.rs**/*.rs — gobwas/glob requires ** to match ≥1 path component; staged-file filter still scopes execution
  • Fix pre-push ts-test command: add --passWithNoTests flag to vitest — vitest 4.x default fails on empty scaffold; flag will be removed when Sprint 1 lands first test suite
  • Update CHANGELOG.md with all fixes and test scenario verification

Testing

All 4 pre-commit acceptance scenarios verified:

  • Scenario A: Stage .env file → hook blocks with "Secret file detected"
  • Scenario B: Manually edit Cargo.toml without Cargo.lock → hook blocks with "Manual dependency editing forbidden"
  • Scenario C: Run cargo add log then commit Cargo.toml + Cargo.lock → commit accepted
  • Scenario D: Stage badly-formatted App.tsx → hook blocks with "Format violation" (after glob fix)

Pre-push validated: runs full pipeline (cargo test, vitest, tsc, cargo-deny, knip) in 3.3 s warm / 42 s cold, both under 60 s budget.

Related Issues

  • Task 11 in Sprint 0 (bootstrap phase)
  • Unblocks Task 12 (Verify CI workflow green)

Checklist

  • All acceptance criteria from Task 11 passing
  • CHANGELOG.md updated
  • No secrets committed
  • Self-reviewed diff
  • Pre-commit hooks pass locally
  • Pre-push hooks pass locally

Summary by CodeRabbit

  • Chores
    • Added lefthook devDependency for streamlined git hook installation and management.
    • Updated pre-commit and pre-push hook configurations with improved glob patterns.
    • Modified pre-push test invocation to prevent failures when no tests are present.

Add the missing `lefthook` 2.1.6 devDependency so `pnpm exec lefthook
install` actually works, then verify the four pre-commit scenarios
(`.env`, manual Cargo.toml edit, cargo add, format violation) and the
pre-push pipeline behave as documented.

Two follow-up fixes surfaced during verification:

- Pre-commit globs `src/**/*.{ts,tsx,...}` and `src-tauri/**/*.rs` were
  silently skipping direct children because `gobwas/glob` requires `**`
  to match >=1 path component. Switched to `**/*.{...}` so `src/App.tsx`
  and `src-tauri/build.rs` reach `oxfmt --check` / `cargo fmt --check`.
  Staged-file filter still scopes execution to actually-staged files.

- Pre-push `ts-test` exited 1 on the empty scaffold because vitest 4.x
  changed the default to fail on no test files. Switched to
  `pnpm exec vitest run --passWithNoTests` (mirrors the CI workflow
  flag); will revert when Sprint 1 lands the first domain test suite.

Pre-push budget verified: 3.3 s warm / 42 s cold, both under the 60 s
target documented in the task acceptance criteria.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc0fdf5a-3bdb-4748-9a5c-4be76b06f4da

📥 Commits

Reviewing files that changed from the base of the PR and between 6d3136a and 08c4dd8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • CHANGELOG.md
  • lefthook.yml
  • package.json

📝 Walkthrough

Walkthrough

This PR introduces git hook automation via lefthook by adding the dependency to package.json, configuring hook behaviors in lefthook.yml with corrected glob patterns and test failure handling, and documenting these changes in CHANGELOG.md.

Changes

Lefthook Git Hooks Setup

Layer / File(s) Summary
Dependency Declaration
package.json
lefthook@^2.1.6 added to devDependencies.
Hook Configuration
lefthook.yml
Glob patterns updated from directory-scoped (src-tauri/**/*.rs, src/**/*.{ts,tsx,css,json}) to root-level (**/*.rs, **/*.{ts,tsx,css,json}) to catch direct children; Vitest pre-push hook now uses --passWithNoTests to prevent failure when no tests exist.
Documentation
CHANGELOG.md
Unreleased section records lefthook devDependency addition with hook installation instructions via ./scripts/install-hooks.sh, and documents the glob pattern fixes and Vitest flag change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hoppy hooks now guard the gate,
Lefthook keeps code in pristine state,
Glob patterns leap, tests forgive,
Git hygiene—how lint should live!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(bootstrap): verify lefthook hooks active end-to-end' clearly summarizes the main purpose of the PR, which is to verify and fix Git pre-commit/pre-push lefthook hooks to work correctly end-to-end.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/task-11-lefthook-hooks

Review rate limit: 3/5 reviews remaining, refill in 16 minutes and 1 second.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 3, 2026

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing chore/task-11-lefthook-hooks (08c4dd8) with main (6d3136a)

Open in CodSpeed

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@mpiton mpiton merged commit 15ab0fb into main May 3, 2026
14 checks passed
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