-
Notifications
You must be signed in to change notification settings - Fork 2k
Auto-apply s/agent-ready-for-rerun from the PR Review Queue workflow #36358
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
Open
kubaflo
wants to merge
21
commits into
main
Choose a base branch
from
feature/auto-rerun-labeler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c98bc94
Auto-apply s/agent-ready-for-rerun from the PR Review Queue workflow
Copilot 152406b
Grant pull-requests: write so the auto-label step can apply the label
Copilot a2fc3e9
Allow scanner to trigger reruns from autonomous queue labels
Copilot fb233b4
Harden auto-rerun labeler: per-PR error isolation, arg-passing, fetch…
Copilot 9b0a5aa
Auto-rerun labeler: single-source label metadata, fail-loud label fet…
Copilot f2cd01e
auto-rerun labeler: fail loud on gh api errors in activity/commit fet…
Copilot b60eadf
Merge remote-tracking branch 'origin/main' into feature/auto-rerun-la…
Copilot 5c53948
auto-rerun labeler: fix -Limit help default, fail-loud label re-read,…
Copilot 5b4acfe
Address review: verify-read regression, label-desc drift, redundant l…
Copilot 8d72e52
Fix autonomous-rerun daily flap on scanner skip (last-declined checkp…
Copilot fe99a54
Doc: note head-SHA-differs as qualifying rerun activity
Copilot 6b46aac
Surface gh api stderr in Get-IssueLabels on failure
Copilot 0fa7212
Make -ApplyLabel post-apply verification failure-tolerant
Copilot 2637ec3
Merge origin/main into feature/auto-rerun-labeler
kubaflo 620a7d9
Merge main into feature/auto-rerun-labeler
Copilot 5886164
Harden autonomous rerun candidate scanning
d4ed6b3
Make rerun tests hermetic in full suite
3a3c1ab
Make rerun decline lifecycle race-safe
1967d88
Address auto-rerun review feedback
9657be3
Handle concurrent rerun label creation
e60d765
Harden autonomous rerun queue handling
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env pwsh | ||
| #Requires -Modules Pester | ||
|
|
||
| BeforeAll { | ||
| $scriptPath = Join-Path $PSScriptRoot 'Query-RerunReadyPRs.ps1' | ||
| $outputDir = Join-Path $PSScriptRoot '../../CustomAgentLogsTmp/QueryRerunReadyTests' | ||
| New-Item -ItemType Directory -Force -Path $outputDir | Out-Null | ||
|
|
||
| . $scriptPath -Owner 'test-owner' -Repo 'test-repo' | ||
|
|
||
| function ConvertTo-GhLines { | ||
| param([object[]]$Items) | ||
| return @($Items | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress }) | ||
| } | ||
| } | ||
|
|
||
| AfterAll { | ||
| Remove-Item -LiteralPath $outputDir -Recurse -Force -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| Describe 'Query-RerunReadyPRs' { | ||
| BeforeEach { | ||
| $script:OutputPath = Join-Path $outputDir "$([Guid]::NewGuid().ToString('N')).json" | ||
| $script:issueComments = @( | ||
| [pscustomobject]@{ | ||
| id = 100 | ||
| body = "<!-- AI Summary -->`n<!-- SESSION:1111111 START -->" | ||
| created_at = '2026-05-31T09:00:00Z' | ||
| updated_at = '2026-05-31T09:00:00Z' | ||
| user = [pscustomobject]@{ login = 'MauiBot'; type = 'User' } | ||
| author_association = 'MEMBER' | ||
| }, | ||
| [pscustomobject]@{ | ||
| id = 200 | ||
| body = '/review rerun' | ||
| created_at = '2026-05-31T10:00:00Z' | ||
| updated_at = '2026-05-31T10:00:00Z' | ||
| user = [pscustomobject]@{ login = 'maintainer'; type = 'User' } | ||
| author_association = 'MEMBER' | ||
| } | ||
| ) | ||
|
|
||
| Mock Get-LatestReviewCommandOptions { | ||
| [pscustomobject]@{ | ||
| Platform = '' | ||
| PipelineRef = 'main' | ||
| CommentId = 200 | ||
| Body = '/review rerun' | ||
| } | ||
| } | ||
|
|
||
| Mock gh { | ||
| param( | ||
| [Parameter(ValueFromRemainingArguments = $true)] | ||
| [string[]]$GhArgs | ||
| ) | ||
|
|
||
| $command = $GhArgs -join ' ' | ||
| $global:LASTEXITCODE = 0 | ||
|
|
||
| if ($command -match '^pr list ') { | ||
| return ([pscustomobject]@{ | ||
| number = 1 | ||
| title = 'Autonomously queued PR' | ||
| url = 'https://example.test/1' | ||
| headRefOid = '2222222abcdef' | ||
| isDraft = $false | ||
| labels = @([pscustomobject]@{ name = 's/agent-ready-for-rerun' }) | ||
| author = [pscustomobject]@{ login = 'dev-user' } | ||
| } | ConvertTo-Json -Depth 10 -Compress) | ||
| } | ||
| if ($command -match '/issues/1/labels') { | ||
| return 's/agent-ready-for-rerun' | ||
| } | ||
| if ($command -match '/issues/1/comments') { | ||
| return ConvertTo-GhLines $script:issueComments | ||
| } | ||
| if ($command -match '/pulls/1/(reviews|comments|commits)') { | ||
| return @() | ||
| } | ||
|
|
||
| throw "Unexpected gh call: $command" | ||
| } | ||
| } | ||
|
|
||
| It 'does not reuse a historical rerun command as the current queue reaction target' { | ||
| Invoke-RerunReadyPRQuery ` | ||
| -QueryMaxPRs 5 ` | ||
| -QueryOwner 'test-owner' ` | ||
| -QueryRepo 'test-repo' ` | ||
| -QueryOutputPath $script:OutputPath | Out-Null | ||
|
|
||
| $result = Get-Content -Raw -LiteralPath $script:OutputPath | ConvertFrom-Json | ||
| $result.candidates.Count | Should -Be 1 | ||
| $result.candidates[0].reviewCommandId | Should -Be 200 | ||
| $result.candidates[0].rerunCommentId | Should -Be 0 | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.