ci: make typecheck-ratchet base collection robust (fix false positive)#49
Merged
Merged
Conversation
The base-baseline step ran `bun turbo typecheck` inside a detached `git worktree` with symlinked node_modules. turbo/tsgo produced no task output in that linked worktree (it has a `.git` *file*, not dir), so the base set came back empty and the ratchet flagged every real head error as "new" — failing Dockerfile-only / no-TS PRs (e.g. #48) with a misleading "introduces N new errors". The base step itself also died because collect-type-errors.sh's final grep exits 1 on zero matches. - Collect the base baseline by checking BASE out IN PLACE in the same working tree (reusing head's node_modules) instead of a linked worktree, so turbo behaves identically for base and head. Head's collector is copied to a temp path before checkout so the up-to-date collector runs even when BASE predates this fix. - collect-type-errors.sh: honor its documented "always exits 0" contract (the final grep exited 1 on no matches and, as the last command, failed the step under `bash -e`). Warn to stderr when the typecheck emitted no turbo task lines (i.e. it did not actually run). - Sanity gate: base=0 signatures while head>0 means base collection did not run — fail with a clear diagnostic instead of misreporting N "new" errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
The typecheck ratchet (#46) fails PRs that contain no TypeScript changes at all — e.g. the Dockerfile-only #48. Root cause is in the base-baseline collection, not the PRs:
bun turbo typecheckinside a detachedgit worktreewith symlinkednode_modules. turbo/tsgo produce no task output in a linked worktree (it has a.gitfile, symlinked deps), so the base baseline came back empty.collect-type-errors.sh's finalgrep … | sed | sort -uexits 1 when grep matches nothing — and as the script's last command that propagated out, failing the step underbash -e(contradicting the script's own "always exits 0" header contract).Evidence: on #48 the base step died in 1.5 s (far too fast for a real
tsgorun), while the head step — same repo, same script, run in the normal checkout — passed.Fix
git checkout --detach $BASE_SHAin the same working tree (reusing head's installednode_modules) instead of a linked worktree, so turbo behaves identically for base and head. Head's collector script is copied to$RUNNER_TEMPbefore the checkout, so the up-to-date collector runs even when BASE predates this fix.collect-type-errors.sh(|| true+ explicitexit 0), and warn to stderr when the typecheck emitted no turbo task lines (i.e. didn't actually run) — so a real tooling failure is visible instead of silently producing an empty baseline.base=0 && head>0means base collection didn't run → fail with a clear diagnostic rather than misreporting N "new" errors.Verification
bash -nclean; YAML parses (both jobs + all 6 ratchet steps intact).collect-type-errors.shwhere the typecheck can't run (nobun) now exits 0 and prints the "type checker did NOT run" diagnostic — previously it would exit 1 and fail the step..github/, so head and base TypeScript are identical → expected ratchet result is 0 new errors (and a non-empty base, so the new guard stays quiet).Follow-up
After merge, rebase #48 onto
collabso it re-runs against the fixed gate (also picks up #47) → its typecheck goes green.🤖 Generated with Claude Code