Skip to content

Fix Get-PrBuildIds.ps1 reporting SUCCESS while builds in progress#19313

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-get-prbuildids-success-status
Draft

Fix Get-PrBuildIds.ps1 reporting SUCCESS while builds in progress#19313
Copilot wants to merge 2 commits intomainfrom
copilot/fix-get-prbuildids-success-status

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Get-PrBuildIds.ps1 reports incorrect build states because gh pr checks returns one row per job (36+ for fsharp-ci), and Sort-Object -Unique picks an arbitrary row. If a completed job is selected, the build shows SUCCESS despite other jobs still running.

Changes

  • Replace deduplication with aggregation: Sort-Object -UniqueGroup-Object BuildId
  • Worst-case state calculation: FAILURE > IN_PROGRESS/QUEUED > SUCCESS
  • Add Detail field: Job count breakdown per state (e.g., "25 IN_PROGRESS, 1 QUEUED, 10 SUCCESS")
  • Clean URLs: Strip &view=logs&jobId=... to link to build overview

Example

Before:

Pipeline  BuildId State   Link
fsharp-ci 1297255 SUCCESS https://dev.azure.com/.../buildId=1297255&view=logs&jobId=abc

(Build actually had 25 IN_PROGRESS + 1 QUEUED + 10 SUCCESS)

After:

Pipeline  BuildId State       Detail                              Link
fsharp-ci 1297255 IN_PROGRESS 25 IN_PROGRESS, 1 QUEUED, 10 SUCCESS https://dev.azure.com/.../buildId=1297255
Original prompt

This section details on the original issue you should resolve

<issue_title>Get-PrBuildIds.ps1 reports SUCCESS while build is still in progress</issue_title>
<issue_description>## Bug

Get-PrBuildIds.ps1 can report State = SUCCESS for a build that is still running.

Root cause

The script calls gh pr checks which returns one row per job (e.g. 36 rows for fsharp-ci), all sharing the same buildId. It then deduplicates with Sort-Object -Property Pipeline, BuildId -Unique, which picks one arbitrary row. If that row happens to be a completed job (e.g. CheckCodeFormatting), the overall state shows SUCCESS even though 25 other jobs are still IN_PROGRESS.

File: .github/skills/pr-build-status/scripts/Get-PrBuildIds.ps1, final pipeline (~line 55):

} | Sort-Object -Property Pipeline, BuildId -Unique

Repro

  1. Open a PR that triggers fsharp-ci
  2. Wait until the Build stage finishes but test stages are still running
  3. Run: pwsh .github/skills/pr-build-status/scripts/Get-PrBuildIds.ps1 -PrNumber <PR>
  4. Observe State = SUCCESS even though Get-BuildInfo.ps1 -BuildId <id> shows Status = inProgress

Observed on PR #19309, build 1297255: script said SUCCESS, actual state was 10/36 SUCCESS + 25 IN_PROGRESS + 1 QUEUED.

Suggested fix

Replace the Sort-Object -Unique with a Group-Object BuildId and derive worst-case state per build:

$builds = $checks | Where-Object { $_.link -match "dev\.azure\.com" } | ForEach-Object {
    $buildId = if ($_.link -match "buildId=(\d+)") { $matches[1] } else { $null }
    $pipeline = ($_.name -split " ")[0]
    [PSCustomObject]@{
        Pipeline = $pipeline
        BuildId  = $buildId
        State    = $_.state
        Link     = $_.link
    }
} | Group-Object BuildId | ForEach-Object {
    $jobs = $_.Group
    $states = $jobs | Select-Object -ExpandProperty State -Unique
    $overall = if ($states -contains "FAILURE") { "FAILURE" }
               elseif ($states -contains "IN_PROGRESS" -or $states -contains "QUEUED") { "IN_PROGRESS" }
               else { "SUCCESS" }
    $first = $jobs | Select-Object -First 1
    [PSCustomObject]@{
        Pipeline = $first.Pipeline
        BuildId  = $first.BuildId
        State    = $overall
        Detail   = ($jobs | Group-Object State | ForEach-Object { "$($_.Count) $($_.Name)" }) -join ", "
        Link     = ($first.Link -replace "\&view=.*", "")
    }
}

This also trims the job-specific &view=logs&jobId=... suffix from the link so it points to the build overview.</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: F# agent
Generic agent for F# coding following the coding guidelines of F# from MsLearn


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… jobs

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Get-PrBuildIds.ps1 reporting SUCCESS while build is in progress Fix Get-PrBuildIds.ps1 reporting SUCCESS while builds in progress Feb 17, 2026
Copilot AI requested a review from T-Gro February 17, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Get-PrBuildIds.ps1 reports SUCCESS while build is still in progress

2 participants