Design 47 H1: held test steps are asked from the pipeline's own catalog revision (H-A-205, H-A-207)
The runner built the asks of the steps that waited for their pins from the branch's newest catalog half, so a newer revision that moved the module changed what a passed build's tests fetched. The entry is now read at the pipeline's own revision through the runner's revision reader, which keeps what it read; a revision that cannot be read, or whose entry is of another fingerprint than the mover's, ends the held steps could not run, naming why. Builds: design 47 H H-A-205, H-A-207, H-A-203
This commit is contained in:
@@ -142,7 +142,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return err
|
||||
}
|
||||
logger.Printf("widens: each read bound %s, %d catalog revisions kept", readBound, revisionsKept)
|
||||
hearer.Widens = widenerOf(calls.Call, readBound, revisionsKept, logger.Printf).Widens
|
||||
widener := widenerOf(calls.Call, readBound, revisionsKept, logger.Printf)
|
||||
hearer.Widens = widener.Widens
|
||||
hearer.LogLast = stepLog{ctx: ctx, js: js, module: cred.Module}.Last
|
||||
hearer.Where = routerRecordOf(cred.Module, calls.Call, calls.Ask)
|
||||
hearer.Failures = &pipeline.Failures{Findings: rv.Findings, Observer: cred.Module, Author: commitAuthor(calls.Call), Logf: logger.Printf}
|
||||
@@ -155,7 +156,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
hearer.AskSteps = starter.AskSteps
|
||||
hearer.Unplaced = func(p seat.Pipeline, module string) string { return starter.Unplaced(p, module, rv.Catalog.View) }
|
||||
hearer.AskPinHeld = func(key, module string, pins map[string]string) {
|
||||
if _, err := starter.AskPinHeld(hearer.Store, key, module, pins, rv.Catalog.View); err != nil {
|
||||
if _, err := starter.AskPinHeld(hearer.Store, key, module, pins, widener.Revision); err != nil {
|
||||
logger.Printf("the steps of %s's %s that waited for its pins are not asked: %v", key, module, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +280,14 @@ func endPinHeld(p *seat.Pipeline, build seat.StepResult, pins map[string]string,
|
||||
return ended
|
||||
}
|
||||
|
||||
// readRevision is revision's read, an error when none is given.
|
||||
func readRevision(revision func(branch string, revision int64) (Half, error), branch string, n int64) (Half, error) {
|
||||
if revision == nil {
|
||||
return Half{}, errors.New("the runner reads no catalog revision")
|
||||
}
|
||||
return revision(branch, n)
|
||||
}
|
||||
|
||||
// heldOn says whether module has a step of p waiting for its entry's pins.
|
||||
func heldOn(p seat.Pipeline, module string) bool {
|
||||
return slices.ContainsFunc(p.Steps, func(st seat.StepResult) bool { return st.Module == module && pinHeld(st) })
|
||||
@@ -287,8 +295,10 @@ func heldOn(p seat.Pipeline, module string) bool {
|
||||
|
||||
// AskPinHeld asks the steps of pipeline key's mover module that waited for its entry's pins (H-A-206) with the pins its
|
||||
// build passed with (H-A-207): each running under its own ask, its fetch the entry's as Place builds it with those pins.
|
||||
// A step whose artifact the branch's half no longer names ends could not run, saying so. It answers how many it asked.
|
||||
func (s *Starter) AskPinHeld(store Updater, key, module string, pins map[string]string, view func(branch string) (Half, bool)) (int, error) {
|
||||
// The entry is read at the pipeline's own catalog revision through revision, which keeps what it read (H-A-205), never
|
||||
// the branch's newest: a revision that cannot be read, or whose entry is of another fingerprint than the mover's, or that
|
||||
// names no artifact of the step, ends the step could not run, saying so. It answers how many it asked.
|
||||
func (s *Starter) AskPinHeld(store Updater, key, module string, pins map[string]string, revision func(branch string, revision int64) (Half, error)) (int, error) {
|
||||
for {
|
||||
p, rev, err := store.Get(key)
|
||||
if err != nil {
|
||||
@@ -299,10 +309,14 @@ func (s *Starter) AskPinHeld(store Updater, key, module string, pins map[string]
|
||||
return 0, nil
|
||||
}
|
||||
var entry catalog.CatalogEntry
|
||||
if view != nil {
|
||||
if half, ok := view(p.Branch); ok {
|
||||
entry = half.Entries[module]
|
||||
}
|
||||
unread := ""
|
||||
switch half, err := readRevision(revision, p.Branch, p.Revision); {
|
||||
case err != nil:
|
||||
unread = fmt.Sprintf("revision %d of %s, the pipeline's, cannot be read for its entry: %v", p.Revision, p.Branch, err)
|
||||
case half.Entries[module].Fp != m.Fingerprint:
|
||||
unread = fmt.Sprintf("revision %d of %s holds %s at %q, not the mover's %s", p.Revision, p.Branch, module, half.Entries[module].Fp, m.Fingerprint)
|
||||
default:
|
||||
entry = half.Entries[module]
|
||||
}
|
||||
entry.Packages = pins
|
||||
now := s.now()
|
||||
@@ -315,9 +329,13 @@ func (s *Starter) AskPinHeld(store Updater, key, module string, pins map[string]
|
||||
}
|
||||
j := slices.IndexFunc(entry.Artifacts, func(a catalog.Artifact) bool { return a.Ref == st.Artifact })
|
||||
language, err := sdkstep.AskLanguageOfSeat(st.Seat)
|
||||
if j < 0 || err != nil {
|
||||
if unread != "" || j < 0 || err != nil {
|
||||
why := unread
|
||||
if why == "" {
|
||||
why = fmt.Sprintf("revision %d of %s names no artifact %s of %s to ask it of", p.Revision, p.Branch, st.Artifact, module)
|
||||
}
|
||||
st.Outcome, st.Ended = seat.StepResultOutcomeCouldNotRun, &now
|
||||
st.Why = fmt.Sprintf("its build passed with its pins, but the catalog half of %s names no artifact %s of %s to ask it of (H-A-207)", p.Branch, st.Artifact, module)
|
||||
st.Why = "its build passed with its pins, but " + why + " (H-A-207, H-A-205)"
|
||||
p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now))
|
||||
ended = append(ended, i)
|
||||
continue
|
||||
|
||||
@@ -120,13 +120,14 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
|
||||
}
|
||||
held := waiting["app"]
|
||||
held.Packages = map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25", "git.novox.be/novox/x/go": ""}
|
||||
held.Fp = "src2:ab"
|
||||
waiting["app"] = held
|
||||
var journal []string
|
||||
heldAsks := &stepAsks{}
|
||||
hs := &Starter{Pipelines: store, Say: func(string, any) error { return nil }, Steps: heldAsks, Name: "the-runner",
|
||||
Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) },
|
||||
Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }}
|
||||
if ok, err := hs.Start(Begin{Branch: "main", Source: 5, Entries: waiting, Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}}}); !ok || err != nil {
|
||||
if ok, err := hs.Start(Begin{Branch: "main", Source: 5, Revision: 3, Entries: waiting, Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}}}); !ok || err != nil {
|
||||
t.Fatalf("start = %v, %v", ok, err)
|
||||
}
|
||||
for _, x := range heldAsks.asks {
|
||||
@@ -166,11 +167,23 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
|
||||
p seat.Pipeline
|
||||
rev uint64
|
||||
}{hp, 1}
|
||||
// The entry is read at the pipeline's own revision (3), never the newer revision 4 that moved the module (H-A-205).
|
||||
moved := held
|
||||
moved.Fp, moved.Path = "src2:ac", "modules/moved"
|
||||
revisions := func(branch string, n int64) (Half, error) {
|
||||
switch n {
|
||||
case 3:
|
||||
return Half{Revision: 3, Entries: waiting}, nil
|
||||
case 0, 4:
|
||||
return Half{Revision: 4, Entries: map[string]catalog.CatalogEntry{"app": moved}}, nil
|
||||
}
|
||||
return Half{}, fmt.Errorf("no revision %d", n)
|
||||
}
|
||||
var askedWith map[string]string
|
||||
h := &Hearer{Store: ms, Say: func(string, any) error { return nil }, Name: "the-runner",
|
||||
AskPinHeld: func(key, module string, pins map[string]string) {
|
||||
askedWith = pins
|
||||
if _, err := hs.AskPinHeld(ms, key, module, pins, func(string) (Half, bool) { return Half{Entries: waiting}, true }); err != nil {
|
||||
if _, err := hs.AskPinHeld(ms, key, module, pins, revisions); err != nil {
|
||||
t.Errorf("ask held: %v", err)
|
||||
}
|
||||
}}
|
||||
@@ -189,12 +202,28 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
|
||||
if !reflect.DeepEqual(b.Step.Fetch.Packages, pinsBuilt) {
|
||||
t.Errorf("the %s of %s fetches %v; want the build's pins", b.Step.Step, b.Step.Artifact, b.Step.Fetch.Packages)
|
||||
}
|
||||
if b.Step.Fetch.Dir != "modules/app" {
|
||||
t.Errorf("the %s of %s fetches %s; want the pipeline's revision's directory", b.Step.Step, b.Step.Artifact, b.Step.Fetch.Dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
after, _, _ := ms.Get("main.5")
|
||||
if askedHeld == 0 || after.Steps[1].Outcome == seat.StepResultOutcomeWaiting || after.Steps[1].Ask == "" {
|
||||
t.Errorf("after the build passed %d held steps were asked, lint = %+v; want each asked", askedHeld, after.Steps[1])
|
||||
}
|
||||
// A mover whose fingerprint the pipeline's revision does not hold ends its held steps could not run, naming it.
|
||||
other := hp
|
||||
other.Pipeline, other.Steps, other.Movers = "main.6", append([]seat.StepResult(nil), hp.Steps...), []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:zz", Repository: "o/app"}}
|
||||
ms["main.6"] = struct {
|
||||
p seat.Pipeline
|
||||
rev uint64
|
||||
}{other, 1}
|
||||
if n, err := hs.AskPinHeld(ms, "main.6", "app", pinsBuilt, revisions); n != 0 || err != nil {
|
||||
t.Errorf("asked %d held steps of a mover its revision does not hold (%v); want none", n, err)
|
||||
}
|
||||
if o, _, _ := ms.Get("main.6"); o.Steps[1].Outcome != seat.StepResultOutcomeCouldNotRun || !strings.Contains(o.Steps[1].Why, "not the mover's src2:zz") {
|
||||
t.Errorf("the held lint step of a moved fingerprint = %+v; want could not run naming it", o.Steps[1])
|
||||
}
|
||||
if !strings.Contains(strings.Join(journal, "\n"), "app's lint of app:program is not asked: it waits on the publish of git.novox.be/novox/x/go") {
|
||||
t.Errorf("the journal says %q; want the held step named", journal)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user