-
Notifications
You must be signed in to change notification settings - Fork 851
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 -UniqueRepro
- Open a PR that triggers
fsharp-ci - Wait until the Build stage finishes but test stages are still running
- Run:
pwsh .github/skills/pr-build-status/scripts/Get-PrBuildIds.ps1 -PrNumber <PR> - Observe
State = SUCCESSeven thoughGet-BuildInfo.ps1 -BuildId <id>showsStatus = 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.
Metadata
Metadata
Labels
Type
Projects
Status