Compare commits
4 Commits
9b7abec506
...
ec02b57adc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec02b57adc | ||
|
|
b8c4fe7cc2 | ||
|
|
0772d24cab | ||
|
|
11b11ea8de |
10
ci-notify.sh
10
ci-notify.sh
@ -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" \
|
||||
|
||||
23
ci-runner.sh
23
ci-runner.sh
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user