ci(sonar): resolve fork PR numbers for finalize - #118
Conversation
workflow_run.pull_requests and commits/{sha}/pulls are empty for fork PR
heads, so Sonar never re-analyzed those PRs. Fall back to matching an open
PR by headRefOid.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
Next review available in: 60 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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.
Pull request overview
Fixes SonarCloud “finalize” workflow failures for fork-based pull requests by improving how the workflow derives a trusted PR number from the workflow_run context when GitHub APIs don’t link the fork head SHA to a PR.
Changes:
- Adds a fallback PR-number resolution path that matches an open PR by
headRefOid(head commit OID) when the existing resolution methods return empty.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Avoid listing open PRs with a limit/head -n1. Use the pulls API head filter from trusted workflow_run metadata and require exactly one OID match. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #118 +/- ##
==========================================
- Coverage 78.02% 78.00% -0.03%
==========================================
Files 38 38
Lines 4979 4979
Branches 1569 1569
==========================================
- Hits 3885 3884 -1
Misses 542 542
- Partials 552 553 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/workflows/finalize.yml:97
- The fork-PR fallback only queries
state=open. If the PR is merged/closed between the upstream workflow finishing and this finalize job running, this lookup will return 0 results and fail even though the commit still maps to a PR. Usingstate=allkeeps the SHA-based disambiguation while avoiding that race.
"repos/${REPO}/pulls?state=open&head=${HEAD_OWNER}:${HEAD_BRANCH}" \
--jq "[.[] | select(.head.sha == \"${HEAD_SHA}\") | .number]")
MATCH_COUNT=$(jq 'length' <<< "${MATCHES}")
if [[ "${MATCH_COUNT}" -ne 1 ]]; then
echo "::error::Expected exactly one open PR for ${HEAD_OWNER}:${HEAD_BRANCH}@${HEAD_SHA}, found ${MATCH_COUNT}: ${MATCHES}"
|
merging this as it is blocking 113 |
Summary
Unable to resolve a trusted PR numberbecauseworkflow_run.pull_requestsandcommits/{sha}/pullsreturn empty for fork head SHAs.headRefOid.Test plan
Made with Cursor