Add pre-commit hook enforcing 30s test suite time limit (#132)

This commit is contained in:
Alexander Whitestone
2026-03-05 19:45:38 -05:00
committed by GitHub
parent aff3edb06a
commit 2b97da9e9c
65 changed files with 356 additions and 611 deletions

22
scripts/pre-commit-hook.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Pre-commit hook: run tests with a wall-clock limit.
# Blocks the commit if tests fail or take too long.
# Current baseline: ~18s wall-clock. Limit set to 30s for headroom.
MAX_SECONDS=30
echo "Running tests (${MAX_SECONDS}s limit)..."
timeout "${MAX_SECONDS}" poetry run pytest tests -q --tb=short --timeout=10
exit_code=$?
if [ "$exit_code" -eq 124 ]; then
echo ""
echo "BLOCKED: tests exceeded ${MAX_SECONDS}s wall-clock limit."
echo "Speed up slow tests before committing."
exit 1
elif [ "$exit_code" -ne 0 ]; then
echo ""
echo "BLOCKED: tests failed."
exit 1
fi