Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail

# Mirrors .github/workflows/ci.yml so local commits match CI.
# Runs from the worktree root regardless of where `git commit` was invoked.
cd "$(git rev-parse --show-toplevel)"

# Git exports GIT_DIR/GIT_INDEX_FILE/etc. into hooks; subprocess `git`
# calls inside tests would otherwise target the parent repo instead of
# their tmp repos, breaking any test that shells out to git.
unset GIT_DIR GIT_INDEX_FILE GIT_WORK_TREE GIT_PREFIX GIT_EXEC_PATH \
GIT_AUTHOR_DATE GIT_COMMITTER_DATE GIT_EDITOR GIT_REFLOG_ACTION

echo "[pre-commit] pnpm check"
pnpm check

echo "[pre-commit] pnpm test"
pnpm test

echo "[pre-commit] cargo +stable fmt --check"
(cd src-tauri && cargo +stable fmt --check)

echo "[pre-commit] cargo +stable clippy -- -D warnings"
(cd src-tauri && cargo +stable clippy -- -D warnings)

echo "[pre-commit] cargo +stable test"
# --test-threads=1 works around a shared-env-var flake between scaffold
# tests and worktree tests; see followup issue.
(cd src-tauri && cargo +stable test -- --test-threads=1)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"test": "vitest run",
"test:e2e": "npx playwright test --project=e2e",
"demo": "npx playwright test --project=demo",
"test:watch": "vitest"
"test:watch": "vitest",
"prepare": "git config core.hooksPath .githooks"
},
"license": "MIT",
"dependencies": {
Expand Down
Loading