Skip to content

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

Merged
cidrblock merged 2 commits into
redhat-developer:mainfrom
cidrblock:ci/fix-sonar-fork-pr-resolve
Aug 13, 2026
Merged

ci(sonar): resolve fork PR numbers for finalize#118
cidrblock merged 2 commits 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: 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 @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: 78ae9ada-11bf-4424-bbe3-1512ae11ab5f

📥 Commits

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

📒 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.

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

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.

Comment thread .github/workflows/finalize.yml
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>
Copilot AI review requested due to automatic review settings August 13, 2026 13:14
cidrblock added a commit to cidrblock/abbenay that referenced this pull request Aug 13, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.00%. Comparing base (b265a2f) to head (c8dca47).

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
daemon 78.00% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

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. Using state=all keeps 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}"

@cidrblock

Copy link
Copy Markdown
Collaborator Author

merging this as it is blocking 113

@cidrblock
cidrblock merged commit 98cd5b4 into redhat-developer:main Aug 13, 2026
11 of 12 checks passed
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