pipeline runner: a step's fetch always names its module's directory, paths when the entry has them (principle 10, A-447)

This commit is contained in:
2026-11-16 12:22:52 +01:00
parent d0e7dee951
commit f5880d449b
2 changed files with 7 additions and 8 deletions
@@ -159,12 +159,11 @@ type Asked struct {
}
func stepAsk(p seat.Pipeline, e catalog.CatalogEntry, a catalog.Artifact, step, id, asker string, now time.Time) nodebuildgo.StepAsk {
// A fetch names a module directory only with the paths in it (buildstep's FetchRequest refuses a directory alone): the
// artifact's named paths from the entry, else no directory, and the commit is fetched whole (lead-47, 2026-11-15: every
// step of the first pipelines ended "could not run (the request names a module directory and no path)").
fetch := nodebuildgo.Fetch{Repository: p.Repository, Commit: p.Commit}
// A step is for its module alone (principle 10, A-447): the fetch always names the module's directory, and the
// artifact's named paths in it when the entry has them.
fetch := nodebuildgo.Fetch{Repository: p.Repository, Commit: p.Commit, Dir: e.Path}
if paths := artifactPaths(e, a.Ref); len(paths) > 0 {
fetch.Dir, fetch.Paths = e.Path, paths
fetch.Paths = paths
}
return nodebuildgo.StepAsk{V: 1, ID: id, Asker: asker, Kind: "step", Language: a.Language, At: &now,
Step: &nodebuildgo.StepRun{Artifact: a.Ref, Branch: p.Branch, Commit: p.Commit, Fetch: fetch, Fingerprint: p.Fingerprint,
@@ -104,10 +104,10 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
len(a.Step.Fetch.Paths) != 1 || a.Step.Fetch.Paths[0] != "cmd/app" {
t.Errorf("the ask = %+v at %s", a, asks.at[1])
}
// An artifact that names no paths fetches the commit whole: a directory alone is refused by the build seat.
// An artifact that names no paths still fetches its module alone: the directory with no paths (principle 10, A-447).
for _, x := range asks.asks[2:] {
if b, ok := x.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Artifact == "app:tools" && (b.Step.Fetch.Dir != "" || len(b.Step.Fetch.Paths) != 0) {
t.Errorf("the tools ask fetches %+v, want the commit whole", b.Step.Fetch)
if b, ok := x.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Artifact == "app:tools" && (b.Step.Fetch.Dir != "modules/app" || len(b.Step.Fetch.Paths) != 0) {
t.Errorf("the tools ask fetches %+v, want the module's directory and no paths", b.Step.Fetch)
}
}
// A second start of the revision asks nothing.