Make tsCodegenSampleCheck actually able to fail - #24
Merged
Conversation
`tsCodegenSampleCheck` read the "before" content in its task body, but sbt evaluates the `sampleCodegenRun.value` dependency before any of the body runs. Codegen had therefore already rewritten the file by the time `before` was read, so `before == after` always held: the gate was vacuous, and running the check destroyed the stale content instead of reporting it. Parameterise the codegen run on its output path (`sampleCodegenRunTo`) so the check can generate into a temp file and compare, leaving the committed sample untouched. `tsCodegenSample` keeps writing to `tsCodegenSampleFile`. Fixes #22 Co-Authored-By: Claude Opus 5 <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.
tsCodegenSampleCheckis the CI gate meant to fail whentypecheck/src/generated.tsis out of date. It could never fail:beforewas read in the task body, but sbt evaluates thesampleCodegenRun.valuedependency before any of the body runs — so codegen had already rewritten the file by the timebeforewas read, andbefore == afteralways held. Worse, running the check destroyed the stale content instead of reporting it, leavinggit statusclean.Fix
Parameterise the codegen run on its output path so the check generates into a temp file and compares, leaving the committed sample untouched:
tsCodegenSamplekeeps writing totsCodegenSampleFile. The now-unusedsampleCodegenRunkey is removed.Verification
Reproduced by deleting one real export from the committed sample:
[success][error] … is out of date — runsbt tsCodegenSampleand commit the resultgit statusafter checkM(untouched)Also confirmed the check passes on an up-to-date sample, and that
sbt tsCodegenSampleregenerates byte-identically to what is committed — so the sample onmainis genuinely current.Note
sbt cannot load this build inside a git worktree at all: sbt-git's bundled JGit throws
NoWorkTreeException: Bare Repository has neither a working tree, nor an indexon the.gitfile worktrees use. Pre-existing and unrelated to this change (adependencyOverridesJGit bump does not help — sbt-git resolves it on the meta-build classpath). Verification was therefore done against a plain clone. Possibly worth its own issue.Fixes #22
🤖 Generated with Claude Code