Compare commits

...
1 Commits
Author SHA1 Message Date
jschoubben 051a10d14b The composer cache key covers the mesh package versions the compose ask names (issue 1921)
mesh/delivery ready: it is merged on the Approve
mesh/check pass 051a10d14b99 on bc4d43b508cf | judged by the candidate's mesh-build-go at ca0bf3816539
mesh/delivery-group group fix/1921-zero-version-builds ready: every member ready, and composed together they pass
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
2026-11-06 01:52:05 +01:00
2 changed files with 36 additions and 4 deletions
@@ -50,7 +50,11 @@ func (m *Module) compose(ctx context.Context, fetch buildstep.StepFunc, a delive
if err != nil {
return nil, err
}
key := delivery.ComposerKey(repository, commit, job.Dir, job.Package, delivery.ToolchainUsed{Version: installed, Recipe: m.Recipe.Version()})
versions, err := sdkstep.PackagesArg(job.Fetch["packages"])
if err != nil {
return nil, buildstep.Refuse("the compose ask %s: %v", a.ID, err)
}
key := delivery.ComposerKey(repository, commit, job.Dir, job.Package, delivery.ToolchainUsed{Version: installed, Recipe: m.Recipe.Version()}, versions)
exe, built, err := m.composerOf(ctx, fetch, job, key)
if err != nil {
return nil, err
@@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"errors"
"os"
"path/filepath"
"slices"
@@ -64,7 +65,7 @@ func TestAKeptComposerIsRunWithTheManifestsFilled(t *testing.T) {
read, digests := indexerHolds(t, `{"module":"demo","version":"1"}`)
m.ReadManifest = read
a := composeAskOf(t, digests[0])
key := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()})
key := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()}, nil)
exe := m.composerPath(key)
if err := os.MkdirAll(filepath.Dir(exe), 0o700); err != nil {
t.Fatal(err)
@@ -95,13 +96,40 @@ func TestAKeptComposerIsRunWithTheManifestsFilled(t *testing.T) {
}
}
// 1921: the versions an ask names are an input of the composer it builds, so a composer kept for one set is not run for
// another; an ask naming none keeps the key it always had.
func TestAComposerIsKeptPerAskedVersions(t *testing.T) {
m := composeModule(t)
m.ReadManifest, _ = indexerHolds(t)
a := composeAskOf(t, "feedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeed")
tc := delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()}
plain := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, tc, nil)
a.Compose.Fetch["packages"] = map[string]any{"git.novox.be/novox/mesh-sdk/go": strings.Repeat("3", 40)}
named := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, tc, delivery.PackageVersions{"git.novox.be/novox/mesh-sdk/go": strings.Repeat("3", 40)})
if plain == named {
t.Fatal("the key ignores the versions")
}
// A composer kept under the key without versions is not used for the ask that names some: it is fetched.
os.MkdirAll(filepath.Dir(m.composerPath(plain)), 0o700)
os.WriteFile(m.composerPath(plain), []byte("#!/bin/sh\nexit 0\n"), 0o700)
fetched := false
fetch := func(context.Context, map[string]any) (any, error) {
fetched = true
return nil, errors.New("stop")
}
m.compose(context.Background(), fetch, a)
if !fetched {
t.Error("a composer built for no versions was run for an ask naming some")
}
}
// 1622: a manifest the indexer does not keep fails the ask, naming its digest; a fetched commit with no go.mod where
// the ask builds fails it naming the directory, and its workspace is released.
func TestAComposeAskFailsLoudly(t *testing.T) {
m := composeModule(t)
m.ReadManifest, _ = indexerHolds(t)
a := composeAskOf(t, "feedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeedfeed")
key := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()})
key := delivery.ComposerKey("novox/mesh-sdk", composeCommit, "go", composer.Package, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()}, nil)
os.MkdirAll(filepath.Dir(m.composerPath(key)), 0o700)
os.WriteFile(m.composerPath(key), []byte("#!/bin/sh\nexit 0\n"), 0o700)
if _, err := m.compose(context.Background(), nil, a); err == nil || !strings.Contains(err.Error(), "feedfeed") {
@@ -168,7 +196,7 @@ func TestAComposeAskBuildsTheNodeEnginesComposerAtItsRoot(t *testing.T) {
t.Fatal(err)
}
ans := out.(delivery.ComposeAnswer)
key := delivery.ComposerKey("novox/mesh-host", composeCommit, delivery.RootPath, nodeEngineComposer, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()})
key := delivery.ComposerKey("novox/mesh-host", composeCommit, delivery.RootPath, nodeEngineComposer, delivery.ToolchainUsed{Version: "go1.26.0", Recipe: m.Recipe.Version()}, nil)
var v composer.Verdict
if err := json.Unmarshal(ans.Verdict, &v); err != nil {
t.Fatal(err)