From e1aab8a8922028ac8699a404a0186111ccab6058 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 6 Nov 2026 01:41:41 +0100 Subject: [PATCH] The composer test lays every repository beside the check as one workspace, as the group places the composer (issue 1966) Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i --- .../mesh-build-go/compose_integration_test.go | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/compose_integration_test.go b/modules/mesh-build-go/cmd/mesh-build-go/compose_integration_test.go index 4bee95dbf..3d36d7bae 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/compose_integration_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/compose_integration_test.go @@ -25,12 +25,14 @@ import ( ) // nodeEngineTree is the node-engine's repository as the checker places it beside this check (MESH_CHECK_BESIDE, the -// repository mesh-host), and sdkBeside mesh-sdk's Go module there when it is placed too (a group that changes it). The test +// repository mesh-host), and with it every Go module of the other repositories placed there (mesh-sdk, mesh-contracts, +// mesh-delivery, mesh-networking: the node-engine's composer requires them at the zero version, so they resolve from the +// workspace as the group lays them, wherever the composer lives). The test // builds the node-engine's real composer command from that tree; it does not stand one in. With no beside directory it // fails, and with the node-engine beside but no composer command in it it fails: a composer test that could not build its // composer proves nothing. With a beside directory that holds no node-engine at all it skips aloud (NOT JUDGED), since a // checker from before this release places none for the catalogue. -func nodeEngineTree(t *testing.T) (tree, sdk string) { +func nodeEngineTree(t *testing.T) (tree string, modules []string) { t.Helper() beside := os.Getenv("MESH_CHECK_BESIDE") if beside == "" { @@ -45,10 +47,32 @@ func nodeEngineTree(t *testing.T) (tree, sdk string) { if _, err := os.Stat(filepath.Join(tree, "cmd", "mesh-compose")); err != nil { t.Fatalf("NOT CHECKED: the node-engine's composer command is not beside this check in MESH_CHECK_BESIDE=%s: %v", beside, err) } - if dir := filepath.Join(beside, "mesh-sdk", "go"); dirExists(dir) { - sdk = dir + entries, err := os.ReadDir(beside) + if err != nil { + t.Fatal(err) } - return tree, sdk + for _, e := range entries { + if e.Name() == "mesh-host" || !dirExists(filepath.Join(beside, e.Name())) { + continue + } + root, err := filepath.EvalSymlinks(filepath.Join(beside, e.Name())) + if err != nil { + t.Fatal(err) + } + filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error { + if err != nil { + return nil + } + if d.IsDir() && (d.Name() == ".git" || d.Name() == "testdata" || d.Name() == "node_modules") { + return filepath.SkipDir + } + if !d.IsDir() && d.Name() == "go.mod" { + modules = append(modules, filepath.Dir(p)) + } + return nil + }) + } + return tree, modules } func dirExists(p string) bool { st, err := os.Stat(p); return err == nil && st.IsDir() } @@ -123,7 +147,7 @@ func TestAComposeAskIsBuiltOnceAndAnsweredOnTheBus(t *testing.T) { m.Run = StepRunner(t.TempDir()) m.GoModCache = goEnvOf(t, "GOMODCACHE") // the module cache this module's own build filled, read and not fetched run, gocache := m.Run, goEnvOf(t, "GOCACHE") // this machine's build cache, so the composer's packages compile once - hostTree, sdkDir := nodeEngineTree(t) + hostTree, beside := nodeEngineTree(t) workFile := "" m.Run = func(ctx context.Context, env []string, name string, args ...string) forgekey.Ran { env = append(env, "GOCACHE="+gocache) @@ -147,8 +171,8 @@ func TestAComposeAskIsBuiltOnceAndAnsweredOnTheBus(t *testing.T) { return nil, err } copyHostTree(t, hostTree, tree) - if sdkDir != "" { // the group's mesh-sdk head, laid beside the node-engine's tree as one workspace - work := "go 1.26.0\n\nuse (\n\t" + tree + "\n\t" + sdkDir + "\n)\n" + if len(beside) > 0 { // the group's other repositories, laid beside the node-engine's tree as one workspace + work := "go 1.26.0\n\nuse (\n\t" + tree + "\n\t" + strings.Join(beside, "\n\t") + "\n)\n" if err := os.WriteFile(filepath.Join(m.Work, ws, "go.work"), []byte(work), 0o600); err != nil { return nil, err }