fix(ci): plumb expected version through env so smoke-windows passes reliably#160
Merged
Merged
Conversation
Smoke-test was reading expected version from package.json on disk.
Worked in build-* jobs because their `Inject version` step bumps
package.json in the same runner before smoke runs. Broke in
smoke-windows: that job is on a separate Windows runner (the .exe is
cross-built on Linux and can't execute there), does a fresh
actions/checkout at the tag ref, and has no `Inject version` step —
so package.json on its disk still holds whatever value was committed
at the tagged commit. When the tag's commit didn't pre-bump
package.json (no chore(release): vX.Y.Z), the binary reported the
injected version while smoke-windows compared against the stale
committed string and failed.
Fix: have smoke-test prefer `STRUCPP_EXPECTED_VERSION` env var over
the package.json fallback, and have every smoke step in release.yml
export `${{ needs.prepare.outputs.version }}` into that env. The
prepare job derives the version from `github.ref_name` (stripping
the leading `v`), so it's the same source of truth all build jobs
feed into `npm version`. smoke-windows now also lists `prepare` in
its `needs:` array to access that output.
Side benefit: the assertion now actually tests what it claims to
test ("the binary reports the version we asked the pipeline to
build"), not "the binary version matches whatever npm version
happened to mutate package.json to" (which was a tautology in every
build-job smoke step).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 task
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.
Summary
The smoke-test reads its expected version from
package.jsonon disk. This works in thebuild-*jobs (theInject versionstep bumps package.json on the same runner before smoke runs) but breaks insmoke-windows: that job is on a separate Windows runner because the Windows binary is cross-built on Linux and can't execute there. It does a freshactions/checkout@v4at the tag ref with noInject versionstep, so itspackage.jsonstill holds whatever was committed at the tagged commit. If the tag's commit didn't pre-bump package.json (nochore(release): vX.Y.ZPR), the binary correctly reports the injected version whilesmoke-windowscompares against the stale committed string and fails.This is exactly what happened on the first attempt at v0.5.1 — binary reported
0.5.1, package.json on Windows runner still said0.5.0, smoke failed, release aborted.Fix
scripts/smoke-test.mjs— preferSTRUCPP_EXPECTED_VERSIONenv var over thepackage.jsonfallback. Logs which source the version came from for traceability..github/workflows/release.yml— every smoke step exportsSTRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}. Thepreparejob derives this value once fromgithub.ref_name(strippingv), so it's the same source of truth all build jobs feed intonpm version.smoke-windowsnow also listspreparein itsneeds:array to access the output.The
Inject versionsteps in the build jobs stay — they're still load-bearing for baking the version into the bundle/binary itself. They're just no longer the only way smoke-test learns what version to expect.Validation plan
Once merged to development and main, v0.5.2 will be tagged WITHOUT a preceding
chore(release): v0.5.2bump. That's the explicit test: with package.json still saying0.5.1at the tag commit, the build jobs will inject0.5.2into their package.json copies and bake0.5.2into the binary, andsmoke-windowswill compare its fresh-checkout binary againstSTRUCPP_EXPECTED_VERSION=0.5.2rather than the stale0.5.1from disk. If that passes, the fix is verified end-to-end.Side benefit
The assertion now actually tests what it claims to test ("the binary reports the version we asked the pipeline to build"), not "the binary version matches whatever
npm versionhappened to mutate package.json to in the same runner" (which was a tautology in every build-job smoke step).Test plan
🤖 Generated with Claude Code