diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place.go b/modules/mesh-delivery-pipeline/internal/pipeline/place.go index 14a82a20..72cb8195 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place.go @@ -137,7 +137,7 @@ func place(p seat.Pipeline, reg catalog.Registration, entries map[string]catalog s.Seat, s.Outcome, s.Started = bs, seat.StepResultOutcomeRunning, &now s.Ask = AskID(startOf(p, now), p.Pipeline, a.Ref, step) body := stepAsk(p, entry, a, language, step, s.Ask, asker, now) - ask := Asked{Seat: bs, ID: s.Ask, Ask: body} + ask := Asked{Seat: bs, ID: s.Ask, Ask: body, Toolchain: a.Language} if share && BoundSeat(bs) { digest := ShareDigest(p.Fingerprint, step, status, body.Step.Fetch) run := TestRunKey(candidate, step, digest) @@ -196,7 +196,10 @@ type Asked struct { // Run is the test run the ask asks, its key in test-runs, with its level, its share digest and the steps of the pipeline // reading it, the asking step first (§724, §725); empty for an ask of no test run. Run, Level, Digest string - Readers []seat.TestRunReader + // Toolchain is the language of the artifact's toolchain as the catalog keys it (go, typescript; design 47 G A-104, A-488b), + // never the ask's language, which names the seat; empty for an artifact with none (an image). + Toolchain string + Readers []seat.TestRunReader } func stepAsk(p seat.Pipeline, e catalog.CatalogEntry, a catalog.Artifact, language, step, id, asker string, now time.Time) nodebuildgo.StepAsk { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go index 13fcdbb4..3251eb56 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go @@ -242,7 +242,9 @@ func TestAStepAskCarriesTheKeptResultsAndTheToolchain(t *testing.T) { reg, entries := placeFixture() e := entries["app"] e.Artifacts[0].Package = &catalog.ArtifactPackage{Ecosystem: "go", Name: "git.example/o/app"} + e.Artifacts = append(e.Artifacts, catalog.Artifact{Ref: "app:lib", Language: "typescript"}) entries["app"] = e + entries["mesh-build-node"] = catalog.CatalogEntry{Module: "mesh-build-node", Acts: []catalog.ActingRule{{Seat: "node-build-node", Step: "build", On: "typescript"}}} store, asks := created{}, &stepAsks{} reads := 0 s := &Starter{Pipelines: store, Say: func(string, any) error { return nil }, Steps: asks, Name: "the-runner", @@ -260,7 +262,7 @@ func TestAStepAskCarriesTheKeptResultsAndTheToolchain(t *testing.T) { if _, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Fp: "src2:aa", Repository: "o/app", Entries: entries}); err != nil { t.Fatal(err) } - var program, tools *nodebuildgo.StepRun + var program, tools, lib *nodebuildgo.StepRun for _, a := range asks.asks { if ask, ok := a.(nodebuildgo.StepAsk); ok { switch { @@ -268,6 +270,8 @@ func TestAStepAskCarriesTheKeptResultsAndTheToolchain(t *testing.T) { program = ask.Step case ask.Step.Artifact == "app:tools" && ask.Step.Step == "unit": tools = ask.Step + case ask.Step.Artifact == "app:lib" && ask.Step.Step == "unit": + lib = ask.Step } } } @@ -277,6 +281,10 @@ func TestAStepAskCarriesTheKeptResultsAndTheToolchain(t *testing.T) { if tools == nil || len(tools.Kept) != 0 || tools.Toolchain == nil { t.Errorf("an artifact with no package carries no kept result and its language's toolchain: %+v", tools) } + // Design 47 G A-488b: the toolchain is read by the artifact's toolchain language (typescript), never by the ask's (node). + if lib == nil || lib.Toolchain == nil || lib.Toolchain.Language != "typescript" { + t.Errorf("the TypeScript artifact's ask carries the toolchain %+v, want the one of typescript", lib) + } for pkg, want := range map[string]bool{"a/b": true, "a/b/c": true, "a/bc": false, "a": false} { if InPackage(pkg, "a/b") != want { t.Errorf("InPackage(%s, a/b) = %v, want %v", pkg, !want, want) @@ -295,7 +303,8 @@ func TestAnArtifactWithoutALanguageIsPlacedByItsKind(t *testing.T) { reg := catalog.Registration{Module: "app", Policy: catalog.Policy{Steps: catalog.StepStatuses{Lint: "required", Unit: "required", Integration: "required"}}} entries := map[string]catalog.CatalogEntry{ "app": {Module: "app", Artifacts: []catalog.Artifact{{Ref: "app:server", Kind: "image"}, {Ref: "app:files", Kind: "archive"}, - {Ref: "app:mirror", Kind: "upstream"}, {Ref: "app:web", Language: "rust"}, {Ref: "app:lib", Language: "typescript"}}}, + {Ref: "app:mirror", Kind: "upstream"}, {Ref: "app:web", Language: "rust"}, {Ref: "app:lib", Language: "typescript"}, {Ref: "app:cli", Language: "go"}}}, + "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}, "mesh-build-image": {Module: "mesh-build-image", Acts: []catalog.ActingRule{{Seat: "node-build-image", Step: "build", On: seatdef.OnKindImage}}}, "mesh-build-node": {Module: "mesh-build-node", Acts: []catalog.ActingRule{{Seat: "node-build-node", Step: "build", On: "typescript"}}}, } @@ -306,6 +315,7 @@ func TestAnArtifactWithoutALanguageIsPlacedByItsKind(t *testing.T) { "app:mirror": {seat.StepResultOutcomeBypassed, "", seat.StepResultStatusBypass}, "app:web": {seat.StepResultOutcomeCouldNotRun, "", "required"}, "app:lib": {seat.StepResultOutcomeRunning, "node-build-node", "required"}, + "app:cli": {seat.StepResultOutcomeRunning, "node-build-go", "required"}, } n := 0 for _, s := range steps { @@ -318,11 +328,11 @@ func TestAnArtifactWithoutALanguageIsPlacedByItsKind(t *testing.T) { t.Errorf("%s %s is %s/%s at %q (%s), want %s/%s at %q", s.Artifact, s.Step, s.Status, s.Outcome, s.Seat, s.Why, w.status, w.outcome, w.seat) } } - if n != 15 { - t.Errorf("placed %d build steps of the five artifacts, want 15", n) + if n != 18 { + t.Errorf("placed %d build steps of the six artifacts, want 18", n) } for _, a := range asks { - if a.Seat != builds.Seat && a.Seat != wants.Seat && a.Seat != "node-build-image" && a.Seat != "node-build-node" { + if a.Seat != builds.Seat && a.Seat != wants.Seat && a.Seat != "node-build-image" && a.Seat != "node-build-node" && a.Seat != "node-build-go" { t.Errorf("asked %s, want only the build, the composition and the image's and the node's build seats", a.Seat) } // Design 47 G A-488: a step's ask names the language of the seat it is asked of (node-build-node node, node-build-image @@ -331,7 +341,7 @@ func TestAnArtifactWithoutALanguageIsPlacedByItsKind(t *testing.T) { t.Errorf("the ask %s on %s names the language %q, want %q", a.ID, a.Seat, ask.Language, strings.TrimPrefix(a.Seat, "node-build-")) } } - if len(asks) != 8 { + if len(asks) != 11 { t.Errorf("asked %d, want the build, the image's and the node's three steps each and the composition", len(asks)) } } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index dcc1ab14..625d8dcb 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -483,16 +483,16 @@ func (s *Starter) carry(key string, asks []Asked) { if a.Package != "" { ask.Step.Kept = kept[a.Package] } - if s.Toolchain == nil || ask.Language == "" { + if s.Toolchain == nil || a.Toolchain == "" { continue } - t, done := chains[ask.Language] + t, done := chains[a.Toolchain] if !done { var err error - if t, err = s.Toolchain(ask.Language); err != nil { - s.logf("the toolchain of %s for the steps of %s is not read: %v", ask.Language, key, err) + if t, err = s.Toolchain(a.Toolchain); err != nil { + s.logf("the toolchain of %s for the steps of %s is not read: %v", a.Toolchain, key, err) } - chains[ask.Language] = t + chains[a.Toolchain] = t } ask.Step.Toolchain = t }