BM publish version: the build modules' bundle asks name the ask's version, as the SDK now refuses one without

A bundle publishes under the version its ask reserved, and the delivery SDK's
publish refuses an empty one loudly; the tests' bundle asks carry a version, a
bundle asked with none is shown refused, and an archive still publishes by its
digest alone.

Builds: design 47 H2 H-A-373, H-A-373 addendum
This commit is contained in:
2026-11-22 01:50:30 +01:00
parent d3d9ff5183
commit 22b92b827d
10 changed files with 56 additions and 31 deletions
@@ -117,7 +117,7 @@ func TestTheFixturePassesTheUnitLevelAndBuildsTwiceToOneDigest(t *testing.T) {
}
var digests []string
for _, id := range []string{"w1", "w2"} {
out, err := m.build(context.Background(), map[string]any{"workspace": id, "module": "modules/m", "artifact": "tools"})
out, err := m.build(context.Background(), map[string]any{"workspace": id, "module": "modules/m", "artifact": "tools", "version": askedVersion})
if err != nil {
t.Fatal(err)
}
@@ -55,8 +55,13 @@ func esbuildEffect(t *testing.T) func(c call) {
}
}
// askedVersion is the version a test's bundle ask reserved: every bundle publishes under the ask's version, and the
// delivery SDK refuses one that names none (design 47 H, H-A-373).
const askedVersion = "1.4.3"
// buildArgs is a bundle's build ask, under the version the ask reserved.
func buildArgs() map[string]any {
return map[string]any{"workspace": "w1", "module": "modules/m", "artifact": "tools"}
return map[string]any{"workspace": "w1", "module": "modules/m", "artifact": "tools", "version": askedVersion}
}
func builtMachine(t *testing.T, extra string) (*Module, *fakeMachine, string) {
@@ -309,11 +314,13 @@ func TestTheBundleBuildGetsTheVersionTheAskCarriesAsMeshVersion(t *testing.T) {
for _, version := range []string{"1.4.3", ""} {
m, f, _ := builtMachine(t, "")
args := buildArgs()
if version != "" {
args["version"] = version
args["version"] = version
if version == "" {
delete(args, "version")
}
if _, err := m.build(context.Background(), args); err != nil {
t.Fatal(err)
// A bundle asked with no version is built with none, and its publish refused loudly (H-A-373).
if _, err := m.build(context.Background(), args); (err != nil) != (version == "") || err != nil && !strings.Contains(err.Error(), "names no version") {
t.Fatalf("ask version %q: %v", version, err)
}
for _, c := range f.calls {
got := ""
@@ -336,11 +343,13 @@ func TestTheBundleCarriesTheAsksVersionInItsPackageJSON(t *testing.T) {
m, f, work := builtMachine(t, "")
workspaceWith(t, work, map[string]string{"modules/m/package.json": `{"name":"m","version":"0.0.0"}`})
args := buildArgs()
if c.version != "" {
args["version"] = c.version
args["version"] = c.version
if c.version == "" {
delete(args, "version")
}
if _, err := m.build(context.Background(), args); err != nil {
t.Fatal(err)
// A bundle asked with no version keeps the package.json's, and its publish is refused loudly (H-A-373).
if _, err := m.build(context.Background(), args); (err != nil) != (c.version == "") || err != nil && !strings.Contains(err.Error(), "names no version") {
t.Fatalf("ask version %q: %v", c.version, err)
}
_ = f
raw, err := os.ReadFile(filepath.Join(work, "w1", "stage-tools", "modules", "module", "package.json"))
@@ -106,7 +106,6 @@ func TestADoneBundleAnswersTheReferenceOfTheArchiveItPushed(t *testing.T) {
m, _, _ := builtMachine(t, ``)
store := withStore(t, m)
args := buildArgs()
args["version"] = "1.4.3"
out, err := m.build(context.Background(), args)
if err != nil {
t.Fatal(err)
@@ -96,7 +96,7 @@ func TestADoneBundleResolvesInARealArtifactStore(t *testing.T) {
needBubblewrap(t)
m, _ := realMachine(t)
addr := realStore(t, m)
out, err := m.build(context.Background(), map[string]any{"workspace": "w1", "module": "modules/m", "artifact": "tools"})
out, err := m.build(context.Background(), map[string]any{"workspace": "w1", "module": "modules/m", "artifact": "tools", "version": askedVersion})
if err != nil {
t.Fatal(err)
}