Files
awoooi/.claude/hooks/pre-commit-check.sh
OG T 9bff46a1b0 feat: integrate Sentry + fix CI/CD issues
Sentry Integration (補強 SignOz):
- Add @sentry/nextjs for frontend error tracking + session replay
- Add sentry-sdk[fastapi] for backend error tracking
- Create sentry.client/server/edge.config.ts
- Integrate with next.config.js + instrumentation.ts
- Add Sentry exception capture in FastAPI error handler
- Create deployment scripts for Self-Hosted @ 192.168.0.110

CI/CD Fixes:
- Fix F821 Undefined name 'Field' in incidents.py
- Add NEXT_PUBLIC_API_URL env var to CI build step
- Add build-arg to Docker build verification

E2E Test Improvements:
- Fix strict mode violations in dashboard-acceptance tests
- Add timeout increase for Phase 4 demo tests
- Make tests more resilient to UI variations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-24 15:19:52 +08:00

34 lines
896 B
Bash
Executable File

#!/bin/bash
# Pre-commit 檢查 - 自動驗證是否違反 HARD_RULES
echo "🔍 檢查 HARD_RULES 違規..."
ERRORS=0
# 1. GitHub Workflows - 禁止 ubuntu-latest
if grep -r "runs-on: ubuntu-latest" .github/workflows/ 2>/dev/null; then
echo "❌ 違規: 發現 ubuntu-latest (必須用 self-hosted)"
ERRORS=$((ERRORS + 1))
fi
# 2. SQLite 檢查
if grep -r "sqlite" apps/api/ --include="*.py" 2>/dev/null | grep -v "#" | grep -v "禁止"; then
echo "❌ 違規: 發現 SQLite (必須用 PostgreSQL)"
ERRORS=$((ERRORS + 1))
fi
# 3. CORS * 檢查
if grep -rE "CORS.*['\"]?\*['\"]?" apps/api/ --include="*.py" 2>/dev/null; then
echo "❌ 違規: 發現 CORS * (必須用白名單)"
ERRORS=$((ERRORS + 1))
fi
if [ $ERRORS -gt 0 ]; then
echo ""
echo "🚨 發現 $ERRORS 個違規,請修正後再提交"
exit 1
fi
echo "✅ HARD_RULES 檢查通過"
exit 0