Skip to content

Commit 6ff2d7d

Browse files
justin808claude
andcommitted
Improve ci-rerun-failures to handle in-progress CI jobs
- Detect when CI jobs are still running - Offer to wait for CI completion with progress updates - Poll every 30 seconds showing in-progress and failed counts - Only proceed to re-run failures after CI completes This makes the script work correctly when invoked immediately after pushing changes, rather than showing 'no failures' while jobs are still running. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent be4807a commit 6ff2d7d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

bin/ci-rerun-failures

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,32 @@ fi
3939
echo -e "${GREEN}Analyzing PR #$PR_NUMBER...${NC}"
4040
echo ""
4141

42+
# Check for in-progress jobs
43+
IN_PROGRESS_COUNT=$(echo "$STATUS_JSON" | jq '[.statusCheckRollup[] | select(.status == "IN_PROGRESS")] | length')
44+
if [ "$IN_PROGRESS_COUNT" -gt 0 ]; then
45+
echo -e "${YELLOW}$IN_PROGRESS_COUNT CI jobs are still running...${NC}"
46+
echo ""
47+
read -p "Wait for CI to complete? [Y/n] " -n 1 -r
48+
echo
49+
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
50+
echo "Waiting for CI to complete (checking every 30 seconds)..."
51+
while [ "$IN_PROGRESS_COUNT" -gt 0 ]; do
52+
sleep 30
53+
STATUS_JSON=$(gh pr view "$PR_NUMBER" --json statusCheckRollup,number 2>/dev/null)
54+
IN_PROGRESS_COUNT=$(echo "$STATUS_JSON" | jq '[.statusCheckRollup[] | select(.status == "IN_PROGRESS")] | length')
55+
FAILED_COUNT=$(echo "$STATUS_JSON" | jq '[.statusCheckRollup[] | select(.conclusion == "FAILURE")] | length')
56+
echo -e " In progress: $IN_PROGRESS_COUNT | Failed: $FAILED_COUNT"
57+
done
58+
echo -e "${GREEN}✓ CI completed!${NC}"
59+
echo ""
60+
fi
61+
fi
62+
4263
# Parse failed checks
4364
FAILED_CHECKS=$(echo "$STATUS_JSON" | jq -r '.statusCheckRollup[] | select(.conclusion == "FAILURE") | .name')
4465

4566
if [ -z "$FAILED_CHECKS" ]; then
46-
echo -e "${GREEN}No failed checks found! All CI jobs passed.${NC}"
67+
echo -e "${GREEN}No failed checks found! All CI jobs passed.${NC}"
4768
exit 0
4869
fi
4970

0 commit comments

Comments
 (0)