Skip to content

ci(sonar): resolve fork PR numbers for finalize - #117

Closed
cidrblock wants to merge 1 commit into
redhat-developer:mainfrom
cidrblock:ci/fix-sonar-fork-pr-resolve
Closed

ci(sonar): resolve fork PR numbers for finalize#117
cidrblock wants to merge 1 commit into
redhat-developer:mainfrom
cidrblock:ci/fix-sonar-fork-pr-resolve

Conversation

@cidrblock

Copy link
Copy Markdown
Collaborator

Summary

  • Sonar finalize has been failing on fork PRs with Unable to resolve a trusted PR number because workflow_run.pull_requests and commits/{sha}/pulls return empty for fork head SHAs.
  • Add a fallback that matches an open PR by headRefOid.

Test plan

Made with Cursor

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>
Copilot AI lite review requested due to automatic review settings August 13, 2026 13:02
@github-actions github-actions Bot added the chore label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cidrblock, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 72 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 347d4364-3b02-4cf6-acec-3dd8ca311d26

📥 Commits

Reviewing files that changed from the base of the PR and between b265a2f and ccb64f4.

📒 Files selected for processing (1)
  • .github/workflows/finalize.yml

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.

@cidrblock

Copy link
Copy Markdown
Collaborator Author

Opened from a stale fork main that lacked finalize.yml; recreating from upstream main.

Copilot AI 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.

Pull request overview

Adds a new finalize GitHub Actions workflow to run SonarCloud analysis after the CI workflow completes, with special handling to resolve PR metadata for fork-based pull requests.

Changes:

  • Introduces .github/workflows/finalize.yml triggered via workflow_run for CI completion.
  • Resolves PR number/base/head for fork PRs by falling back to matching an open PR via headRefOid (head commit SHA).
  • Creates/updates a dedicated sonar check run and runs the SonarCloud scan using coverage artifacts from the originating workflow run.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +10 to +15
permissions:
actions: read
checks: write
contents: read
pull-requests: read
statuses: write
Comment on lines +54 to +60
- name: Download coverage artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: sonar-coverage
path: packages/daemon/coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
Comment on lines +83 to +86
PR_NUMBER=$(gh pr list --repo "${REPO}" --state open --limit 100 \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"${HEAD_SHA}\") | .number" \
| head -n1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants