A changed file touches exactly the modules whose build reads it (hq issue 280, ADR 0237)

The builder reads a module's own directory (the repository for one built from its root)
and a repository its recipe packages, nothing else. A file in no module's directory was
read as shared code and rebuilt everything built from the repository: 103 modules for a
merge-check.sh added at the catalogue's root. It now touches nothing, in the merge
handler, the release planner and the pull request's check alike, and the gate says so.
This commit is contained in:
jochen
2026-10-06 22:34:57 +02:00
parent 327654e57b
commit b24bb030ec
7 changed files with 71 additions and 116 deletions
+11 -10
View File
@@ -108,9 +108,9 @@ type mergeComposed struct {
type mergeWidthOf struct {
Modules []string `json:"modules"`
Tiers int `json:"tiers"`
// Shared is the changed paths read as shared code: in no directory of a module the mesh holds, so
// everything built from the repository is rebuilt for them.
Shared []string `json:"shared,omitempty"`
// Unread is the changed paths no module's build reads — in no module's directory — which rebuild
// nothing (issue 280): said, so a reader sees why a change to them moves no module.
Unread []string `json:"unread,omitempty"`
}
// wideRebuild is how many modules a rebuild may take before the gate says so as a warning.
@@ -312,11 +312,11 @@ func judgeChange(ctx context.Context, in mergeCheckInput) (mergeVerdict, error)
v.Notes = append(v.Notes, "the width of the rebuild could not be worked out: "+err.Error())
} else {
v.Width = &w
if len(w.Shared) > 0 && len(w.Modules) > wideRebuild {
v.Warnings = append(v.Warnings, fmt.Sprintf("a merge rebuilds %d module(s), because %s read as shared "+
"code: in no directory of a module the mesh holds (issue 278)", len(w.Modules),
readableList(w.Shared)))
} else if len(w.Modules) > wideRebuild {
if len(w.Unread) > 0 {
v.Notes = append(v.Notes, fmt.Sprintf("%s read by no module's build, and rebuild nothing (issue 280)",
readableList(w.Unread)))
}
if len(w.Modules) > wideRebuild {
v.Warnings = append(v.Warnings, fmt.Sprintf("a merge rebuilds %d module(s) in %d tier(s)",
len(w.Modules), w.Tiers))
}
@@ -1016,7 +1016,8 @@ func rebuildWidth(f snapshot.Facts, repository string, paths []string, tree stri
}
sort.Strings(w.Modules)
}
// The paths read as shared: in no directory of a module the mesh holds from this repository.
// The paths no build reads: in no directory of a module the mesh holds from this repository, or one
// the tree holds.
var dirs []string
for _, e := range from {
if d := strings.Trim(e.Source.Path, "/"); d != "" {
@@ -1032,7 +1033,7 @@ func rebuildWidth(f snapshot.Facts, repository string, paths []string, tree stri
inModule = inModule || strings.HasPrefix(p, d)
}
if !inModule && len(dirs) > 0 {
w.Shared = append(w.Shared, p)
w.Unread = append(w.Unread, p)
}
}
return w, nil