cli/pkg/cmd/pr/status/fixtures/prStatusChecks.json
Kynan Ware 1c274a8a56 fix(pr status): don't count cancelled checks as failures
When a GitHub Actions workflow uses concurrency with cancel-in-progress,
cancelled runs were counted as failures in `gh pr status` and
`gh pr view`, even when a newer run for the same check name succeeded.
The GitHub web UI and `gh pr checks` both handle this correctly.

Three changes fix this:

1. Add a `cancelled` check status category. Cancelled runs are now
   excluded from all summary counts (passing/failing/pending) and
   subtracted from the total, matching the web UI behavior.

2. Move `eliminateDuplicates` from pkg/cmd/pr/checks to
   `api.EliminateDuplicateChecks` (exported). The function operates
   entirely on `api.CheckContext` and is now shared by both `pr checks`
   and `ChecksStatus()` (used by `pr status` and `pr view`).

3. Apply deduplication in the `ChecksStatus()` slow path, keeping only
   the most recent run per check name — consistent with `pr checks`.

Fixes #12895

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 12:33:31 -06:00

177 lines
5 KiB
JSON

{
"data": {
"repository": {
"pullRequests": {
"totalCount": 0,
"edges": []
}
},
"viewerCreated": {
"totalCount": 4,
"edges": [
{
"node": {
"number": 8,
"title": "Strawberries are not actually berries",
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/8",
"headRefName": "strawberries",
"mergeable": "UNKNOWN",
"reviewDecision": "CHANGES_REQUESTED",
"statusCheckRollup": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"__typename": "StatusContext",
"context": "ci/build",
"state": "SUCCESS"
}
]
}
}
}
}
]
}
}
},
{
"node": {
"number": 7,
"title": "Bananas are berries",
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/7",
"headRefName": "banananana",
"reviewDecision": "APPROVED",
"baseRef": {
"branchProtectionRule": {
"requiredApprovingReviewCount": 0
}
},
"latestReviews": {
"nodes": [
{
"author": {
"login": "bob"
},
"state": "APPROVED"
},
{
"author": {
"login": "stella"
},
"state": "CHANGES_REQUESTED"
},
{
"author": {
"login": "alice"
},
"state": "APPROVED"
}
]
},
"statusCheckRollup": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"__typename": "CheckRun",
"name": "build",
"status": "IN_PROGRESS",
"conclusion": ""
}
]
}
}
}
}
]
}
}
},
{
"node": {
"number": 6,
"title": "Avocado is probably not a berry",
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/6",
"headRefName": "avo",
"mergeable": "MERGEABLE",
"reviewDecision": "REVIEW_REQUIRED",
"statusCheckRollup": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"__typename": "CheckRun",
"name": "build",
"status": "IN_PROGRESS",
"conclusion": ""
},
{
"__typename": "StatusContext",
"context": "ci/deploy",
"state": "FAILURE"
},
{
"__typename": "CheckRun",
"name": "lint",
"status": "COMPLETED",
"conclusion": "NEUTRAL"
}
]
}
}
}
}
]
}
}
},
{
"node": {
"number": 5,
"title": "Why can't berries get along?",
"state": "OPEN",
"url": "https://github.com/cli/cli/pull/5",
"headRefName": "strawberries",
"mergeable": "CONFLICTING",
"statusCheckRollup": {
"nodes": [
{
"commit": {
"statusCheckRollup": {
"contexts": {
"nodes": [
{
"__typename": "StatusContext",
"context": "ci/build",
"state": "SUCCESS"
}
]
}
}
}
}
]
}
}
}
]
},
"reviewRequested": {
"totalCount": 0,
"edges": []
}
}
}