Repository navigation
Pin /perf PR head to the trigger-time commit and gate the sticky comment - #899
Conversation
Resolve and pin the PR head SHA in an early step (before the .NET setup and PerfLib steps), then re-verify the fetched `pull/N/head` still equals that pinned SHA before creating the build worktree, so the benchmarked commit is the one that existed when the run was triggered. For comment triggers, reject a head whose commit post-dates the /perf comment. Publish perf-out/comment.md only when the benchmark step succeeded; on any non-success, synthesize the neutral fallback (overwriting whatever is on disk) so a leftover/partial file is never posted. Update tests/stress_perf/ci/README.md to match. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates the on-demand perf comparison workflow so /perf runs benchmark (and comment on) the exact PR head commit resolved at trigger time, and so the sticky PR comment is only published when a benchmark run completed successfully.
Changes:
- Add an early “Pin PR head SHA” step to resolve and record the PR head SHA immediately, with a best-effort guard for comment triggers where the head appears newer than the
/perfcomment. - Update PR worktree creation to fetch
refs/pull/N/headand hard-verify the fetchedFETCH_HEADstill matches the pinned SHA before building. - Gate sticky comment publishing on the benchmark step’s
outcome == success, otherwise overwrite with a neutral workflow-generated fallback.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/perf-compare.yml |
Pins PR head SHA at trigger time, verifies it before building, and only publishes perf-out/comment.md on successful benchmark completion. |
tests/stress_perf/ci/README.md |
Documents the pinned-head behavior and the success-gated sticky comment behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t gating in skill doc - perf-compare.yml: source the sticky-comment step's PR_NUMBER from the triggering event rather than steps.resolve.outputs, so the always() step can still post the fallback comment when 'Resolve PR' throws (e.g. the PR head advanced after /perf and the run is rejected before resolve emits its outputs). - perf-compare/SKILL.md: note that /perf publishes the rendered comparison only on a successful run and posts a neutral fallback otherwise. Co-authored-by: Copilot App <[email protected]>
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
Hemant Kumar (Hemantxk)
left a comment
There was a problem hiding this comment.
I see the CI.yml also captures SHA, but it captures it through HEAD_SHA: ${{ github.event.pull_request.head.sha }}, which seems to fetch right hash. Just curious would it be easier to follow the similar approach here?
|
Hemant Kumar (@Hemantxk) thanks! That works in
|
What
Two adjustments to
.github/workflows/perf-compare.ymlso a/perfrun always benchmarks — and comments on — exactly the commit that triggered it.1. Pin the PR head at trigger time
.NETsetup + PerfLib steps rather than resolving the head live several minutes later.pull/N/head, and re-verifies the fetched head still equals the pinned SHA (-cne) before creating the build worktree. If the branch moved on after the trigger, the step stops with an actionable message instead of building a different commit./perfcomment is rejected (best-effort on the commit-date lookup; the pinned-SHA re-verification is the hard check either way).workflow_dispatchkeeps working unchanged.2. Only publish a comment the benchmark actually produced
perf-out/comment.mdonly when the benchmark step''soutcome == success(the trusted script writes that file as the final action of a clean run). On any non-success it synthesizes the neutral fallback, overwriting whatever is on disk, so a leftover or incomplete file is never posted.Docs
tests/stress_perf/ci/README.mdupdated to describe the pinned-head resolution and the success-gated comment.Notes
perf-logsartifact.Validation