ci: find fork PRs for benchmark comments#139
Draft
yangzhg wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Improves the benchmark comment workflow’s ability to locate the correct pull request for forked PR workflow runs and reliably wait for the benchmark artifact before commenting, failing fast with clear errors when discovery fails.
Changes:
- Add multi-strategy PR discovery: workflow_run payload → PRs by commit → PRs by
head_owner:head_branch. - Add polling for the
benchmark-compareartifact to handle eventual consistency before posting. - Switch from “skip silently” behavior to “fail workflow with message” when PR/artifact can’t be found.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+89
to
93
| const pr = await findPullRequest(); | ||
| if (!pr) { | ||
| core.setOutput('skip', 'true'); | ||
| core.setFailed(`Unable to find PR for workflow_run ${run.id} (${run.head_sha}).`); | ||
| return; | ||
| } |
Comment on lines
+71
to
+85
| async function findBenchmarkArtifact() { | ||
| const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
| for (let attempt = 1; attempt <= 12; ++attempt) { | ||
| const artifacts = await github.paginate( | ||
| github.rest.actions.listWorkflowRunArtifacts, | ||
| {owner, repo, run_id: run.id}); | ||
| const artifact = artifacts.find((item) => | ||
| item.name === 'benchmark-compare' && !item.expired); | ||
| if (artifact) { | ||
| core.info(`Found benchmark artifact ${artifact.id}.`); | ||
| return artifact; | ||
| } | ||
| core.info(`benchmark-compare artifact not visible yet; attempt ${attempt}/12.`); | ||
| await sleep(10000); | ||
| } |
| const artifact = await findBenchmarkArtifact(); | ||
| if (!artifact) { | ||
| core.setOutput('skip', 'true'); | ||
| core.setFailed(`Unable to find benchmark-compare artifact for workflow_run ${run.id}.`); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #139 +/- ##
=======================================
Coverage 69.67% 69.67%
=======================================
Files 27 27
Lines 3706 3706
Branches 1189 1189
=======================================
Hits 2582 2582
Misses 211 211
Partials 913 913 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
edb68e4 to
5ad6b6b
Compare
5ad6b6b to
107e5ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
head_owner:head_branchwhenworkflow_run.pull_requestsand commit association are empty for fork PRs.benchmark-compareartifact before posting, and fail the comment workflow with a concrete message if PR/artifact discovery still fails.Why
Fork PRs can produce a benchmark artifact while the privileged
workflow_runcomment job cannot resolve the PR through the original lookup paths. That made the benchmark comment workflow succeed without posting a comment.Validation
git diff --checkcheck yamlpassedhead=yangzhg:gcc-compatwhile commit association returns no PR.