Repository navigation
Commit 8221e4a
committed
build(tck): check the spec submodule out at the pin before copying its assets
A rebase moves the gitlink and not the submodule's working tree. So a checkout
can hold a pin naming one revision and assets on disk from another, and nothing
in the build says so.
That is not hypothetical. Re-pinning the assets last pass and running the suite
copied the *previous* pin's Gherkin over the capability the suite had just been
given, because the rebase had moved the gitlink and `poe sync-spec-assets` copies
whatever is in the submodule working tree. The only thing that noticed was a
self-test comparing the capability enum against the packaged assets -- and that
guard fires for exactly one symptom, a declarable capability that no canonical
scenario carries. A pin that changes nothing but the content of a scenario passes
every guard in this package and still runs the wrong suite. The same root cause
in another language ran an entire adoption suite against stale assets and
reported byte-identical numbers to the run before it, with nothing failing and
nothing warning.
So `sync()` now brings the submodule to the revision the superproject's index
records before it copies anything, and `poe test` already depends on the sync:
the suite cannot run against assets it did not just check out. `git submodule
update` after a rebase stops being something an operator has to remember, which
is the part that was never going to hold.
The guarantee is narrower than Go's and the README says so rather than implying
otherwise. These assets reach the package by being copied, so a copy can always
be made wrong; what this buys is that the suite cannot run without a fresh sync
and a sync cannot succeed against any revision but the pinned one. Go consumes
the assets as a nested module out of a read-only, checksum-verified cache and has
no second artifact to go stale at all. The two fail differently.
The index rather than HEAD, because the index is what the next commit records and
so what a run is about to claim it tested against. If the update does not reach
the pinned revision -- the commit is not in the local object store and could not
be fetched -- nothing is copied and the build stops, naming the likely cause.
Nothing is written when the working tree is already at the pin, so the ordinary
path touches no git state.
Two ways out, both loud. OPENFEATURE_TCK_SPEC_UNPINNED=1 copies whatever is
checked out, for drafting a change to the canonical assets before there is a
revision to pin; it warns on every sync and names the revision it used. And where
the pin cannot be read at all the sync warns and continues: building from an
unpacked sdist is the ordinary case, with no repository, no pin and the assets
already in the tree, but so is a linked git worktree whose .git file names a path
outside the running process's filesystem namespace -- a Windows worktree driven
from WSL, where git answers inside the submodule and not in the superproject.
The guarantee genuinely is not in force there and the warning is what says so.
tests/test_spec_assets.py pins both halves. The decision is checked against a
scripted git: a working tree behind the pin is checked out and the checkout
confirmed, one already at the pin is left alone, a checkout that does not reach
the pin stops the build, and neither warning path issues an update. And the
invariant itself is checked against this very checkout -- the submodule HEAD
equals the pin -- which is the assertion that would have failed last pass. It
skips where no pin is readable, because there the guarantee is off and a pass
would say otherwise.
`hatch_build_sync.py` joins the mypy file list, and pytest gains `pythonpath` so
the tests can import it the way the build hook does.
Self-tests move from 208 passed / 41 skipped to 214 passed / 42 skipped: seven
new tests, one of which skips here because this checkout's pin is unreadable from
the shell the suite runs in.
Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>1 parent b518555 commit 8221e4a
4 files changed
Lines changed: 494 additions & 95 deletions
0 commit comments