fix(ci): resolve fork PRs for recipe-evidence sticky comment#1297
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR updates the GitHub Actions workflow to fix PR detection for fork-originated pull requests. The "Resolve PR number from trusted workflow_run metadata" step now retrieves open PRs via paginated listing and matches them by comparing the PR head commit SHA and repository owner against workflow metadata. This replaces the previous approach that queried the commits API endpoint, which did not return PRs from forked repositories. The implementation includes pagination handling and jq injection safeguards by sourcing variable values through environment variables. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Comment |
Summary
Resolve the PR number for the recipe-evidence sticky comment by listing open PRs and matching on head SHA, so the comment posts on fork PRs instead of being silently skipped.
Motivation / Context
The comment workflow resolved the PR via
GET /repos/<base>/commits/{HEAD_SHA}/pulls. That endpoint does not reliably return fork-originated PRs — the head commit lives in the contributor's fork, not the base repo — so every external-contributor PR resolved to 0 matches and the comment was skipped with:Confirmed empirically:
commits/c3daa9f…/pullsonNVIDIA/aicrreturns[], yet PR #1295 (open, fromyuanchen8911) has exactly that commit as its head. Listing open PRs and matching.head.shafinds it.Fixes: N/A
Related: #1292 (companion fix: the upload step that produces the artifact this workflow consumes)
Type of Change
Component(s) Affected
.github/workflows/recipe-evidence-comment.yaml)Implementation Notes
commits/{sha}/pullslookup withgh api --paginate "…/pulls?state=open" --jqstreaming PR numbers, slurped into a JSON array withjq -s. This matches both same-repo and fork PRs uniformly.HEAD_SHA/HEAD_OWNERare read via jq'senv.rather than interpolated into the filter, so a hostile value can't break out of the jq expression. (gh's--jqdoesn't accept jq's--arg.)gh api --paginate --jq+ standalonejq -spattern rather thangh api --slurp, which isn't available in the pinnedgh.workflow_runevent (SHA + owner), never an artifact. The exactly-one-match guard and owner cross-check are unchanged.Testing
End-to-end validation requires a live fork PR run on GitHub. No Go code changed.
Risk Assessment
Rollout notes: N/A — takes effect on the next
recipes/**PR.Checklist
make testwith-race) — N/A, no Go changesgit commit -S)