Design 47 H1: every step ask fetches with the entry's pins, as the build does (H-A-203)
The runner's lint, unit and integration asks carried no pins, only the build ask did, so the Go build module, which refuses a requirement of another repository with no pin, could not run twelve test steps of the contracts mover (main.45). stepAsk now puts the entry's packages into the fetch in the form the entry keeps and the builder sends, so a test runs against what the build was built against; a package the entry names with no pin yet is left out. Builds: design 47 H H-A-203, H-A-192, H-A-183
This commit is contained in:
+13
-1
@@ -88,7 +88,8 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "ASKS", Subjects: []string{"mesh.seat.*.accept.>"}, Retention: jetstream.WorkQueuePolicy}); err != nil {
|
||||
askStream, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "ASKS", Subjects: []string{"mesh.seat.*.accept.>"}, Retention: jetstream.WorkQueuePolicy})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -116,6 +117,7 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
answer("mesh.seat.mesh-hand-acts.call.hand-act.*", map[string]any{})
|
||||
entries := []catalog.CatalogEntry{
|
||||
{Module: "app", Commit: "c1", Fp: "src2:aa", Path: "modules/app", Repository: "o/app",
|
||||
Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25"},
|
||||
Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}},
|
||||
{Module: "web", Commit: "w1", Fp: "src2:ww", Path: "modules/web", Repository: "o/web", Artifacts: []catalog.Artifact{{Ref: "web:program", Language: "node"}}},
|
||||
{Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}},
|
||||
@@ -331,6 +333,16 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
passBuild(p3, "app", "c1", "src2:aa")
|
||||
unitRun, unit := runOfStep(p3, "app:program", "unit")
|
||||
integRun, integ := runOfStep(p3, "app:program", "integration")
|
||||
// A test ask fetches with the entry's pins, as the builder gives them the build (H-A-203).
|
||||
last, err := askStream.GetLastMsgForSubject(ctx, "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var testAsk nodebuildgo.StepAsk
|
||||
if err := json.Unmarshal(last.Data, &testAsk); err != nil || testAsk.Step == nil ||
|
||||
testAsk.Step.Fetch.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.25" {
|
||||
t.Fatalf("the last test ask = %s (%v), want its fetch to carry the entry's pin", last.Data, err)
|
||||
}
|
||||
if got := runKeys("main.1"); len(got) != 2 || len(unit.Readers) != 2 || len(integ.Readers) != 2 {
|
||||
t.Fatalf("runs %v, unit readers %+v, integration readers %+v; want one run per level read by both artifacts", got, unit.Readers, integ.Readers)
|
||||
}
|
||||
|
||||
@@ -234,6 +234,18 @@ func stepAsk(p seat.Pipeline, m seat.Mover, e catalog.CatalogEntry, a catalog.Ar
|
||||
if paths := artifactPaths(e, a.Ref); len(paths) > 0 {
|
||||
fetch.Paths = paths
|
||||
}
|
||||
// The entry's pins, the same the builder gives the build (H-A-203, H-A-183): a test runs against what the build was
|
||||
// built against, and the Go build module refuses a requirement of another repository with no pin (H-A-192). A
|
||||
// package the entry names with no pin yet is left out, as the builder pins it only from its publish.
|
||||
for path, version := range e.Packages {
|
||||
if version == "" {
|
||||
continue
|
||||
}
|
||||
if fetch.Packages == nil {
|
||||
fetch.Packages = map[string]string{}
|
||||
}
|
||||
fetch.Packages[path] = version
|
||||
}
|
||||
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: m.Commit, Fetch: fetch, Fingerprint: m.Fingerprint,
|
||||
Module: m.Module, Pipeline: p.Pipeline, Revision: p.Source, Step: step}}
|
||||
|
||||
@@ -44,7 +44,7 @@ func placeFixture() (catalog.Registration, map[string]catalog.CatalogEntry) {
|
||||
Artifacts: map[string]catalog.StepStatuses{"tools": {Lint: "bypass"}},
|
||||
}}
|
||||
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"},
|
||||
"app": {Module: "app", Path: "modules/app", Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25", "git.novox.be/novox/x/go": ""}, Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"},
|
||||
{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"}}},
|
||||
}
|
||||
@@ -104,6 +104,13 @@ 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])
|
||||
}
|
||||
// Every step ask fetches with the entry's pins, as the builder gives them the build; a package with no pin yet is left
|
||||
// out (H-A-203, H-A-192).
|
||||
for _, x := range asks.asks[1:] {
|
||||
if b, ok := x.(nodebuildgo.StepAsk); ok && b.Step != nil && (len(b.Step.Fetch.Packages) != 1 || b.Step.Fetch.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.25") {
|
||||
t.Errorf("the %s ask of %s fetches the pins %v, want the entry's", b.Step.Step, b.Step.Artifact, b.Step.Fetch.Packages)
|
||||
}
|
||||
}
|
||||
// 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 != "modules/app" || len(b.Step.Fetch.Paths) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user