Design 47 H1: a pipeline ends failed once it can no longer pass, a mover waiting on its registration named (H-A-163)
main.20 and main.22 never ended: a mover with no step placed (no registration) held the end even after a placed mover's required step failed and nothing was open. It now holds the end only while the pipeline could still pass. Builds: design 47 H §746, H-A-163, G A-327
This commit is contained in:
@@ -568,16 +568,21 @@ func stepPassed(s seat.StepResult) bool {
|
||||
|
||||
// endPipeline ends a pipeline whose every mover is placed and every step ended: passed when every mover's required steps
|
||||
// passed, were carried or had nothing to run, else failed, naming each required step that held it (ADR 0666 §7, §9;
|
||||
// design 47 H §746). A failed optional step, and an optional step still waiting, hold nothing. An approval step still
|
||||
// design 47 H §746). A mover with no step placed, waiting on its registration (A-327), holds the end only while the
|
||||
// pipeline could still pass: once a placed mover's required step did not pass and none is open, it ends failed, naming that
|
||||
// mover (H-A-163). A failed optional step, and an optional step still waiting, hold nothing. An approval step still
|
||||
// waiting when a required step did not pass is `not asked` (§26). It says whether the pipeline ended now, its end count one
|
||||
// higher.
|
||||
func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
||||
if p.Outcome != seat.PipelineOutcomeRunning {
|
||||
return false
|
||||
}
|
||||
// A mover with no step placed waits on its registration (A-327): it holds the end only while every placed mover's
|
||||
// required steps passed, since once one failed or could not run the pipeline can no longer pass (H-A-163).
|
||||
var unplaced []string
|
||||
for _, m := range p.Movers {
|
||||
if !placed(*p, m.Module) {
|
||||
return false
|
||||
unplaced = append(unplaced, m.Module)
|
||||
}
|
||||
}
|
||||
var held []string
|
||||
@@ -598,6 +603,9 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
||||
held = append(held, strings.TrimSpace(s.Module+" "+s.Artifact+" "+s.Step)+" "+s.Outcome)
|
||||
}
|
||||
}
|
||||
if len(unplaced) > 0 && len(held) == 0 {
|
||||
return false
|
||||
}
|
||||
if len(notAsked) > 0 {
|
||||
if len(held) == 0 {
|
||||
return false
|
||||
@@ -611,6 +619,9 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
||||
p.Outcome, p.Why = seat.PipelineOutcomePassed, ""
|
||||
if len(held) > 0 {
|
||||
p.Outcome, p.Why = seat.PipelineOutcomeFailed, "required steps not passed: "+strings.Join(held, ", ")
|
||||
for _, m := range unplaced {
|
||||
p.Why += "; " + m + " has no registration"
|
||||
}
|
||||
}
|
||||
for i := range p.Movers {
|
||||
m := &p.Movers[i]
|
||||
|
||||
@@ -291,23 +291,41 @@ func TestApprovalEnds(t *testing.T) {
|
||||
}
|
||||
|
||||
// An optional step still waiting (a code review nobody has given) does not hold a pipeline's end; a required one does
|
||||
// (design 47 G A-104).
|
||||
// (design 47 G A-104). A mover with no step placed, waiting on its registration (A-327), holds the end while every placed
|
||||
// mover's required steps passed or one is open, and once a placed one did not pass the pipeline ends failed, naming it
|
||||
// (H-A-163).
|
||||
func TestAnOptionalStepStillWaitingHoldsNoEnd(t *testing.T) {
|
||||
now := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)
|
||||
for name, c := range map[string]struct {
|
||||
review string
|
||||
ends bool
|
||||
}{"optional review waiting": {seat.StepResultStatusOptional, true}, "required review waiting": {seat.StepResultStatusRequired, false}} {
|
||||
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Steps: []seat.StepResult{
|
||||
{Step: seat.StepResultStepBuild, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
||||
{Step: seat.StepResultStepReview, Status: c.review, Outcome: seat.StepResultOutcomeWaiting},
|
||||
{Step: seat.StepResultStepApproval, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
||||
review, build, unit string
|
||||
unregistered bool
|
||||
ends bool
|
||||
outcome string
|
||||
}{
|
||||
"optional review waiting": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, false, true, seat.PipelineOutcomePassed},
|
||||
"required review waiting": {seat.StepResultStatusRequired, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, false, false, ""},
|
||||
"unregistered mover, the placed one passed": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, true, false, ""},
|
||||
"unregistered mover, the placed one failed": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomePassed, true, true, seat.PipelineOutcomeFailed},
|
||||
"unregistered mover, failed and a step open": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomeRunning, true, false, ""},
|
||||
"unregistered mover, the placed one could not run": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomeCouldNotRun, true, true, seat.PipelineOutcomeFailed},
|
||||
} {
|
||||
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app"}}, Steps: []seat.StepResult{
|
||||
{Step: seat.StepResultStepBuild, Module: "app", Status: seat.StepResultStatusRequired, Outcome: c.build},
|
||||
{Step: seat.StepResultStepUnit, Module: "app", Status: seat.StepResultStatusRequired, Outcome: c.unit},
|
||||
{Step: seat.StepResultStepReview, Module: "app", Status: c.review, Outcome: seat.StepResultOutcomeWaiting},
|
||||
{Step: seat.StepResultStepApproval, Module: "app", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
||||
}}
|
||||
if c.unregistered {
|
||||
p.Movers = append(p.Movers, seat.Mover{Module: "contracts"})
|
||||
}
|
||||
if got := endPipeline(&p, now); got != c.ends {
|
||||
t.Errorf("%s: ended = %v, want %v", name, got, c.ends)
|
||||
}
|
||||
if c.ends && p.Outcome != seat.PipelineOutcomePassed {
|
||||
t.Errorf("%s: outcome %s", name, p.Outcome)
|
||||
if c.ends && p.Outcome != c.outcome {
|
||||
t.Errorf("%s: outcome %s, want %s", name, p.Outcome, c.outcome)
|
||||
}
|
||||
if c.ends && c.unregistered && !strings.Contains(p.Why, "contracts has no registration") {
|
||||
t.Errorf("%s: why %q, want it to name the mover waiting on its registration", name, p.Why)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user