|
|
|
@@ -75,52 +75,6 @@ func fromRepo(module, repository, path string) inventory.Entry {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A merge rebuilds the modules whose own directories it changed, and everything when what it changed
|
|
|
|
|
// is shared. One repository holding many modules is the ordinary case here, and rebuilding all of
|
|
|
|
|
// them for a change to one is what exhausted a registry's pull limit the first night this ran.
|
|
|
|
|
func TestAMergeRebuildsTheModulesItChanged(t *testing.T) {
|
|
|
|
|
const repo = "http://forge.internal:20000/novox/mesh-catalog.git"
|
|
|
|
|
gitea := fromRepo("gitea", repo, "modules/gitea")
|
|
|
|
|
keycloak := fromRepo("keycloak", repo, "modules/keycloak")
|
|
|
|
|
known := []inventory.Entry{gitea, keycloak, fromRepo("plex", repo, "modules/plex")}
|
|
|
|
|
candidates := []inventory.Entry{gitea, keycloak}
|
|
|
|
|
merge := func(paths []string, truncated bool) link.SourceMoved {
|
|
|
|
|
return link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main",
|
|
|
|
|
Paths: paths, PathsTruncated: truncated}
|
|
|
|
|
}
|
|
|
|
|
named := func(entries []inventory.Entry) string {
|
|
|
|
|
var names []string
|
|
|
|
|
for _, e := range entries {
|
|
|
|
|
names = append(names, e.Manifest.Module)
|
|
|
|
|
}
|
|
|
|
|
return strings.Join(names, ",")
|
|
|
|
|
}
|
|
|
|
|
for _, c := range []struct {
|
|
|
|
|
what string
|
|
|
|
|
m link.SourceMoved
|
|
|
|
|
want string
|
|
|
|
|
}{
|
|
|
|
|
{"one module's own files", merge([]string{"modules/gitea/index.ts", "modules/gitea/client.ts"}, false), "gitea"},
|
|
|
|
|
{"two modules' files", merge([]string{"modules/gitea/index.ts", "modules/keycloak/module.json"}, false), "gitea,keycloak"},
|
|
|
|
|
{"a file at the root no build reads (issue 280)", merge([]string{"tsconfig.json"}, false), ""},
|
|
|
|
|
{"a module the mesh does not hold", merge([]string{"modules/plex/index.ts"}, false), ""},
|
|
|
|
|
{"nothing said about the files", merge(nil, false), "gitea,keycloak"},
|
|
|
|
|
{"more files than were listed", merge([]string{"modules/gitea/index.ts"}, true), "gitea,keycloak"},
|
|
|
|
|
// novox/hq issue 252: a module the mesh has never registered is still a module, when the merge
|
|
|
|
|
// shows it is one — and a directory that may be shared code is still shared.
|
|
|
|
|
{"a new module beside a held one", merge([]string{"modules/gitea/x", "modules/newmod/module.json"}, false), "gitea"},
|
|
|
|
|
{"a new module's other files", merge([]string{"modules/newmod/index.ts", "modules/newmod/module.json"}, false), ""},
|
|
|
|
|
{"a module removed", merge([]string{"modules/gone/module.json"}, false), ""},
|
|
|
|
|
{"a directory with no manifest", merge([]string{"modules/lib/x.go"}, false), ""},
|
|
|
|
|
{"a file directly among the modules", merge([]string{"modules/README.md"}, false), ""},
|
|
|
|
|
{"a root file beside a module's", merge([]string{"merge-check.sh", "modules/keycloak/x.ts"}, false), "keycloak"},
|
|
|
|
|
} {
|
|
|
|
|
if got := named(whatTheMergeTouched(candidates, known, c.m, nil)); got != c.want {
|
|
|
|
|
t.Errorf("%s: rebuilt %q, wanted %q", c.what, got, c.want)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A module whose recipe packages source from another repository is affected when that repository
|
|
|
|
|
// moves — the manifest the mesh keeps says nothing about it, so the record of what the build read is
|
|
|
|
|
// the only thing that can say so.
|
|
|
|
@@ -203,52 +157,6 @@ func TestAModuleBuiltAtACommitStillFollowsItsBranch(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// novox/hq issues 278 and 280: a merge touching the code of a module the mesh does not hold — the
|
|
|
|
|
// catalogue's reference module, whose manifest it left alone — read as shared and rebuilt every module
|
|
|
|
|
// built from the repository (103 of them on 2026-10-06, 88 byte-identical); so did a merge-check.sh added at
|
|
|
|
|
// the root. No build reads a file outside its module's directory, so neither rebuilds anything, said by the
|
|
|
|
|
// announcer or not.
|
|
|
|
|
func TestAChangeInsideAModuleIsThatModulesHeldOrNot(t *testing.T) {
|
|
|
|
|
const repo = "http://forge.internal:20000/novox/mesh-catalog.git"
|
|
|
|
|
gitea := fromRepo("gitea", repo, "modules/gitea")
|
|
|
|
|
keycloak := fromRepo("keycloak", repo, "modules/keycloak")
|
|
|
|
|
known := []inventory.Entry{gitea, keycloak}
|
|
|
|
|
candidates := []inventory.Entry{gitea, keycloak}
|
|
|
|
|
merge := func(paths, modules []string, said bool) link.SourceMoved {
|
|
|
|
|
return link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Paths: paths,
|
|
|
|
|
ModuleDirs: modules, ModuleDirsSaid: said}
|
|
|
|
|
}
|
|
|
|
|
named := func(entries []inventory.Entry) string {
|
|
|
|
|
var names []string
|
|
|
|
|
for _, e := range entries {
|
|
|
|
|
names = append(names, e.Manifest.Module)
|
|
|
|
|
}
|
|
|
|
|
return strings.Join(names, ",")
|
|
|
|
|
}
|
|
|
|
|
showcase := []string{"modules/showcase/index.ts"}
|
|
|
|
|
for _, c := range []struct {
|
|
|
|
|
what string
|
|
|
|
|
m link.SourceMoved
|
|
|
|
|
want string
|
|
|
|
|
}{
|
|
|
|
|
{"a module held by none, said", merge(showcase, []string{"modules/showcase"}, true), ""},
|
|
|
|
|
{"beside a held one's change", merge(append([]string{"modules/gitea/index.ts"}, showcase...),
|
|
|
|
|
[]string{"modules/gitea", "modules/showcase"}, true), "gitea"},
|
|
|
|
|
{"deeper inside it", merge([]string{"modules/showcase/daemon/index.ts"}, []string{"modules/showcase"}, true), ""},
|
|
|
|
|
{"a directory holding no manifest, read by no build", merge([]string{"modules/lib/x.go"}, nil, true), ""},
|
|
|
|
|
{"one of two files in no module", merge([]string{"modules/showcase/index.ts", "modules/lib/x.go"},
|
|
|
|
|
[]string{"modules/showcase"}, true), ""},
|
|
|
|
|
{"the root is never a module directory", merge([]string{"tsconfig.json"}, []string{"", "/", "."}, true), ""},
|
|
|
|
|
{"not said: still no build reads it", merge(showcase, []string{"modules/showcase"}, false), ""},
|
|
|
|
|
{"an old announcer saying nothing", merge(showcase, nil, false), ""},
|
|
|
|
|
{"a manifest the merge removed, said or not", merge([]string{"modules/gone/module.json", "modules/gone/x.ts"}, nil, true), ""},
|
|
|
|
|
} {
|
|
|
|
|
if got := named(whatTheMergeTouched(candidates, known, c.m, nil)); got != c.want {
|
|
|
|
|
t.Errorf("%s: rebuilt %q, wanted %q", c.what, got, c.want)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// What the announcer says reaches the controller as it is sent: the two fields, by their names on the
|
|
|
|
|
// wire, and an older announcement without them reads as not said.
|
|
|
|
|
func TestTheAnnouncerSaysWhichDirectoriesAreModules(t *testing.T) {
|
|
|
|
|