1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/scripts/pre-commit-hook.sh
2026-03-05 19:45:38 -05:00

23 lines
620 B
Bash
Executable File

#!/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