P8 publish-reaches-sharing-pipelines: a package-published marks every running pipeline of its branch that moves the module at its fingerprint
Builds: design 47 H2 H-A-707 (6)
This commit is contained in:
@@ -1232,6 +1232,24 @@ func (s *Starter) heardPublished(ev builds.PackagePublished, view func(branch st
|
||||
if !ok {
|
||||
return seat.Pipeline{}, false, nil
|
||||
}
|
||||
p, held, err := s.markPublished(key, ev, view)
|
||||
if !held {
|
||||
return p, false, err
|
||||
}
|
||||
// The same publish reaches every other running pipeline of the branch that moves the publishing module at the fingerprint it
|
||||
// names, so a pipeline sharing the build releases its waiting movers too (design 47 H2 H-A-707 (6)).
|
||||
if ev.Fingerprint != "" {
|
||||
if serr := s.markSharing(ev, key, view); serr != nil {
|
||||
s.logf("a package-published of %s at %s did not reach every pipeline sharing the build: %v", ev.Artifact, ev.Fingerprint, serr)
|
||||
err = errors.Join(err, serr)
|
||||
}
|
||||
}
|
||||
return p, true, err
|
||||
}
|
||||
|
||||
// markPublished writes ev into the publishing mover's published of the running pipeline key and releases the movers that waited for
|
||||
// it; it answers that pipeline, read, and whether one is held.
|
||||
func (s *Starter) markPublished(key string, ev builds.PackagePublished, view func(branch string) (Half, bool)) (seat.Pipeline, bool, error) {
|
||||
for {
|
||||
p, rev, err := s.Store.Get(key)
|
||||
if err != nil {
|
||||
@@ -1255,6 +1273,32 @@ func (s *Starter) heardPublished(ev builds.PackagePublished, view func(branch st
|
||||
}
|
||||
}
|
||||
|
||||
// markSharing marks ev in every running pipeline of its branch, but except, whose mover of the publishing module is at the
|
||||
// fingerprint the publish names (design 47 H2 H-A-707 (6)).
|
||||
func (s *Starter) markSharing(ev builds.PackagePublished, except string, view func(branch string) (Half, bool)) error {
|
||||
pkeys, err := s.Store.Keys(keys.EscapeName(ev.Branch) + ".*")
|
||||
if err != nil {
|
||||
return fmt.Errorf("the pipelines of %s are not listed: %w", ev.Branch, err)
|
||||
}
|
||||
var errs []error
|
||||
for _, k := range pkeys {
|
||||
if k == except {
|
||||
continue
|
||||
}
|
||||
p, _, err := s.Store.Get(k)
|
||||
if err != nil || p.Branch != ev.Branch || p.Run != "" || p.Outcome != seat.PipelineOutcomeRunning {
|
||||
continue
|
||||
}
|
||||
if i := slices.IndexFunc(p.Movers, func(m seat.Mover) bool { return m.Module == ev.Module }); i < 0 || p.Movers[i].Fingerprint != ev.Fingerprint {
|
||||
continue
|
||||
}
|
||||
if _, _, err := s.markPublished(k, ev, view); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
// sourcePipeline is the key of branch's pipeline of the lowest-numbered revision of source, the take-in's (H-A-213 (4),
|
||||
// H-A-218): a pipeline is keyed by its revision, so one of a source is found by the source it names, never by its key.
|
||||
func (s *Starter) sourcePipeline(branch string, source int64) (string, bool) {
|
||||
|
||||
@@ -517,12 +517,16 @@ func testATakeInOfTheOldFormIsRefused(t *testing.T) {
|
||||
// older builder) into its source's lowest-numbered revision, the take-in's.
|
||||
func TestAPublishIsTakenIntoThePipelineOfItsRevision(t *testing.T) {
|
||||
mem := memStore{}
|
||||
for _, r := range []int64{7, 8} {
|
||||
for _, r := range []int64{7, 8, 9} {
|
||||
fp := "src2:a" // the pipelines of revisions 7 and 8 move mesh-sdk at one fingerprint, revision 9's at another (H-A-707 (6))
|
||||
if r == 9 {
|
||||
fp = "src2:b"
|
||||
}
|
||||
mem[Key("main", r)] = struct {
|
||||
p seat.Pipeline
|
||||
rev uint64
|
||||
}{seat.Pipeline{Pipeline: Key("main", r), Branch: "main", Source: 4, Revision: r, Outcome: seat.PipelineOutcomeRunning,
|
||||
Movers: []seat.Mover{{Module: "mesh-sdk"}}}, 1}
|
||||
Movers: []seat.Mover{{Module: "mesh-sdk", Fingerprint: fp}}}, 1}
|
||||
}
|
||||
s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(string, any) error { return nil }}
|
||||
view := func(string) (Half, bool) { return Half{Revision: 8}, true }
|
||||
@@ -535,6 +539,11 @@ func TestAPublishIsTakenIntoThePipelineOfItsRevision(t *testing.T) {
|
||||
if err := s.Published(ev, view); err != nil || len(published("main.7")) != 1 || len(published("main.8")) != 1 {
|
||||
t.Errorf("a publish naming no revision (%v): main.7 %v, main.8 %v; want main.7's, the source's lowest", err, published("main.7"), published("main.8"))
|
||||
}
|
||||
// H2 H-A-707 (6): a publish naming the fingerprint reaches every running pipeline of the branch that moves the module at it
|
||||
ev = builds.PackagePublished{Artifact: "mesh-sdk:py", Module: "mesh-sdk", Branch: "main", Source: 4, Revision: 8, Version: "0.1.18", Fingerprint: "src2:a"}
|
||||
if err := s.Published(ev, view); err != nil || len(published("main.8")) != 2 || len(published("main.7")) != 2 || len(published("main.9")) != 0 {
|
||||
t.Errorf("a publish at src2:a (%v): main.8 %v, main.7 %v, main.9 %v; want both pipelines moving it marked and revision 9's not", err, published("main.8"), published("main.7"), published("main.9"))
|
||||
}
|
||||
}
|
||||
|
||||
// racingStore is memStore whose first Update is preceded by before, a write another part makes between a read and its write.
|
||||
|
||||
Reference in New Issue
Block a user