From 7d97516c3be7d960a3afdf655364185fb9f4f4d7 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 15 Nov 2026 18:58:23 +0100 Subject: [PATCH] pipeline: a step's fetch names the module directory only with its artifact's paths Every step of the first pipelines ended 'could not run (the request names a module directory and no path)': the runner put the entry's directory in the fetch without paths, which the build seat refuses. It now names the directory with the artifact's named paths from the entry, and else neither, so the commit is fetched whole. --- .../internal/pipeline/place.go | 20 ++++++++++++++++++- .../internal/pipeline/place_test.go | 11 ++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place.go b/modules/mesh-delivery-pipeline/internal/pipeline/place.go index b4037762..66b41d75 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place.go @@ -159,7 +159,13 @@ type Asked struct { } func stepAsk(p seat.Pipeline, e catalog.CatalogEntry, a catalog.Artifact, step, id, asker string, now time.Time) nodebuildgo.StepAsk { - fetch := nodebuildgo.Fetch{Repository: p.Repository, Commit: p.Commit, Dir: e.Path} + // 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} + if paths := artifactPaths(e, a.Ref); len(paths) > 0 { + fetch.Dir, fetch.Paths = e.Path, 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, Module: p.Module, Pipeline: p.Pipeline, Revision: p.Source, Step: step}} @@ -192,3 +198,15 @@ func askAll(asker StepAsker, arm Arm, key string, asks []Asked, recovery bool) e } return first } + +// artifactPaths are the named paths the entry keeps for the artifact, by its reference or its name. +func artifactPaths(e catalog.CatalogEntry, ref string) []string { + if e.Inputs == nil { + return nil + } + if p, ok := e.Inputs.Paths[ref]; ok { + return p + } + _, name, _ := strings.Cut(ref, ":") + return e.Inputs.Paths[name] +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go index 8f3d93eb..f7634024 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go @@ -45,7 +45,7 @@ func placeFixture() (catalog.Registration, map[string]catalog.CatalogEntry) { }} return reg, map[string]catalog.CatalogEntry{ "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}, - {Ref: "app:web", Language: "rust"}}}, + {Ref: "app:web", Language: "rust"}}, Inputs: &catalog.EntryInputs{Paths: map[string][]string{"app:program": {"cmd/app"}}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}, } } @@ -100,9 +100,16 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) { a := asks.asks[1].(nodebuildgo.StepAsk) if asks.at[1] != "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner" || a.Kind != "step" || a.Asker != "the-runner" || a.ID != p.Steps[1].Ask || asks.ids[1] != a.ID || a.Step.Commit != "c1" || a.Step.Fingerprint != "src2:aa" || a.Step.Pipeline != "main.4.app" || a.Step.Artifact != "app:program" || - a.Step.Step != "lint" || a.Step.Fetch.Repository != "o/app" || a.Step.Fetch.Dir != "modules/app" || a.Step.Revision != 4 { + a.Step.Step != "lint" || a.Step.Fetch.Repository != "o/app" || a.Step.Fetch.Dir != "modules/app" || a.Step.Revision != 4 || + 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. + 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) + } + } // A second start of the revision asks nothing. if ok, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Entries: entries}); ok || err != nil || len(asks.asks) != 7 { t.Errorf("second start = %v, %v, %d asks", ok, err, len(asks.asks))