Skip to content

Commit 702304b

Browse files
erraggyclaude
andauthored
fix: add CI check retry logic to prepare-release script (#337)
The `gh pr checks --watch` command fails immediately when CI checks haven't registered yet after PR creation. Add a retry loop (5 attempts, 15s between) that detects "no checks reported" and waits. Also update the skill docs with benchmark timing data (mean 10.3 min across 10 releases) and background mode requirement. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e04b4b commit 702304b

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

.claude/scripts/prepare-release.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,26 @@ echo ""
219219
if [[ "$SKIP_TO_CHECKOUT" == "false" ]]; then
220220
# Step 5.3: Wait for CI and merge
221221
echo "Step 5.3: Waiting for CI checks..."
222-
if ! gh pr checks "$PR_NUMBER" --watch --fail-fast; then
223-
echo "Error: CI checks failed for PR #$PR_NUMBER" >&2
222+
# CI checks need time to register after PR creation. Retry until checks appear.
223+
CI_PASSED=false
224+
for attempt in 1 2 3 4 5; do
225+
if gh pr checks "$PR_NUMBER" --watch --fail-fast 2>/dev/null; then
226+
CI_PASSED=true
227+
break
228+
fi
229+
# If checks haven't appeared yet, wait and retry
230+
CHECKS=$(gh pr checks "$PR_NUMBER" 2>&1 || true)
231+
if echo "$CHECKS" | grep -q "no checks reported"; then
232+
echo " Checks not yet reported, waiting 15s (attempt $attempt/5)..."
233+
sleep 15
234+
else
235+
# Checks appeared but failed
236+
echo "Error: CI checks failed for PR #$PR_NUMBER" >&2
237+
exit 3
238+
fi
239+
done
240+
if [[ "$CI_PASSED" != "true" ]]; then
241+
echo "Error: CI checks never appeared for PR #$PR_NUMBER after 75s" >&2
224242
exit 3
225243
fi
226244
echo " ✓ CI checks passed"

.claude/skills/prepare-release/SKILL.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,25 @@ After all agents complete:
137137

138138
> ⚠️ **CRITICAL:** Use the prepare script. Do NOT run these commands manually.
139139
140-
After all agent work is committed, from the repository root run:
140+
After all agent work is committed, from the repository root run the script **in background mode** (`run_in_background: true`):
141141

142142
```bash
143143
.claude/scripts/prepare-release.sh <version>
144144
```
145145

146+
> **Timing:** The script takes ~13-15 minutes total (CI benchmarks ~10.3 min + CI checks ~3 min + overhead). This exceeds the Bash tool's 10-minute max timeout, so it **must** run in background mode. Use `TaskOutput` with `block: true, timeout: 600000` to wait, and re-check if it times out — the script is idempotent and can be re-run safely.
147+
146148
The script handles:
147149

148150
- **Phase 4:** Push branch, trigger CI benchmarks, wait for completion, pull results
149-
- **Phase 5:** Create PR, wait for CI checks, merge with `--admin`, switch to main
151+
- **Phase 5:** Create PR, wait for CI checks (with retry for check registration delay), merge with `--squash --admin`, switch to main
150152
- **Phase 6:** Generate release notes, save to temp file, display for review
151153

152154
If the script fails partway through, check the error message. You can re-run safely:
153155

154156
- `--skip-benchmarks` flag if benchmarks already completed
155157
- The script auto-detects already-merged PRs and skips to checkout
158+
- CI check registration delay is handled with automatic retries (up to 75s)
156159

157160
### Phase 6.2: Enhance Release Notes
158161

@@ -264,4 +267,6 @@ If user chooses "Yes", from the repository root run:
264267
- CI benchmarks run on the pre-release branch and are included in the PR
265268
- Document all new public API in CLAUDE.md
266269
- **ALWAYS use scripts** for phases 4-6 - never run release commands manually
270+
- **ALWAYS run scripts in background mode** - the prepare script takes ~13-15 min (exceeds Bash 10-min max timeout)
267271
- **ALWAYS enhance release notes** (Phase 6.2) - never skip to publishing with auto-generated notes only
272+
- **If the script fails at Phase 5.3** (CI checks), it's often a timing issue — re-run the script (it's idempotent) or manually run `gh pr checks <PR#> --watch` then merge

0 commit comments

Comments
 (0)