Skip to content

ci: retry hra-release label check while PR list is empty - #22

Merged
cdunster merged 1 commit into
mainfrom
ci/19-npm-publish-randomly-ignores-the-release-label
Jul 2, 2026
Merged

ci: retry hra-release label check while PR list is empty#22
cdunster merged 1 commit into
mainfrom
ci/19-npm-publish-randomly-ignores-the-release-label

Conversation

@cdunster

@cdunster cdunster commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This is a re-apply of #21 but based on main instead of the stable branch as stable is managed by the release automation and will silently reset any manual changed upon a release.

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
@cdunster cdunster self-assigned this Jul 2, 2026
@cocogitto-bot

cocogitto-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

✔️ a4e7bf7 - Conventional commits check succeeded.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

The check job in the nodejs-publish-release.yml workflow was updated to introduce REPOSITORY and COMMIT_SHA environment variables and replace the previous single-attempt GitHub API label lookup with a retry loop (up to 5 attempts, 30-second delay) that only waits while zero PRs are associated with the commit. Once PRs are found, the script evaluates whether any associated PR carries the hra-release label and writes the boolean result to GITHUB_OUTPUT.

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
Loading

Suggested reviewers: jost-s, ThetaSinner

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: retrying the hra-release label check while the PR list is empty.
Description check ✅ Passed The description is related to the changeset and explains that this PR reapplies the earlier fix on top of main.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/19-npm-publish-randomly-ignores-the-release-label

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/nodejs-publish-release.yml (1)

51-51: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Real gh api failures 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 producing result=false without any signal of what actually went wrong.

Since publish is gated on this output (a false here is a no-op per publish-release.yml's note on hra-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

📥 Commits

Reviewing files that changed from the base of the PR and between 686ba4a and a4e7bf7.

📒 Files selected for processing (1)
  • .github/workflows/nodejs-publish-release.yml

@cdunster
cdunster requested a review from a team July 2, 2026 13:47
@cdunster
cdunster merged commit 569e2bb into main Jul 2, 2026
5 checks passed
@cdunster
cdunster deleted the ci/19-npm-publish-randomly-ignores-the-release-label branch July 2, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants