Guards the package files: list against ADR-0009 - #73
Merged
Conversation
ADR-0009 makes `assets/` public API, published with the package, but
`mix.exs`'s `files:` list never named it. Nothing catches that: hex
prints what it packages and says nothing about what it omits, so the
first commit to ship JavaScript would have shipped it into a tarball
that silently left `assets/` out.
The entry itself cannot land yet - hex refuses to build a package whose
`files:` names a directory that is not on disk ("Missing files:
assets"), so listing it today would break `mix hex.publish` in order to
prevent a later breakage. The guard is conditional instead: a directory
an accepted ADR declares published must appear in `files:` once it
exists on disk. Adding the first file under `assets/` turns the test
red unless the same commit adds the entry.
Verified in all three states: absent and unlisted (green), present and
unlisted (red, naming the directory and the ADR), present and listed
(green).
Refs: sui-2ke
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.
Closes sui-2ke.
Provenance
Campaign 027, statifier-ui lane. Cut from
origin/mainat 7cbf911; onecommit, no rebase needed (origin/main had not moved at push time), so no
sibling conflict arose. A sibling sui worker may be live on
lib/anddocs/for the wire-format decisions; this branch touches neither.Files touched:
test/packaging_test.exs(new, 58 lines). Nothingelse -
mix.exsis deliberately unchanged, see below.What this is
ADR-0009 ("JavaScript ships as source") decides that this package's JS is
delivered as source under
assets/and that "assets/becomes publicAPI".
mix.exs'spackage()files:list has never named it. Hexpackages exactly what
files:names and reports nothing about what itleaves out, so the first commit to ship JavaScript would have shipped it
into a tarball that silently omitted
assets/, with the first symptombeing a host that cannot resolve the import.
Why the
files:entry is not in this PRThe bead's original fix was to add
assetstofiles:. Probed on thisbranch: hex refuses to build a package whose
files:names a directorythat is not on disk.
(hex 2.5.0, Elixir 1.18.3, OTP 27.3.
mix hex.publishshares that codepath.)
assets/does not exist yet, so adding the entry today would breakthe next release in order to prevent a later one. Committing a placeholder
assets/was the other option and is barred: ADR-0009 names no layout forthis package's own assets tree - every
assets/package.jsonin the recordis the host's file - so a placeholder would invent the first slice of a
declared-public-API surface, which is a contract call rather than a
packaging fix.
The bead was re-scoped to the guard only. The first JS ship (sui-wqr, or
the ADR-0008 elkjs renderer) adds the
files:entry alongside its firstreal asset, and this test is what makes forgetting it impossible.
The guard
test/packaging_test.exsasserts that every top-level directory anaccepted ADR declares published appears in
files:once it exists ondisk. The declared set is a tracked module attribute citing its record,
not something inferred from the filesystem, and a second test keeps that
list from being quietly emptied into a vacuous pass.
Verified in all three states:
assets/on diskfiles:The red case was produced by creating
assets/index.js, running the test,and removing it again; the green-green case by adding
assetstofiles:at the same time and reverting both. Neither probe is in the commit.
Changelog
No fragment.
changelog.d/README.mdexcludes "test harness or internaltest-support changes", and nobody calling the public API can tell the
difference - the packaged tarball is byte-identical to before this PR.
ADR
No ADR touch. The record already says everything the guard relies on
("
assets/becomes public API"); the test's own header comment carries thehex-refuses-a-missing-directory finding, which is a toolchain fact rather
than a decision.
Gate
Full
mix qualitygreen on this HEAD, attested (mix quality.verify,data.attested: true): 880 of 880 tests, 92.8% coverage, dialyzer clean,credo strict clean, doctor passed. The two
○lines are the permanentGettext and Sobelow skips declared in
gate.not_applicable_skips.