Compare commits

..

4 Commits

Author SHA1 Message Date
Claude BM
ec02b57adc Add global lock to serialize CI runs across branches
Multiple simultaneous test runs compete for PostgreSQL connections,
causing spurious errors. Global flock ensures one branch runs at a time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 09:20:11 +00:00
Claude BM
b8c4fe7cc2 Fail CI when 0 tests run — 0/0/0 is never a pass
If pytest reports 0 passed, 0 failed, 0 skipped, treat it as a
failure. Something is wrong if no tests ran at all.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 07:17:12 +00:00
Claude BM
0772d24cab Fix pytest-timeout detection and catch collection errors
--timeout flag caused pytest to fail silently on branches without
pytest-timeout installed. Now checks for the package first. Also
detects when pytest exits non-zero with 0 results (collection error)
and properly reports it as a failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 07:13:15 +00:00
Claude BM
11b11ea8de feat: tag @TSHARPSbm_bot in all CI notifications so Claude sees results 2026-04-21 05:18:26 +00:00
2 changed files with 29 additions and 4 deletions

View File

@ -26,7 +26,9 @@ if [ "$STATUS" = "pass" ]; then
Tests: ${SUMMARY}
Features: ${FEATURES}
Duration: ${DURATION}
Pushed by: ${ACTOR}"
Pushed by: ${ACTOR}
@TSHARPSbm_bot"
elif [ "$STATUS" = "fail" ]; then
ICON="❌"
@ -37,7 +39,8 @@ Features: ${FEATURES}
Duration: ${DURATION}
Pushed by: ${ACTOR}
${TAG_USERS} — this build needs attention."
${TAG_USERS} — this build needs attention.
@TSHARPSbm_bot"
elif [ "$STATUS" = "error" ]; then
ICON="🚨"
@ -46,7 +49,8 @@ elif [ "$STATUS" = "error" ]; then
The CI runner itself failed — not a test failure.
Check logs: journalctl -u tsharps-ci --since '5 minutes ago'
${TAG_USERS} — runner needs attention."
${TAG_USERS} — runner needs attention.
@TSHARPSbm_bot"
fi
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \

View File

@ -31,6 +31,11 @@ if ! flock -n 200; then
exit 0
fi
# Serialize all CI runs to avoid DB connection contention
GLOBAL_LOCK="/tmp/tsharps-ci-global.lock"
exec 201>"$GLOBAL_LOCK"
flock 201
echo "=== TSHARPS CI Runner ==="
echo "Branch: $BRANCH"
echo "Commit: $COMMIT"
@ -73,7 +78,12 @@ if [ ! -f "$PYTHON" ]; then
PYTHON="python3"
fi
TEST_OUTPUT=$($PYTHON -m pytest "$WORKTREE/backend/tests/" --tb=line -q --timeout="$TIMEOUT" 2>&1)
TIMEOUT_FLAG=""
if $PYTHON -c "import pytest_timeout" 2>/dev/null; then
TIMEOUT_FLAG="--timeout=$TIMEOUT"
fi
TEST_OUTPUT=$($PYTHON -m pytest "$WORKTREE/backend/tests/" --tb=line -q $TIMEOUT_FLAG 2>&1)
TEST_EXIT=$?
PASS_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+ passed' | grep -oP '\d+' || echo 0)
@ -81,6 +91,17 @@ FAIL_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+ failed' | grep -oP '\d+' || ech
SKIP_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+ skipped' | grep -oP '\d+' || echo 0)
ERROR_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+ error' | grep -oP '\d+' || echo 0)
if [ "$TEST_EXIT" -ne 0 ] && [ "$PASS_COUNT" = "0" ] && [ "$FAIL_COUNT" = "0" ]; then
ERROR_COUNT=1
echo "WARNING: pytest exited with code $TEST_EXIT but reported no results — likely a collection error"
echo "$TEST_OUTPUT" | tail -5
fi
if [ "$PASS_COUNT" = "0" ] && [ "$FAIL_COUNT" = "0" ] && [ "$SKIP_COUNT" = "0" ]; then
OVERALL="fail"
echo "FAIL: 0 tests ran — something is wrong"
fi
echo "Tests: $PASS_COUNT passed, $FAIL_COUNT failed, $SKIP_COUNT skipped, $ERROR_COUNT errors"
if [ "$FAIL_COUNT" != "0" ] && [ "$FAIL_COUNT" != "" ]; then