-
Notifications
You must be signed in to change notification settings - Fork 542
CI: Hide comments when commit being built isn't the last commit in PR #23043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
foreach ($c in $prComments) { | ||
if ($c.Body.Contains($commentIdentifier)) { | ||
# This could be our comment or a previous one, but let's check if it's recent | ||
# We'll minimize any comment with our identifier that's from the bot and not already minimized | ||
if ($c.Author -eq "vs-mobiletools-engineering-service2" -and -not $c.IsMinimized) { | ||
Write-Host "Found recently posted comment to minimize: $($c.Id)" | ||
$this.MinimizeComments(@($c)) | ||
break | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a nicer variable name, rather than 'c' use 'comment'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 253edf5. Changed the variable name from 'c' to 'comment' in the foreach loop for better readability.
} | ||
} | ||
|
||
[void] HideNewlyPostedComment([int] $restCommentId, [string] $commentId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comprehensive documentation in commit 253edf5. The HideNewlyPostedComment method now has a synopsis with description and parameter documentation.
@@ -628,6 +684,65 @@ mutation { | |||
$response= Invoke-RestMethod -Uri $url -Headers $headers -Method "POST" -Body $body | |||
} # foreach | |||
} | |||
|
|||
[bool] IsCurrentCommitLatestInPR() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comprehensive documentation in commit 253edf5. The IsCurrentCommitLatestInPR method now has a synopsis with description and outputs documentation.
$result = $this.NewComment($msg) | ||
|
||
# If this commit is not the latest in the PR, hide this comment immediately | ||
if ($this.IsPR() -and -not $this.IsCurrentCommitLatestInPR()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use this if statement in several places, can you make it a function and reuse the logic rather than copy paste it over an over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored in commit 253edf5. Created two helper methods - HandlePreviousCommentHiding() and HandleNewCommentHiding() - to eliminate the duplicate conditional logic across all three NewCommentFrom* methods. This reduces code duplication and makes the logic easier to maintain.
…g, and extract duplicate logic Co-authored-by: mandel-macaque <2190086+mandel-macaque@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
✅ [CI Build #5583700] Build passed (Build packages) ✅Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
✅ [CI Build #5583700] Build passed (Detect API changes) ✅Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
✅ [CI Build #5583700] Build passed (Build macOS tests) ✅Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
💻 [CI Build #5583700] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This comment has been minimized.
This comment has been minimized.
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
💻 [CI Build #5583700] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
💻 [CI Build #5583700] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
✅ API diff for current PR / commit.NET ( No breaking changes )✅ API diff vs stable.NET ( No breaking changes )ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
💻 [CI Build #5583700] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
This PR implements the functionality to automatically hide CI comments when the commit being built is not the latest commit in the pull request, helping to keep PR conversations clean by only showing the most recent CI results.
Changes Made
New Methods Added
IsCurrentCommitLatestInPR()
- Checks if the current commit matches the head commit of the PR using the GitHub APIHideNewlyPostedComment()
- Helper method to find and minimize recently posted commentsModified Comment Posting Logic
Updated all comment posting methods (
NewCommentFromMessage
,NewCommentFromObject
,NewCommentFromFile
) to:Behavior Changes
Before: All CI comments were posted visibly, with previous comments always hidden when posting new ones.
After:
Example Scenarios
Testing
GitHub.Tests.ps1
The implementation ensures that users only see CI results for the most current state of their PR while still preserving all CI history in the hidden comments.
Fixes #23042.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/testorg/testrepo/commits/testhash/pulls
pwsh /tmp/test_module_import.ps1
(http block)www.powershellgallery.com
pwsh -Command Install-Module -Name Pester -Force -Scope CurrentUser
(dns block)pwsh -Command Set-PSRepository psgallery -InstallationPolicy trusted; Install-Module -Name Pester -Confirm:$false -Force
(dns block)pwsh -Command Get-PSRepository
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.