Skip to content

Commit c63a23e

Browse files
committed
feat: add pre-push hook for local tests
- Go tests run on every push - Frontend tests only run when pushing GUI tags (v*-gui) - Uses native git hooks via .husky/pre-push
1 parent 2877ced commit c63a23e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.husky/pre-push

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
echo "🔍 Running pre-push checks..."
4+
5+
# Check if pushing a GUI tag
6+
PUSHING_GUI_TAG=$(git tag --points-at HEAD | grep -E "^v.*-gui$" || true)
7+
8+
# Always run Go tests
9+
echo "🔨 Running Go tests..."
10+
go test ./cmd/... ./internal/... ./pkg/...
11+
if [ $? -ne 0 ]; then
12+
echo "❌ Go tests failed!"
13+
exit 1
14+
fi
15+
16+
# Only run frontend tests if pushing GUI tag
17+
if [ -n "$PUSHING_GUI_TAG" ]; then
18+
echo "📦 GUI tag detected: $PUSHING_GUI_TAG"
19+
echo "📦 Running frontend tests..."
20+
cd frontend && npm run test:run
21+
if [ $? -ne 0 ]; then
22+
echo "❌ Frontend tests failed!"
23+
exit 1
24+
fi
25+
cd ..
26+
else
27+
echo "⏭️ No GUI tag - skipping frontend tests"
28+
fi
29+
30+
echo "✅ All pre-push checks passed!"

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test": "vitest",
1212
"test:ui": "vitest --ui",
1313
"test:run": "vitest run",
14-
"test:coverage": "vitest run --coverage"
14+
"test:coverage": "vitest run --coverage",
15+
"prepare": "husky"
1516
},
1617
"dependencies": {
1718
"@radix-ui/react-checkbox": "^1.3.3",

0 commit comments

Comments
 (0)