ci: retry hra-release label check while PR list is empty - #22
Conversation
The commits/{sha}/pulls API is eventually consistent: right after a merge
it can return an empty array for tens of seconds before the commit is
associated with its PR, causing the release to skip the hra-release label.
Retry only while the array is empty and stop as soon as a PR is found, so
non-release merges never wait.
Refs: #19
|
✔️ a4e7bf7 - Conventional commits check succeeded. |
WalkthroughChangesThe Sequence Diagram(s)sequenceDiagram
participant CheckJob
participant GitHubAPI
CheckJob->>GitHubAPI: query PRs for COMMIT_SHA
alt no PRs found and attempts remain
GitHubAPI-->>CheckJob: empty PR list
CheckJob->>CheckJob: wait 30s, retry (up to 5 times)
else PRs found
GitHubAPI-->>CheckJob: PR list with labels
CheckJob->>CheckJob: check for hra-release label
CheckJob->>CheckJob: write result to GITHUB_OUTPUT
end
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/nodejs-publish-release.yml (1)
51-51: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winReal
gh apifailures are indistinguishable from "PR not yet associated".
2>/dev/null || echo "[]"swallows every failure mode (auth error, rate limit, network blip) the same way as a genuinely empty PR list. All 5 attempts then run through their full delay and log "No PR associated ... yet" even when the real cause is an API/auth failure, silently producingresult=falsewithout any signal of what actually went wrong.Since publish is gated on this output (a
falsehere is a no-op perpublish-release.yml's note onhra-release), a masked transient failure could quietly skip a real release with no actionable log trail.🔍 Suggested fix to surface the real error
- pulls=$(gh api "repos/${REPOSITORY}/commits/${COMMIT_SHA}/pulls" 2>/dev/null || echo "[]") - count=$(echo "$pulls" | jq 'length') + if ! pulls=$(gh api "repos/${REPOSITORY}/commits/${COMMIT_SHA}/pulls" 2>&1); then + echo "gh api call failed (attempt $i/$attempts): $pulls" >&2 + pulls="[]" + fi + count=$(echo "$pulls" | jq 'length' 2>/dev/null || echo 0)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/nodejs-publish-release.yml at line 51, The pulls lookup in the release workflow is masking all gh api failures as an empty PR list, so distinguish “no PR yet” from real API errors in the publish step. Update the gh api call used in the retry loop so it captures the command’s exit status and stderr, logs the actual failure when gh api fails, and only falls back to the empty-array path when the API truly returns no associated PRs. Use the existing retry logic around pulls and the surrounding publish-release workflow step to keep the behavior of result=false only for the intended no-PR case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/nodejs-publish-release.yml:
- Line 51: The pulls lookup in the release workflow is masking all gh api
failures as an empty PR list, so distinguish “no PR yet” from real API errors in
the publish step. Update the gh api call used in the retry loop so it captures
the command’s exit status and stderr, logs the actual failure when gh api fails,
and only falls back to the empty-array path when the API truly returns no
associated PRs. Use the existing retry logic around pulls and the surrounding
publish-release workflow step to keep the behavior of result=false only for the
intended no-PR case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5edd9e20-11a7-4ff3-b72c-8ab41b89fcd7
📒 Files selected for processing (1)
.github/workflows/nodejs-publish-release.yml
This is a re-apply of #21 but based on
maininstead of thestablebranch asstableis managed by the release automation and will silently reset any manual changed upon a release.