Skip to content

ci: find fork PRs for benchmark comments#139

Draft
yangzhg wants to merge 1 commit into
bytedance:masterfrom
yangzhg:benchmark-comment-fork-pr
Draft

ci: find fork PRs for benchmark comments#139
yangzhg wants to merge 1 commit into
bytedance:masterfrom
yangzhg:benchmark-comment-fork-pr

Conversation

@yangzhg
Copy link
Copy Markdown
Collaborator

@yangzhg yangzhg commented May 12, 2026

Summary

  • Find benchmark target PRs by head_owner:head_branch when workflow_run.pull_requests and commit association are empty for fork PRs.
  • Poll for the benchmark-compare artifact 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_run comment job cannot resolve the PR through the original lookup paths. That made the benchmark comment workflow succeed without posting a comment.

Validation

Copilot AI review requested due to automatic review settings May 12, 2026 03:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-compare artifact 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);
}
Comment thread .github/workflows/benchmark_comment.yml Outdated
const artifact = await findBenchmarkArtifact();
if (!artifact) {
core.setOutput('skip', 'true');
core.setFailed(`Unable to find benchmark-compare artifact for workflow_run ${run.id}.`);
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.67%. Comparing base (92964a8) to head (107e5ba).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yangzhg yangzhg force-pushed the benchmark-comment-fork-pr branch from edb68e4 to 5ad6b6b Compare May 12, 2026 03:27
@yangzhg yangzhg force-pushed the benchmark-comment-fork-pr branch from 5ad6b6b to 107e5ba Compare May 12, 2026 03:30
@yangzhg yangzhg marked this pull request as draft May 12, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants