From 592637e6d73958c7082848cc86859d945143ed99 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:52:06 +0100 Subject: [PATCH] BM2b (sdk): a step's install archive reaches its test calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The integration step's ask names the install archive; the step run carries it on the check job it runs and hands it to every test call as its argument archive, for the Go build module to unpack into the workspace. Builds: design 47 H2 §800; H-A-367 (4), H-A-399 (1) --- modules/mesh-delivery-sdk/buildstep/ask.go | 4 ++++ modules/mesh-delivery-sdk/steprun/askrun.go | 3 +++ modules/mesh-delivery-sdk/steprun/askrun_test.go | 12 ++++++++++++ modules/mesh-delivery-sdk/steprun/steprun.go | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-sdk/buildstep/ask.go b/modules/mesh-delivery-sdk/buildstep/ask.go index 2e256a6fa..63029a780 100644 --- a/modules/mesh-delivery-sdk/buildstep/ask.go +++ b/modules/mesh-delivery-sdk/buildstep/ask.go @@ -373,6 +373,10 @@ type CheckJob struct { // Toolchain is the toolchain the checker agreed for the language (ADR 0584 clause 2): a holder whose node reports // another version declines the check. Toolchain *ToolchainUsed `json:"toolchain,omitempty"` + // Archive is the install archive a pipeline step's ask names (StepRun.Archive, design 47 H2 §800), which the step run + // hands each test call as its argument archive for the build module to unpack into the workspace. A check ask names + // none, so it is no part of the ask's form. + Archive string `json:"-"` } // ComposeJob asks one compose-candidate build. diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index 74577abd8..bbfb70177 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -360,6 +360,9 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string, if len(job.NodeNames) > 0 { args[sdkstep.NodeNamesArg] = job.NodeNames // the names check's (ADR 0567 §12) } + if job.Archive != "" { + args["archive"] = job.Archive // the install archive the build module unpacks (design 47 H2 §800) + } return args } test := func(args map[string]any) (bool, error) { diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 887a8618f..762ee4d37 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -443,6 +443,7 @@ func TestRunAskRunsAPipelineStepAndSaysItsEnd(t *testing.T) { run int // which run of the ask this is (the step's Run), 0 outside a puller notRun []sdkstep.NotRun saidOpen string // the end's said opens with these words + archive string // the step's install archive, which every test call names }{ {name: "unit: the kept package carried, the other tested and kept", ask: stepOf(sdkstep.StepUnit, sdkstep.KeptResult{Package: "x/a", Digest: "d-a", Level: "unit"}), digests: map[string]string{"x/a": "d-a", "x/b": "d-b"}, tests: map[string]bool{"x/b": true}, outcome: sdkstep.OutcomePassed, counts: 1, carried: []string{"x/a"}, kept: []string{"x/b"}}, @@ -469,6 +470,9 @@ func TestRunAskRunsAPipelineStepAndSaysItsEnd(t *testing.T) { saidOpen: "the bus did not answer in setup within 5m0s under load"}, {name: "a starved setup beside an assertion: failed", ask: stepOf(sdkstep.StepIntegration), digests: map[string]string{"x/b": "d-b"}, run: 1, outcome: sdkstep.OutcomeFailed, counts: 2, test: map[string]any{"passed": false, "tests": 2, "why": "2 failed", "failed": []sdkstep.Failure{{Package: "x/b", Test: "TestT", Cause: "mesh: setup starved: words"}, {Package: "x/b", Test: "TestU", Cause: "got 1, want 2"}}}}, + // §800: the install archive the step names reaches the test calls, for the build module to unpack. + {name: "integration with an install archive: the test calls name it", ask: stepOf(sdkstep.StepIntegration), digests: map[string]string{"x/b": "d-b"}, tests: map[string]bool{"x/b": true}, + outcome: sdkstep.OutcomePassed, counts: 1, kept: []string{"x/b"}, archive: "oci-artifact-registry://gitea/npm-tree:0.1.4"}, // §799: a fetch met away on the third run ends the step failed with its why. {name: "a fetch fault's third run: failed, fetch:", ask: stepOf(sdkstep.StepUnit), run: 3, outcome: sdkstep.OutcomeFailed, fetchErr: &sdkstep.Passing{Err: errors.New("fetch: git fetch: status 502")}, saidOpen: "fetch: git fetch"}, @@ -487,6 +491,9 @@ func TestRunAskRunsAPipelineStepAndSaysItsEnd(t *testing.T) { if row.test != nil { s.Test = func(context.Context, map[string]any) (any, error) { return row.test, nil } } + if row.archive != "" { + row.ask.Step.Archive = row.archive + } ctx := context.Background() if row.run > 0 { ctx = context.WithValue(ctx, phaseKey{}, &phases{step: sdkstep.Step{Run: row.run}}) @@ -536,6 +543,11 @@ func TestRunAskRunsAPipelineStepAndSaysItsEnd(t *testing.T) { if _, err := sdkstep.EncodeStepEnded(e); err != nil { t.Errorf("%s: the end does not encode: %v", row.name, err) } + for _, c := range r.calls { + if strings.HasPrefix(c, "test ") && row.archive != "" && !strings.Contains(c, `"archive":"`+row.archive+`"`) { + t.Errorf("%s: the test call %s names no archive %s", row.name, c, row.archive) + } + } if !slices.Equal(e.NotRun, row.notRun) || !strings.HasPrefix(e.Said, row.saidOpen) { t.Errorf("%s: not run %+v said %q, want %+v and said opening %q", row.name, e.NotRun, e.Said, row.notRun, row.saidOpen) } diff --git a/modules/mesh-delivery-sdk/steprun/steprun.go b/modules/mesh-delivery-sdk/steprun/steprun.go index 0a2d19581..b5dff4aca 100644 --- a/modules/mesh-delivery-sdk/steprun/steprun.go +++ b/modules/mesh-delivery-sdk/steprun/steprun.go @@ -135,7 +135,7 @@ func (s AskSteps) testStep(ctx context.Context, ask sdkstep.StepAsk, end *sdkste } return 0, false, nil } - job := sdkstep.CheckJob{Fetch: *withPackages(&run.Fetch, ask.Packages), Levels: []string{level}, Kept: true, Toolchain: run.Toolchain} + job := sdkstep.CheckJob{Fetch: *withPackages(&run.Fetch, ask.Packages), Levels: []string{level}, Kept: true, Toolchain: run.Toolchain, Archive: run.Archive} out, err := s.check(ctx, job) if err != nil { return err