fix(gh): classify pr checks by status column, not name substring#2796
Open
john-chen-opus wants to merge 1 commit into
Open
fix(gh): classify pr checks by status column, not name substring#2796john-chen-opus wants to merge 1 commit into
john-chen-opus wants to merge 1 commit into
Conversation
`format_pr_checks` matched pass/fail/pending as a substring anywhere in the row, so a check whose NAME contains those words (e.g. "compass-audit", "fail-fast smoke") was miscounted, and skipping/cancelled checks were dropped entirely — the summary's counts silently disagreed with the real PR. Classify on the tab-separated status column instead, fold skipped/cancelled into the totals, and lead with `passed/total` so the counts reconcile. When no row parses (e.g. "no checks reported on the '<branch>' branch"), return empty so the caller falls back to gh's raw message instead of a misleading "0 passed" summary. Adds unit tests for name-substring, skip reconciliation, and the empty/fallback path.
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
format_pr_checks(thertk gh pr checkssummarizer) classifies each row with a whole-line substring test:gh pr checksprints tab-separated rows —<name>\t<bucket>\t<elapsed>\t<url>— so matching the whole line has two correctness bugs:compass-auditorfail-fast smokecontainspass/failas a substring and gets miscounted regardless of its real bucket.skippingandcancel(ed)checks are dropped entirely. They match none of the three branches, so they vanish from the summary — the printed counts silently disagree with the real PR. (On a PR whose only non-passing checks are change-gated skips,ghstill exits 0, so this summary is what the agent sees.)This bit me while shipping an unrelated change: the summary disagreed with the actual check set, and the empty-checks case surfaced as a confusing "0 passed" rather than gh's real message.
Fix
Classify on the tab-separated status column, not a whole-line substring:
starts_with(absorbsskipping/skipped,cancel/canceled/cancelled).skippedandcancelledinto the totals (cancelled surfaces with failures —gh's own rollup exits non-zero for it).passed/totalso the counts reconcile — skipped/pending checks are part of the total, never silently dropped.no checks reported on the '<branch>' branch), return empty so the caller falls back togh's raw output instead of inventing a misleading0 passedsummary.This aligns with the design philosophy in CONTRIBUTING.md:
Tests
Added three unit tests in
gh_cmd.rs:test_format_pr_checks_classifies_by_bucket_not_name— names containingpass/failare classified by their status column;test_format_pr_checks_reconciles_total_with_skips—1 pass + 2 skipsreports1/3with skips surfaced;test_format_pr_checks_empty_falls_back_to_raw— empty / "no checks reported" → empty (raw fallback).Local:
cargo fmt --checkclean,cargo clippy --bin rtkclean (only a pre-existing rusqlite future-incompat note),cargo test --bin rtk cmds::git::gh_cmd→ 69 passed.