A pipeline step's ask names its build seat's language; the toolchain stays keyed by the artifact's (A-488, A-488b) #255
@@ -127,10 +127,17 @@ func place(p seat.Pipeline, reg catalog.Registration, entries map[string]catalog
|
||||
steps = append(steps, s)
|
||||
continue
|
||||
}
|
||||
// The ask names the language of the seat it is asked of, never the artifact's word (design 47 G A-488).
|
||||
language, err := sdkstep.AskLanguageOfSeat(bs)
|
||||
if err != nil {
|
||||
s.Outcome, s.Started, s.Ended, s.Why = seat.StepResultOutcomeCouldNotRun, &now, &now, err.Error()
|
||||
steps = append(steps, s)
|
||||
continue
|
||||
}
|
||||
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, step, s.Ask, asker, now)
|
||||
ask := Asked{Seat: bs, ID: s.Ask, Ask: body}
|
||||
body := stepAsk(p, entry, a, language, step, s.Ask, asker, now)
|
||||
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)
|
||||
@@ -189,17 +196,20 @@ 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, step, id, asker string, now time.Time) nodebuildgo.StepAsk {
|
||||
func stepAsk(p seat.Pipeline, e catalog.CatalogEntry, a catalog.Artifact, language, step, id, asker string, now time.Time) nodebuildgo.StepAsk {
|
||||
// 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.Paths = paths
|
||||
}
|
||||
return nodebuildgo.StepAsk{V: 1, ID: id, Asker: asker, Kind: "step", Language: a.Language, At: &now,
|
||||
return nodebuildgo.StepAsk{V: 1, ID: id, Asker: asker, Kind: "step", Language: 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}}
|
||||
}
|
||||
|
||||
@@ -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,8 +303,10 @@ 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: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"}}},
|
||||
}
|
||||
steps, asks := Place(seat.Pipeline{Pipeline: "main.4.app", Module: "app"}, reg, entries, time.Unix(0, 0), "the-runner")
|
||||
want := map[string]struct{ outcome, seat, status string }{
|
||||
@@ -304,6 +314,8 @@ func TestAnArtifactWithoutALanguageIsPlacedByItsKind(t *testing.T) {
|
||||
"app:files": {seat.StepResultOutcomeBypassed, "", seat.StepResultStatusBypass},
|
||||
"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 {
|
||||
@@ -316,16 +328,21 @@ 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 != 12 {
|
||||
t.Errorf("placed %d build steps of the four artifacts, want 12", 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" {
|
||||
t.Errorf("asked %s, want only the build, the composition and the image's build seat", a.Seat)
|
||||
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
|
||||
// image), never the artifact's word (typescript).
|
||||
if ask, ok := a.Ask.(nodebuildgo.StepAsk); ok && ask.Language != strings.TrimPrefix(a.Seat, "node-build-") {
|
||||
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) != 5 {
|
||||
t.Errorf("asked %d, want the build, the image's three steps and the composition", len(asks))
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -141,6 +141,19 @@ func BuildSeat(language string) (string, error) {
|
||||
return "node-build-" + language, nil
|
||||
}
|
||||
|
||||
// AskLanguageOfSeat is the language of the asks a build seat takes: node-build-go go, node-build-node node, node-build-image
|
||||
// image (BuildSeat's inverse). A pipeline step's ask names it, never the artifact's language word (design 47 G A-488).
|
||||
func AskLanguageOfSeat(seat string) (string, error) {
|
||||
language, ok := strings.CutPrefix(seat, "node-build-")
|
||||
if !ok {
|
||||
return "", fmt.Errorf("buildstep: %q is no build seat", seat)
|
||||
}
|
||||
if err := checkAskLanguage(language); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return language, nil
|
||||
}
|
||||
|
||||
// AskSubject is the subject a build seat accepts a queue's asks on: the seat's accept subject of main's form, which names no
|
||||
// asker (design 47 G §600, §483).
|
||||
func AskSubject(language, queue string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user