Optimize Pre-Push Hook for Speed

 Optimized Pre-Push Hook:
- Quick checks only: ESLint, TypeScript, npm audit
- Removed slow tests and build (run in GitHub Actions)
- ~3x faster for small fixes

 Added Full Pre-Push Option:
- npm run pre-push:full for complete checks
- Use for important changes or releases
- Includes tests and build locally

🎯 Best Practices:
- Quick checks locally (30 seconds)
- Full validation in GitHub Actions
- Best of both worlds: speed + thoroughness

📝 Usage:
- Normal pushes: npm run pre-push (fast)
- Important changes: npm run pre-push:full (thorough)
This commit is contained in:
Dennis Konkol
2025-09-06 08:57:31 +00:00
parent 2e91dfc7d5
commit 1d4ae2bd41
3 changed files with 123 additions and 24 deletions

View File

@@ -64,30 +64,7 @@ if ! npm run lint; then
fi
print_success "ESLint passed"
# 3. Run Tests
print_status "Running tests..."
if ! npm run test; then
print_error "Tests failed! Please fix the failing tests before pushing."
exit 1
fi
print_success "All tests passed"
# 4. Build Application
print_status "Building application..."
if ! npm run build; then
print_error "Build failed! Please fix the build errors before pushing."
exit 1
fi
print_success "Build successful"
# 5. Security Audit
print_status "Running security audit..."
if ! npm audit --audit-level=moderate; then
print_warning "Security vulnerabilities found. Consider running 'npm audit fix'"
# Don't fail the push for security warnings, just warn
fi
# 6. Type Check
# 3. Quick Type Check (faster than full build)
print_status "Running TypeScript type check..."
if ! npx tsc --noEmit; then
print_error "TypeScript type check failed!"
@@ -95,6 +72,16 @@ if ! npx tsc --noEmit; then
fi
print_success "TypeScript type check passed"
# Note: Tests and Build will run in GitHub Actions
print_status "Skipping tests and build locally (will run in CI/CD)"
# 4. Security Audit (quick check)
print_status "Running security audit..."
if ! npm audit --audit-level=moderate; then
print_warning "Security vulnerabilities found. Consider running 'npm audit fix'"
# Don't fail the push for security warnings, just warn
fi
echo ""
echo "================================"
print_success "All pre-push checks passed! ✅"