Skip to content

fix(gh): deduplicate watched PR checks - #3542

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
uuzzrm:fix/gh-checks-watch-deduplicate
Sep 13, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
uuzzrm:fix/gh-checks-watch-deduplicate

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

gh pr checks --watch can append each polling snapshot when its output is captured instead of sent to a TTY. The formatter was counting every pass and fail row, so repeated snapshots inflated the totals.

This change parses the tab-separated check rows, keeps the latest status for each check identity, and summarizes the deduplicated results. Checks with the same name but different links remain separate, and the final failed rows are still shown.

Fixes #3541

Testing

  • cargo fmt --all --check
  • cargo clippy --all-targets
  • cargo test --bin rtk format_pr_checks (3 passed)
  • cargo run --quiet -- gh pr checks 3540 --repo rtk-ai/rtk

The full cargo test suite was also run. It produced 2,557 passing tests, with 16 existing process-test failures because their Unix command dependencies are unavailable in this Windows environment; none of those failures involve gh_cmd.rs.

@uuzzrm
uuzzrm force-pushed the fix/gh-checks-watch-deduplicate branch from e2cf6c6 to 656a864 Compare August 11, 2026 22:59
dev1abz added a commit to dev1abz/rtk that referenced this pull request Aug 12, 2026
`gh pr checks` spells a pending bucket `pending`, never `*`, and prints five
tab-separated fields with the description last. The transition test used a
shape gh does not emit; the new case carries the trailing description column
and a pending row that resolves across polls.

Co-Authored-By: Claude Opus 5 <[email protected]>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 of 3 — APPROVED, follow-up filed

Claim: dedupe gh pr checks --watch poll snapshots so each check is counted once, at its latest status.

Scope: accept (round 1, frozen). Two other open PRs touch gh_cmd.rs nearby — #1122 (the RunOptions line just above) and #4000 (the identifier parse inside pr_checks). Neither touches format_pr_checks, and both merge cleanly with this; #3542 can land independently.

Ran: real gh 2.46.0 locally and 2.100.0 in Docker, LC_ALL=C — green / red / live-pending / missing-PR / --required / --json / --watch, develop 5626e94a vs this PR merged onto it.

The decisive case is a live 25-poll --watch, captured against #3857 while its CI was actually running, so the pending→pass transitions are real rather than synthetic (347 lines, 30,794 B):

develop:  [ok] Passed: 254   [pending] Pending: 43     <- 11 checks
this PR:  [ok] Passed: 11    [FAIL] Failed: 0          <- correct

That is 99.8% against the 20% floor (CONTRIBUTING.md). Non-watch output is byte-identical to develop, exit codes 0/1/8 all propagate, and the error paths are unchanged.

CI @83f87f92: green.

Worth recording: the two earlier CI runs on 656a8640 showed as failure, but both had zero jobs and no logs — they were action_required runs that expired without ever executing. This PR had never been built. The fixup push created a fresh run, which I approved; that is the first real CI this branch has had.

Blocks merge (0, frozen at round 1)

Nothing. No content loss, no wrong answer, no regression against develop.

Optional — closed by fixup 83f87f92

The transition test used "Lint\t*\t\t…". Real gh spells a pending bucket pending, never *, and emits five tab-separated fields with the description last — I checked 92 real rows across 9 PRs plus the 347-line watch capture: zero *, zero empty link fields. The "*" arm itself is harmless dead code and I left it alone; the fixup only corrects the fixture and adds a case with the real five-field shape. Mutation-checked: disabling the dedup fails 3 of the 4 tests, the new one included.

Filed as follow-up

  • #4021 — format_pr_checks drops every bucket that is not pass/fail/pending, so skipping and cancelled rows vanish and the totals do not add up (real #3982: 8+2 reported for 15 checks). Pre-existing — the old substring implementation dropped the same rows, verified on #1122 — so it is not a regression here and does not hold this up. This PR is the natural base for the fix.

Checked and correct — no need to re-verify

  • Output format is byte-identical between gh 2.46.0 and 2.100.0, so the new exact-match parser is not brittle across versions.
  • --json is passed through untouched (has_json_flag routes it to passthrough at gh_cmd.rs:194) — confirmed by replaying real gh 2.100 JSON through both binaries.
  • Each of the three added tests bites under targeted mutation.

Hypotheses built and dropped

  • Format drift on newer gh — the exact-match parser looked brittle next to the old substring matching, but 2.100 emits the identical format.
  • Empty link field splitting one check into two entries across polls — 0 of 92 real rows have one.
  • Red PRs showing the fix — they cannot today: early_exit_on_failure sends a non-zero exit down the raw path, so the benefit on failing runs only appears once #1122 lands. Both are needed for the red case; neither blocks the other.

Next

Nothing — approving. Fixup 83f87f92 pushed: corrects the test fixtures to gh's real row shape and adds a five-field case.

Rounds: 1/3. Threads: 0 open, 0 resolved.

@KuSh
KuSh merged commit 0cd3eba into rtk-ai:develop Sep 13, 2026
11 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh pr checks --watch reports duplicated pass/fail counts when checks already finished

2 participants