[build] Hide stale build failure comment when a re-run succeeds#26012
[build] Hide stale build failure comment when a re-run succeeds#26012rolfbjarne wants to merge 1 commit into
Conversation
After 6d24fb6 we stopped posting a comment on successful builds. But this had a side effect: if a build first fails (posting a 'Build failed' comment) and then passes on a re-run, the stale failure comment was never hidden. Now the 'Report build result' step hides any previous build failure comment for the same job when the build succeeds, instead of just skipping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR fixes a CI UX regression in the Azure Pipelines “Report build result” step: when a job failed once (posting a “Build failed” PR comment) and then succeeded on a re-run for the same commit, the old failure comment remained visible and misleading.
Changes:
- On successful job completion, initialize the GitHub comments helper and call
HandlePreviousCommentHiding("build $(System.JobDisplayName)")before returning. - Keep the existing behavior of not posting a “Build passed” comment on success, while still cleaning up any stale prior failure comment for the same job.
- Leave the failure path unchanged (still posts a “Build failed” comment with the same comment id).
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #c8f354f] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 199 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Since 6d24fb6 ([build] Only report build failures, not successes) we stopped posting a comment on successful builds. That introduced a side effect: if a build first fails (posting a "Build failed" comment) and then passes on a re-run of the same commit, the stale failure comment was never hidden, leaving misleading output on the PR.
The reason is that hiding previous same-id comments only happened inside
NewCommentFromMessage(viaHandlePreviousCommentHiding), which the success path now skips by returning early.This change makes the "Report build result" step, on success, call
$githubComments.HandlePreviousCommentHiding("build $(System.JobDisplayName)")before returning. That hides any previous build failure comment for the same job while still not posting a new "Build passed" comment. The existing safeguards apply: comments are only hidden when the current commit is the latest in the PR, and nothing happens when not running in a PR context.🤖 Pull request created by Copilot