Compare commits
18
Commits
go/v0.1.24
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
442b03f61d | ||
|
|
fb23967de3 | ||
|
|
07dd8ea842 | ||
|
|
d0436bb38c | ||
|
|
fe51379ee2 | ||
|
|
037cb9555e | ||
|
|
5c5136d6d1 | ||
|
|
c43e7a5d1c | ||
|
|
e04321acae | ||
|
|
4c2914194b | ||
|
|
277c53067e | ||
|
|
227f6e68ce | ||
|
|
521cbf089e | ||
|
|
39a2c6a944 | ||
|
|
577ec05205 | ||
|
|
744204c5ab | ||
|
|
0f41b405ba | ||
|
|
e312999843 |
@@ -222,6 +222,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.RevisionWait = time.Duration(revisionWait) * time.Minute
|
b.RevisionWait = time.Duration(revisionWait) * time.Minute
|
||||||
|
// A step ask naming a package with no pin waits for its release (H-A-165); its bound is package-wait-minutes.
|
||||||
|
packageWait, err := numberFile(getenv("MESH_BUILDER_PACKAGE_WAIT_FILE"), int(build.DefaultPackageWait/time.Minute))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.PackageWait = time.Duration(packageWait) * time.Minute
|
||||||
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
|
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
|
||||||
b.Waits = newWaitsKept(waitsBucket, func(ctx context.Context, event, id string, body any) error {
|
b.Waits = newWaitsKept(waitsBucket, func(ctx context.Context, event, id string, body any) error {
|
||||||
return emitEvent(context.WithoutCancel(ctx), js, cred, event, id, body)
|
return emitEvent(context.WithoutCancel(ctx), js, cred, event, id, body)
|
||||||
@@ -236,6 +242,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
return emitSeatEvent(context.WithoutCancel(ctx), js, cred, meshbuilds.SubjectPackagePublished, "package-published-"+p.Module+"-"+p.Version+"-"+p.Artifact, p)
|
return emitSeatEvent(context.WithoutCancel(ctx), js, cred, meshbuilds.SubjectPackagePublished, "package-published-"+p.Module+"-"+p.Version+"-"+p.Artifact, p)
|
||||||
}
|
}
|
||||||
b.Reserved = reserved
|
b.Reserved = reserved
|
||||||
|
// A release heard, or the newest the builder's record keeps, pins a package an entry names with none (H-A-165).
|
||||||
|
reserved.heardReleased = b.VersionReleased
|
||||||
|
b.NewestReleased = reserved.r.NewestReleased
|
||||||
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
|
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
|
||||||
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
|
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
|
||||||
// A state bound later numbers the builds looked at without it.
|
// A state bound later numbers the builds looked at without it.
|
||||||
|
|||||||
@@ -44,12 +44,15 @@ type reservations struct {
|
|||||||
// built asks a done build's publish (design 47 G A-457a), released ends its item; nil are none.
|
// built asks a done build's publish (design 47 G A-457a), released ends its item; nil are none.
|
||||||
built func(ctx context.Context, module, version string) error
|
built func(ctx context.Context, module, version string) error
|
||||||
released func(ctx context.Context, module, version string)
|
released func(ctx context.Context, module, version string)
|
||||||
filled atomic.Bool
|
// heardReleased is told each version-released taken in (design 47 H H-A-165): a step ask waiting for a package of the
|
||||||
bounds func() jetstream.KeyValue
|
// module wakes. Nil tells nobody.
|
||||||
found *findings
|
heardReleased func(module, version string)
|
||||||
bound time.Duration
|
filled atomic.Bool
|
||||||
wake func(context.Context)
|
bounds func() jetstream.KeyValue
|
||||||
logf func(string, ...any)
|
found *findings
|
||||||
|
bound time.Duration
|
||||||
|
wake func(context.Context)
|
||||||
|
logf func(string, ...any)
|
||||||
// call asks a seat's verb: the git seat's tag (design 47 G §370).
|
// call asks a seat's verb: the git seat's tag (design 47 G §370).
|
||||||
call toolCaller
|
call toolCaller
|
||||||
// say says package-published on the seat mesh-builds; nil says none.
|
// say says package-published on the seat mesh-builds; nil says none.
|
||||||
@@ -252,6 +255,9 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
|||||||
if rv.released != nil {
|
if rv.released != nil {
|
||||||
rv.released(ctx, ev.Module, ev.Version)
|
rv.released(ctx, ev.Module, ev.Version)
|
||||||
}
|
}
|
||||||
|
if rv.heardReleased != nil {
|
||||||
|
rv.heardReleased(ev.Module, ev.Version)
|
||||||
|
}
|
||||||
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -134,10 +134,15 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
|||||||
if err != nil || !strings.Contains(got.Summary, "m:b unpublished") || strings.Contains(got.Summary, "m:a unpublished") || !strings.Contains(got.Summary, "1.4.3") {
|
if err != nil || !strings.Contains(got.Summary, "m:b unpublished") || strings.Contains(got.Summary, "m:a unpublished") || !strings.Contains(got.Summary, "1.4.3") {
|
||||||
t.Fatalf("finding = %+v (%v), want version-unreleased naming m:b of 1.4.3", got, err)
|
t.Fatalf("finding = %+v (%v), want version-unreleased naming m:b of 1.4.3", got, err)
|
||||||
}
|
}
|
||||||
|
var heardReleases []string // H-A-165: a release heard wakes a step ask waiting for a package of the module
|
||||||
|
rv.heardReleased = func(m, v string) { heardReleases = append(heardReleases, m+" "+v) }
|
||||||
released := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"m","version":"1.4.3","source":1,"artifacts":[]}`)}
|
released := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"m","version":"1.4.3","source":1,"artifacts":[]}`)}
|
||||||
if !rv.heard(ctx, released) || !released.acked {
|
if !rv.heard(ctx, released) || !released.acked {
|
||||||
t.Fatalf("version-released was not taken in (acked %v)", released.acked)
|
t.Fatalf("version-released was not taken in (acked %v)", released.acked)
|
||||||
}
|
}
|
||||||
|
if strings.Join(heardReleases, ", ") != "m 1.4.3" {
|
||||||
|
t.Errorf("the release heard was told %v, want m 1.4.3 (H-A-165)", heardReleases)
|
||||||
|
}
|
||||||
if strings.Join(items, ", ") != "asked m 1.4.3, ended m 1.4.3" {
|
if strings.Join(items, ", ") != "asked m 1.4.3, ended m 1.4.3" {
|
||||||
t.Errorf("publish items %v, want the build's end to ask the publish and the release to end it", items)
|
t.Errorf("publish items %v, want the build's end to ask the publish and the release to end it", items)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package build
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// **A build waits for its revision; a build with no version is never made** (design 47 H H-A-155, H-A-156; H-A-141): a step
|
// **A build waits for its revision; a build with no version is never made** (design 47 H H-A-155, H-A-156; H-A-141): a step
|
||||||
@@ -100,3 +103,108 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// **A package with no pin waits for its release** (design 47 H H-A-165, H-A-161): an entry keeps a mesh package none of
|
||||||
|
// whose versions is released with an empty version. Its step ask waits, as for its revision, for the release of the module
|
||||||
|
// that holds the package (the catalog's version-released, VersionReleased), up to PackageWait (the setting
|
||||||
|
// package-wait-minutes), then builds with that release as the package's pin (v<version>); past the bound the step fails,
|
||||||
|
// naming the package, and nothing is built.
|
||||||
|
|
||||||
|
// DefaultPackageWait is the bound of a step ask's wait for a package's release, its setting package-wait-minutes' default.
|
||||||
|
const DefaultPackageWait = 10 * time.Minute
|
||||||
|
|
||||||
|
func (b *Builder) packageWait() time.Duration {
|
||||||
|
if b.PackageWait > 0 {
|
||||||
|
return b.PackageWait
|
||||||
|
}
|
||||||
|
return DefaultPackageWait
|
||||||
|
}
|
||||||
|
|
||||||
|
// VersionReleased takes the catalog's version-released of module in: a step ask waiting for a package of it wakes.
|
||||||
|
func (b *Builder) VersionReleased(module, version string) {
|
||||||
|
b.init()
|
||||||
|
b.mu.Lock()
|
||||||
|
b.releases[module] = version
|
||||||
|
b.mu.Unlock()
|
||||||
|
b.pictureMoved()
|
||||||
|
}
|
||||||
|
|
||||||
|
// releaseOf is the pin a package is built against: the release of the module holding it, as Go names it; "" for none yet.
|
||||||
|
func (b *Builder) releaseOf(ctx context.Context, pkg string) string {
|
||||||
|
if b.Members == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
module, _, found, err := b.Members(ctx, pkg)
|
||||||
|
if err != nil || !found {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
b.mu.Lock()
|
||||||
|
v := b.releases[module]
|
||||||
|
b.mu.Unlock()
|
||||||
|
if v == "" && b.NewestReleased != nil {
|
||||||
|
if kept, ok, err := b.NewestReleased(ctx, module); err == nil && ok {
|
||||||
|
v = kept
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return "v" + v
|
||||||
|
}
|
||||||
|
|
||||||
|
// awaitPins fills each package entry names with no pin from its release, waiting for one; no outcome once every package has
|
||||||
|
// a pin, failed past the bound, could not run at the builder's stop.
|
||||||
|
func (b *Builder) awaitPins(ctx context.Context, entry *meshcatalog.CatalogEntry) (outcome, said string) {
|
||||||
|
var unpinned []string
|
||||||
|
for p, v := range entry.Packages {
|
||||||
|
if v == "" {
|
||||||
|
unpinned = append(unpinned, p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(unpinned) == 0 {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
slices.Sort(unpinned)
|
||||||
|
bound := b.packageWait()
|
||||||
|
wait, stop := context.WithTimeout(ctx, bound) // a context's bound, no timer (ADR 0437 §8)
|
||||||
|
defer stop()
|
||||||
|
pins := map[string]string{}
|
||||||
|
told := false
|
||||||
|
for {
|
||||||
|
b.mu.Lock()
|
||||||
|
moved := b.moved
|
||||||
|
b.mu.Unlock()
|
||||||
|
missing := ""
|
||||||
|
for _, p := range unpinned {
|
||||||
|
if pins[p] == "" {
|
||||||
|
pins[p] = b.releaseOf(ctx, p)
|
||||||
|
}
|
||||||
|
if pins[p] == "" && missing == "" {
|
||||||
|
missing = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if missing == "" {
|
||||||
|
packages := maps.Clone(entry.Packages)
|
||||||
|
maps.Copy(packages, pins)
|
||||||
|
entry.Packages = packages
|
||||||
|
if told {
|
||||||
|
b.logf("%s at %s: every package it names has a released version: built with %v", entry.Module, entry.Fp, pins)
|
||||||
|
}
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
notReleased := fmt.Sprintf("package %s has no released version", missing)
|
||||||
|
if !told {
|
||||||
|
b.logf("%s at %s: %s yet: the ask waits for its release, at most %s", entry.Module, entry.Fp, notReleased, bound)
|
||||||
|
told = true
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-moved:
|
||||||
|
case <-wait.Done():
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return meshbuilds.StepEndedOutcomeCouldNotRun, notReleased + ": the builder stopped before it was"
|
||||||
|
}
|
||||||
|
b.logf("%s at %s: %s within %s: the step fails, nothing is built", entry.Module, entry.Fp, notReleased, bound)
|
||||||
|
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s within %s", notReleased, bound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ type Builder struct {
|
|||||||
// RevisionWait bounds a step ask's wait for its revision, its setting revision-wait-minutes (H-A-156); DefaultRevisionWait
|
// RevisionWait bounds a step ask's wait for its revision, its setting revision-wait-minutes (H-A-156); DefaultRevisionWait
|
||||||
// when 0.
|
// when 0.
|
||||||
RevisionWait time.Duration
|
RevisionWait time.Duration
|
||||||
|
// PackageWait bounds a step ask's wait for the release of a package its entry names with no pin, its setting
|
||||||
|
// package-wait-minutes (H-A-165); DefaultPackageWait when 0. NewestReleased reads the newest version the builder's
|
||||||
|
// record of releases keeps for a module; nil reads none, and only a release heard (VersionReleased) gives a pin.
|
||||||
|
PackageWait time.Duration
|
||||||
|
NewestReleased func(ctx context.Context, module string) (version string, found bool, err error)
|
||||||
// Forms answers what each node's engine states it reads (ADR 0618 §2, ADR 0624 §1): present, the nodes whose engine
|
// Forms answers what each node's engine states it reads (ADR 0618 §2, ADR 0624 §1): present, the nodes whose engine
|
||||||
// answered when last asked, and counted, every node the assignments names, present or away, a node with no statement
|
// answered when last asked, and counted, every node the assignments names, present or away, a node with no statement
|
||||||
// stating nothing (the baseline's first forms). A done key names each artifact in the forms these keep, the oldest in
|
// stating nothing (the baseline's first forms). A done key names each artifact in the forms these keep, the oldest in
|
||||||
@@ -157,6 +162,8 @@ type Builder struct {
|
|||||||
builds map[string]context.CancelCauseFunc
|
builds map[string]context.CancelCauseFunc
|
||||||
// moved is closed and made again at each entry the picture takes in or drops: the step asks waiting for a revision wake.
|
// moved is closed and made again at each entry the picture takes in or drops: the step asks waiting for a revision wake.
|
||||||
moved chan struct{}
|
moved chan struct{}
|
||||||
|
// releases are the versions heard released, by module (VersionReleased): a package with no pin waits for one.
|
||||||
|
releases map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type planned struct {
|
type planned struct {
|
||||||
@@ -187,6 +194,7 @@ func (b *Builder) init() {
|
|||||||
b.hands, b.events = map[string]*handWatch{}, map[string]bool{}
|
b.hands, b.events = map[string]*handWatch{}, map[string]bool{}
|
||||||
b.builds = map[string]context.CancelCauseFunc{}
|
b.builds = map[string]context.CancelCauseFunc{}
|
||||||
b.moved = make(chan struct{})
|
b.moved = make(chan struct{})
|
||||||
|
b.releases = map[string]string{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1106,6 +1114,7 @@ func (b *Builder) runLane(ctx context.Context, l *lane, repository string, m mes
|
|||||||
// The versions of the mesh packages the fingerprint was computed with (novox/hq ADR 0573 §2): the build module writes
|
// The versions of the mesh packages the fingerprint was computed with (novox/hq ADR 0573 §2): the build module writes
|
||||||
// them into the workspace, whatever the repository's go.mod names.
|
// them into the workspace, whatever the repository's go.mod names.
|
||||||
ask.Packages = maps.Clone(m.Packages)
|
ask.Packages = maps.Clone(m.Packages)
|
||||||
|
maps.DeleteFunc(ask.Packages, func(_, v string) bool { return v == "" }) // a package with no released version is no pin (H-A-161)
|
||||||
for _, fb := range req.Builds {
|
for _, fb := range req.Builds {
|
||||||
delete(ask.Packages, fb.Package) // a package `builds` names is named in neither packages nor package (§465)
|
delete(ask.Packages, fb.Package) // a package `builds` names is named in neither packages nor package (§465)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,10 +332,12 @@ func TestABundleAndAnArchiveAreBuiltOnOneNodeAndDone(t *testing.T) { // 1607/AC7
|
|||||||
func TestATrunkFingerprintIsOneAskOnTheDeliveryStream(t *testing.T) {
|
func TestATrunkFingerprintIsOneAskOnTheDeliveryStream(t *testing.T) {
|
||||||
r := newRig(t, goBundle)
|
r := newRig(t, goBundle)
|
||||||
r.asks.Answer = nil // no node has pulled it yet
|
r.asks.Answer = nil // no node has pulled it yet
|
||||||
// Issue 1585 (ADR 0573 §2): the ask carries the package versions the fingerprint was computed with.
|
// Issue 1585 (ADR 0573 §2): the ask carries the module's pins; a package the entry keeps with no version (none
|
||||||
sdk := buildstep.PackageVersions{"git.novox.be/novox/mesh-sdk/go": hex40('5')}
|
// released, design 47 H-A-161) is no pin.
|
||||||
|
sdk := buildstep.PackageVersions{"git.novox.be/novox/mesh-sdk/go": "v0.1.20"}
|
||||||
data, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20",
|
data, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20",
|
||||||
Fp2: fp1, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains), Packages: sdk})
|
Fp2: fp1, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains),
|
||||||
|
Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.20", "git.novox.be/novox/mesh-contracts/go/seats/x": ""}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc
|
|||||||
if entry.Module != e.Module || (e.Commit != "" && entry.Commit != e.Commit) {
|
if entry.Module != e.Module || (e.Commit != "" && entry.Commit != e.Commit) {
|
||||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry of %s at %s is of %s at %s", e.Module, e.Fingerprint, entry.Module, entry.Commit)
|
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry of %s at %s is of %s at %s", e.Module, e.Fingerprint, entry.Module, entry.Commit)
|
||||||
}
|
}
|
||||||
|
// A package the entry names with no pin is built against its release, waited for (H-A-165).
|
||||||
|
if outcome, said := b.awaitPins(ctx, &entry); outcome != "" {
|
||||||
|
return outcome, said
|
||||||
|
}
|
||||||
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
|
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
|
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package build
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -11,6 +13,7 @@ import (
|
|||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||||
|
|
||||||
"mesh-delivery-builder/internal/versions"
|
"mesh-delivery-builder/internal/versions"
|
||||||
@@ -116,6 +119,79 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
|||||||
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
|
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
|
||||||
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
||||||
t.Run("H-A-162: a revision held that changes no entry wakes the ask", aRevisionHeldWakesTheAsk)
|
t.Run("H-A-162: a revision held that changes no entry wakes the ask", aRevisionHeldWakesTheAsk)
|
||||||
|
t.Run("H-A-165: a package with no pin waits for its release and is built with it", aPackageWithNoPinWaitsForItsRelease)
|
||||||
|
t.Run("H-A-165: past its bound a package with no release fails the step", aPackageWithNoReleaseFailsPastItsBound)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpinnedRig is a rig whose step entry m names the package x with no version, built by the module contracts.
|
||||||
|
func unpinnedRig(t *testing.T) (*rig, *fakeReservations) {
|
||||||
|
var held atomic.Int64
|
||||||
|
r, res, entry := revisionRig(t, &held, make(chan struct{}, 1))
|
||||||
|
r.b.Picture = nil // no revision to wait for here
|
||||||
|
entry.Packages = map[string]string{"git.novox.be/novox/mesh-contracts/go/seats/x": "", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}
|
||||||
|
r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { return entry, nil }
|
||||||
|
r.b.Members = func(_ context.Context, pkg string) (string, string, bool, error) {
|
||||||
|
return "contracts", "contracts:x", pkg == "git.novox.be/novox/mesh-contracts/go/seats/x", nil
|
||||||
|
}
|
||||||
|
return r, res
|
||||||
|
}
|
||||||
|
|
||||||
|
func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
|
||||||
|
r, _ := unpinnedRig(t)
|
||||||
|
var once sync.Once
|
||||||
|
looked := make(chan struct{})
|
||||||
|
r.b.NewestReleased = func(context.Context, string) (string, bool, error) { // the record holds none yet
|
||||||
|
once.Do(func() { close(looked) })
|
||||||
|
return "", false, nil
|
||||||
|
}
|
||||||
|
ended := make(chan meshbuilds.StepEnded, 1)
|
||||||
|
go func() {
|
||||||
|
ended <- r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||||
|
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-looked:
|
||||||
|
case end := <-ended:
|
||||||
|
t.Fatalf("the ask ended before the package was released: %+v, asks %+v", end, r.asks.Asks())
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatal("the ask never looked for the package's release")
|
||||||
|
}
|
||||||
|
if _, ok := r.st.vals[r.key]; ok {
|
||||||
|
t.Fatal("the build was made before the package had a release")
|
||||||
|
}
|
||||||
|
r.b.VersionReleased("contracts", "0.1.3")
|
||||||
|
var end meshbuilds.StepEnded
|
||||||
|
select {
|
||||||
|
case end = <-ended:
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatal("the release did not wake the ask")
|
||||||
|
}
|
||||||
|
r.b.Wait()
|
||||||
|
asks := r.asks.Asks()
|
||||||
|
if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(asks) == 0 ||
|
||||||
|
!reflect.DeepEqual(asks[0].Packages, buildstep.PackageVersions{"git.novox.be/novox/mesh-contracts/go/seats/x": "v0.1.3", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}) {
|
||||||
|
t.Errorf("end = %+v, asks %+v; want passed, built with x at v0.1.3", end, asks)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func aPackageWithNoReleaseFailsPastItsBound(t *testing.T) {
|
||||||
|
r, _ := unpinnedRig(t)
|
||||||
|
r.b.PackageWait = time.Nanosecond
|
||||||
|
end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||||
|
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||||
|
r.b.Wait()
|
||||||
|
if _, built := r.st.vals[r.key]; end.Outcome != meshbuilds.StepEndedOutcomeFailed || built ||
|
||||||
|
!strings.Contains(end.Said, "package git.novox.be/novox/mesh-contracts/go/seats/x has no released version") {
|
||||||
|
t.Errorf("end = %+v, built %v; want failed naming the package, nothing built", end, built)
|
||||||
|
}
|
||||||
|
// A release the builder's own record keeps gives the pin at once.
|
||||||
|
r.b.NewestReleased = func(_ context.Context, module string) (string, bool, error) {
|
||||||
|
return "0.1.2", module == "contracts", nil
|
||||||
|
}
|
||||||
|
if end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||||
|
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}); strings.Contains(end.Said, "no released version") {
|
||||||
|
t.Errorf("a release the record keeps did not pin the package: %+v", end)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func aRevisionHeldWakesTheAsk(t *testing.T) {
|
func aRevisionHeldWakesTheAsk(t *testing.T) {
|
||||||
|
|||||||
@@ -295,6 +295,23 @@ func (r *Reserver) ReleasedFor(ctx context.Context, module, fingerprint string)
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewestReleased is the newest version the builder's own record of releases keeps for module (design 47 H H-A-165): a
|
||||||
|
// package with no pin is built against it; false when the record holds none.
|
||||||
|
func (r *Reserver) NewestReleased(ctx context.Context, module string) (string, bool, error) {
|
||||||
|
if r.Releases == nil {
|
||||||
|
return "", false, nil
|
||||||
|
}
|
||||||
|
raw, _, found, err := r.Releases.Get(ctx, ReleasedKey(module))
|
||||||
|
if err != nil || !found {
|
||||||
|
return "", false, err
|
||||||
|
}
|
||||||
|
var rec ReleasedRecord
|
||||||
|
if json.Unmarshal(raw, &rec) != nil || len(rec.Kept) == 0 {
|
||||||
|
return "", false, nil
|
||||||
|
}
|
||||||
|
return rec.Kept[len(rec.Kept)-1].Version, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
|
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
|
||||||
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string) error {
|
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string) error {
|
||||||
n := r.ReleasedKept
|
n := r.ReleasedKept
|
||||||
|
|||||||
@@ -201,11 +201,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
|||||||
t.Errorf("reservations left: %v", all)
|
t.Errorf("reservations left: %v", all)
|
||||||
}
|
}
|
||||||
// One key per module holds the last releases, the oldest dropped (A-456b).
|
// One key per module holds the last releases, the oldest dropped (A-456b).
|
||||||
|
newest := ""
|
||||||
for _, fp := range []string{"src2:b1", "src2:b2"} {
|
for _, fp := range []string{"src2:b1", "src2:b2"} {
|
||||||
n, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp})
|
n, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
newest = n.Version
|
||||||
if _, err := r.Released(ctx, "m", n.Version); err != nil {
|
if _, err := r.Released(ctx, "m", n.Version); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -219,6 +221,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
|||||||
if ok, _ := r.ReleasedFor(ctx, "m", "src2:b2"); !ok {
|
if ok, _ := r.ReleasedFor(ctx, "m", "src2:b2"); !ok {
|
||||||
t.Error("the newest release is not kept")
|
t.Error("the newest release is not kept")
|
||||||
}
|
}
|
||||||
|
// H-A-165: the newest version the record keeps is the pin of a package with none.
|
||||||
|
if v, ok, err := r.NewestReleased(ctx, "m"); !ok || err != nil || v != newest {
|
||||||
|
t.Errorf("newest released of m = %q, %v (%v), want %s", v, ok, err, newest)
|
||||||
|
}
|
||||||
|
if _, ok, _ := r.NewestReleased(ctx, "other"); ok {
|
||||||
|
t.Error("a module never released has a newest release")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b — a build again of a done key replaces
|
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b — a build again of a done key replaces
|
||||||
|
|||||||
@@ -186,9 +186,9 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
|||||||
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
|
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
|
||||||
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
||||||
}
|
}
|
||||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 6 || m.Config["revision-wait-minutes"].Default != float64(2) ||
|
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 7 || m.Config["revision-wait-minutes"].Default != float64(2) || m.Config["package-wait-minutes"].Default != float64(10) ||
|
||||||
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(8) {
|
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(8) {
|
||||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), package-wait-minutes of 10 (H-A-165), the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
||||||
}
|
}
|
||||||
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
||||||
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
||||||
@@ -241,7 +241,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
|||||||
t.Errorf("process = %v", p)
|
t.Errorf("process = %v", p)
|
||||||
}
|
}
|
||||||
env, _ := p["env"].(map[string]any)
|
env, _ := p["env"].(map[string]any)
|
||||||
if len(env) != 7 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
if len(env) != 8 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||||
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
||||||
}
|
}
|
||||||
for k, v := range env {
|
for k, v := range env {
|
||||||
|
|||||||
@@ -155,6 +155,14 @@
|
|||||||
"trusted": false,
|
"trusted": false,
|
||||||
"default": 2
|
"default": 2
|
||||||
},
|
},
|
||||||
|
"package-wait-minutes": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "minutes a build step ask waits for the release of a mesh package its entry names with no pin before it fails, building nothing (design 47 H H-A-165).",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 120,
|
||||||
|
"trusted": false,
|
||||||
|
"default": 10
|
||||||
|
},
|
||||||
"publish-pause": {
|
"publish-pause": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "seconds before a version's second publish try, doubled per try up to publish-pause-max (design 47 G A-457a).",
|
"description": "seconds before a version's second publish try, doubled per try up to publish-pause-max (design 47 G A-457a).",
|
||||||
@@ -239,6 +247,14 @@
|
|||||||
"mode": "0600",
|
"mode": "0600",
|
||||||
"content": "${config:revision-wait-minutes}"
|
"content": "${config:revision-wait-minutes}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "package-wait",
|
||||||
|
"type": "file",
|
||||||
|
"path": "${dir:state}/package-wait-minutes",
|
||||||
|
"owner": "mesh-delivery-builder",
|
||||||
|
"mode": "0600",
|
||||||
|
"content": "${config:package-wait-minutes}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "publish-pause",
|
"id": "publish-pause",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
@@ -286,6 +302,7 @@
|
|||||||
"MESH_BROKER_FILE": "${dir:state}/broker",
|
"MESH_BROKER_FILE": "${dir:state}/broker",
|
||||||
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
||||||
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
|
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
|
||||||
|
"MESH_BUILDER_PACKAGE_WAIT_FILE": "${dir:state}/package-wait-minutes",
|
||||||
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
||||||
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
||||||
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const (
|
|||||||
VerbRerun = "rerun"
|
VerbRerun = "rerun"
|
||||||
VerbAccept = "accept"
|
VerbAccept = "accept"
|
||||||
VerbCancel = "cancel"
|
VerbCancel = "cancel"
|
||||||
|
VerbEndAgain = "end-again"
|
||||||
VerbPlace = "place"
|
VerbPlace = "place"
|
||||||
VerbAskAgain = "ask-again"
|
VerbAskAgain = "ask-again"
|
||||||
VerbTestRuns = "test-runs"
|
VerbTestRuns = "test-runs"
|
||||||
@@ -47,7 +48,7 @@ const (
|
|||||||
|
|
||||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||||
func Verbs() []string {
|
func Verbs() []string {
|
||||||
return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbPlace, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop}
|
return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbEndAgain, VerbPlace, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Events is every event published on the seat's subject: a new copy each call.
|
// Events is every event published on the seat's subject: a new copy each call.
|
||||||
@@ -1195,6 +1196,19 @@ type CancelAnswer struct {
|
|||||||
Pipeline Pipeline `json:"pipeline"`
|
Pipeline Pipeline `json:"pipeline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EndAgainInput is what end-again takes.
|
||||||
|
type EndAgainInput struct {
|
||||||
|
// the pipeline's key
|
||||||
|
Pipeline string `json:"pipeline"`
|
||||||
|
// why, written with the caller the runtime proves in the hand-act log
|
||||||
|
Why string `json:"why"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EndAgainAnswer is what end-again answers.
|
||||||
|
type EndAgainAnswer struct {
|
||||||
|
Pipeline Pipeline `json:"pipeline"`
|
||||||
|
}
|
||||||
|
|
||||||
// PlaceInput is what place takes.
|
// PlaceInput is what place takes.
|
||||||
type PlaceInput struct {
|
type PlaceInput struct {
|
||||||
// the pipeline's key
|
// the pipeline's key
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ func TestFixtures(t *testing.T) {
|
|||||||
decode: func(b []byte) (any, error) { var v TestRunsDropAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
decode: func(b []byte) (any, error) { var v TestRunsDropAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
{name: "place asks a waiting pipeline ahead of its turn, with why", subject: "", given: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}", wire: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}",
|
{name: "place asks a waiting pipeline ahead of its turn, with why", subject: "", given: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}", wire: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}",
|
||||||
decode: func(b []byte) (any, error) { var v PlaceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
decode: func(b []byte) (any, error) { var v PlaceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
|
{name: "end-again asks a running pipeline's end judged once more, with why", subject: "", given: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}", wire: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}",
|
||||||
|
decode: func(b []byte) (any, error) { var v EndAgainInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
v, err := c.decode([]byte(c.given))
|
v, err := c.decode([]byte(c.given))
|
||||||
|
|||||||
@@ -336,5 +336,13 @@
|
|||||||
"pipeline": "main.3590",
|
"pipeline": "main.3590",
|
||||||
"why": "the operator wants the fix out first"
|
"why": "the operator wants the fix out first"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end-again asks a running pipeline's end judged once more, with why",
|
||||||
|
"of": "verb:end-again.input",
|
||||||
|
"given": {
|
||||||
|
"pipeline": "main.20",
|
||||||
|
"why": "a mover waits on its registration and another failed"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -474,6 +474,39 @@
|
|||||||
},
|
},
|
||||||
"class": "act"
|
"class": "act"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "end-again",
|
||||||
|
"description": "A running pipeline's end judged once more, as at a step's end: it ends when it can, failed as soon as it can no longer pass (design 47 H §746, H-A-163, H-A-164). Written in the hand-act log.",
|
||||||
|
"input": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"pipeline": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "the pipeline's key"
|
||||||
|
},
|
||||||
|
"why": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "why, written with the caller the runtime proves in the hand-act log"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"pipeline",
|
||||||
|
"why"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"pipeline": {
|
||||||
|
"$ref": "#/defs/Pipeline"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"pipeline"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class": "act"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "place",
|
"name": "place",
|
||||||
"description": "A waiting pipeline placed ahead of its turn, its steps asked now; written in the hand-act log (design 47 H §748, H-A-53).",
|
"description": "A waiting pipeline placed ahead of its turn, its steps asked now; written in the hand-act log (design 47 H §748, H-A-53).",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export declare const verbs: {
|
|||||||
readonly rerun: "rerun";
|
readonly rerun: "rerun";
|
||||||
readonly accept: "accept";
|
readonly accept: "accept";
|
||||||
readonly cancel: "cancel";
|
readonly cancel: "cancel";
|
||||||
|
readonly endAgain: "end-again";
|
||||||
readonly place: "place";
|
readonly place: "place";
|
||||||
readonly askAgain: "ask-again";
|
readonly askAgain: "ask-again";
|
||||||
readonly testRuns: "test-runs";
|
readonly testRuns: "test-runs";
|
||||||
@@ -683,6 +684,19 @@ export interface CancelAnswer {
|
|||||||
"pipeline": Pipeline;
|
"pipeline": Pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** is what end-again takes. */
|
||||||
|
export interface EndAgainInput {
|
||||||
|
/** the pipeline's key */
|
||||||
|
"pipeline": string;
|
||||||
|
/** why, written with the caller the runtime proves in the hand-act log */
|
||||||
|
"why": string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** is what end-again answers. */
|
||||||
|
export interface EndAgainAnswer {
|
||||||
|
"pipeline": Pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
/** is what place takes. */
|
/** is what place takes. */
|
||||||
export interface PlaceInput {
|
export interface PlaceInput {
|
||||||
/** the pipeline's key */
|
/** the pipeline's key */
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const verbs = {
|
|||||||
rerun: "rerun",
|
rerun: "rerun",
|
||||||
accept: "accept",
|
accept: "accept",
|
||||||
cancel: "cancel",
|
cancel: "cancel",
|
||||||
|
endAgain: "end-again",
|
||||||
place: "place",
|
place: "place",
|
||||||
askAgain: "ask-again",
|
askAgain: "ask-again",
|
||||||
testRuns: "test-runs",
|
testRuns: "test-runs",
|
||||||
|
|||||||
@@ -182,9 +182,9 @@ func containsVia(call toolCaller) func(ctx context.Context, repository, commit,
|
|||||||
var lockFiles = []string{"go.sum", "package-lock.json"}
|
var lockFiles = []string{"go.sum", "package-lock.json"}
|
||||||
|
|
||||||
// readVia reads a repository at a commit as the forge bridge does for a merged message: the seat git's trees, then the
|
// readVia reads a repository at a commit as the forge bridge does for a merged message: the seat git's trees, then the
|
||||||
// module.json and lock files of the one directory dir by its file (a repository can hold hundreds). A manifest the forge
|
// module.json and lock files of the one directory dir by its file (a repository can hold hundreds), and the go.mod beside a
|
||||||
// does not have is an error; a directory with no module.json in the trees is answered with no manifest; a lock file it does
|
// go.sum for its mesh packages (Packages). A manifest the forge does not have is an error; a directory with no module.json in
|
||||||
// not have is left out.
|
// the trees is answered with no manifest; a lock file it does not have is left out.
|
||||||
func readVia(call toolCaller) func(ctx context.Context, repository, sha, dir string) (index.RepoRead, error) {
|
func readVia(call toolCaller) func(ctx context.Context, repository, sha, dir string) (index.RepoRead, error) {
|
||||||
return func(_ context.Context, repository, sha, dir string) (index.RepoRead, error) {
|
return func(_ context.Context, repository, sha, dir string) (index.RepoRead, error) {
|
||||||
a, err := treesOf(call, repository, git.TreesInput{Commit: sha})
|
a, err := treesOf(call, repository, git.TreesInput{Commit: sha})
|
||||||
@@ -222,13 +222,20 @@ func readVia(call toolCaller) func(ctx context.Context, repository, sha, dir str
|
|||||||
out.Locks[dir] = map[string]string{}
|
out.Locks[dir] = map[string]string{}
|
||||||
}
|
}
|
||||||
out.Locks[dir][name] = hex.EncodeToString(sum[:])
|
out.Locks[dir][name] = hex.EncodeToString(sum[:])
|
||||||
if name == "go.sum" {
|
if name != "go.sum" {
|
||||||
if p := fingerprint.MeshPackagesOf([]byte(c)); len(p) > 0 {
|
continue
|
||||||
if out.Packages == nil {
|
}
|
||||||
out.Packages = map[string][]string{}
|
// A Go module's mesh packages are what its go.mod requires, at any version (design 47 H-A-157): its go.sum
|
||||||
}
|
// names none required at the zero version (ADR 0573 §2).
|
||||||
out.Packages[dir] = p // the mesh packages it uses, as the bridge reads them (ADR 0573 §2)
|
mod, absent, err := file(dir, "go.mod")
|
||||||
|
if err != nil {
|
||||||
|
return index.RepoRead{}, fmt.Errorf("%s: %w", path.Join(dir, "go.mod"), err)
|
||||||
|
}
|
||||||
|
if p := fingerprint.MeshRequiresOf([]byte(mod)); !absent && len(p) > 0 {
|
||||||
|
if out.Packages == nil {
|
||||||
|
out.Packages = map[string][]string{}
|
||||||
}
|
}
|
||||||
|
out.Packages[dir] = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ func TestReadViaReadsManifestsAndLocks(t *testing.T) {
|
|||||||
return json.RawMessage(`{"path":"module.json","content":"{\"module\":\"snake\"}"}`), nil
|
return json.RawMessage(`{"path":"module.json","content":"{\"module\":\"snake\"}"}`), nil
|
||||||
case "go.sum":
|
case "go.sum":
|
||||||
return json.RawMessage(`{"path":"go.sum","content":"x"}`), nil
|
return json.RawMessage(`{"path":"go.sum","content":"x"}`), nil
|
||||||
|
case "go.mod": // a mesh package required at the zero version, which no go.sum line names (design 47 H-A-157)
|
||||||
|
return json.RawMessage(`{"path":"go.mod","content":"module snake\n\nrequire (\n\tgit.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000\n)\n"}`), nil
|
||||||
}
|
}
|
||||||
return json.RawMessage(`{"path":"x","absent":true}`), nil
|
return json.RawMessage(`{"path":"x","absent":true}`), nil
|
||||||
}
|
}
|
||||||
@@ -129,12 +131,15 @@ func TestReadViaReadsManifestsAndLocks(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(got.Manifests) != 1 || len(files) != 3 { // the one directory asked: its manifest and two lock files, never the others
|
if len(got.Manifests) != 1 || len(files) != 4 { // the one directory asked: its manifest, two lock files and the go.mod, never the others
|
||||||
t.Fatalf("manifests = %v, files asked = %v", got.Manifests, files)
|
t.Fatalf("manifests = %v, files asked = %v", got.Manifests, files)
|
||||||
}
|
}
|
||||||
if got.Root != "r0" || got.Manifests[""] != `{"module":"snake"}` || len(got.Locks[""]) != 1 || got.Locks[""]["go.sum"] == "" {
|
if got.Root != "r0" || got.Manifests[""] != `{"module":"snake"}` || len(got.Locks[""]) != 1 || got.Locks[""]["go.sum"] == "" {
|
||||||
t.Fatalf("read = %+v", got)
|
t.Fatalf("read = %+v", got)
|
||||||
}
|
}
|
||||||
|
if p := got.Packages[""]; len(p) != 1 || p[0] != "git.novox.be/novox/mesh-sdk/go" {
|
||||||
|
t.Fatalf("mesh packages %v, want mesh-sdk, which the go.mod requires", got.Packages)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fakeRuns records the run events handed to it and answers err.
|
// fakeRuns records the run events handed to it and answers err.
|
||||||
|
|||||||
+10
-4
@@ -58,7 +58,8 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a; ADR 0593 §2 to §4): the indexer whole against
|
// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a; ADR 0593 §2 to §4): the indexer whole against
|
||||||
// the bus. Two Go modules of the catalogue, importer, whose go.sum requires mesh-sdk's Go module, and plain, which requires
|
// the bus. Two Go modules of the catalogue, importer, whose go.mod requires mesh-sdk's Go module at the zero version (no
|
||||||
|
// go.sum line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires
|
||||||
// nothing of it, are taken in with mesh-sdk as main's first source revision. A source revision moving mesh-sdk to a commit
|
// nothing of it, are taken in with mesh-sdk as main's first source revision. A source revision moving mesh-sdk to a commit
|
||||||
// changing its buildstep package is taken in as one revision whose movers are mesh-sdk and importer, of another repository,
|
// changing its buildstep package is taken in as one revision whose movers are mesh-sdk and importer, of another repository,
|
||||||
// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package.
|
// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package.
|
||||||
@@ -67,7 +68,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
sdkGo = "git.novox.be/novox/mesh-sdk/go"
|
sdkGo = "git.novox.be/novox/mesh-sdk/go"
|
||||||
m1, m2 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222"
|
m1, m2 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222"
|
||||||
catalogMerge = "3333333333333333333333333333333333333333"
|
catalogMerge = "3333333333333333333333333333333333333333"
|
||||||
goSumContent = "git.novox.be/novox/mesh-sdk/go v0.1.14 h1:x=\ngit.novox.be/novox/mesh-sdk/go v0.1.14/go.mod h1:y=\n"
|
goModContent = "module importer\n\nrequire git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000\n"
|
||||||
sdkRoot1, sdk2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
sdkRoot1, sdk2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||||
)
|
)
|
||||||
avahi, err := os.ReadFile("../../internal/index/testdata/catalogue-a67f0196-avahi.module.json")
|
avahi, err := os.ReadFile("../../internal/index/testdata/catalogue-a67f0196-avahi.module.json")
|
||||||
@@ -119,7 +120,8 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
forge.put(m2, sdkAt(sdk2, "f6", "7777777777777777777777777777777777777777"))
|
forge.put(m2, sdkAt(sdk2, "f6", "7777777777777777777777777777777777777777"))
|
||||||
forge.put(catalogMerge, repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"},
|
forge.put(catalogMerge, repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"},
|
||||||
files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"),
|
files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"),
|
||||||
"modules/importer/go.sum": goSumContent, "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"}})
|
"modules/importer/go.mod": goModContent, "modules/importer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n",
|
||||||
|
"modules/plain/go.mod": "module plain\n\nrequire golang.org/x/sys v0.1.0\n", "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"}})
|
||||||
regs := registerAvahi(t, ctx, js, "main")
|
regs := registerAvahi(t, ctx, js, "main")
|
||||||
for _, r := range []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}},
|
for _, r := range []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}},
|
||||||
{V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}},
|
{V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}},
|
||||||
@@ -142,7 +144,11 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
say(10, true, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m1}, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-catalog", Commit: catalogMerge})
|
say(10, true, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m1}, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-catalog", Commit: catalogMerge})
|
||||||
heard.next(t, "main", 10)
|
heard.next(t, "main", 10)
|
||||||
heard.acked(t, "main")
|
heard.acked(t, "main")
|
||||||
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != "" && m.Packages[sdkGo] == m1 })
|
// mesh-sdk has released no version: importer keeps the package for its kind-1 edge, with no pin (H-A-161).
|
||||||
|
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool {
|
||||||
|
pin, kept := m.Packages[sdkGo]
|
||||||
|
return m.Fp2 != "" && kept && pin == ""
|
||||||
|
})
|
||||||
plain := untilModule(t, ctx, js, "plain", func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != "" })
|
plain := untilModule(t, ctx, js, "plain", func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != "" })
|
||||||
if _, ok := plain.Packages[sdkGo]; ok {
|
if _, ok := plain.Packages[sdkGo]; ok {
|
||||||
t.Fatalf("plain requires %s: %+v", sdkGo, plain.Packages)
|
t.Fatalf("plain requires %s: %+v", sdkGo, plain.Packages)
|
||||||
|
|||||||
@@ -135,14 +135,32 @@ func NamedTree(manifest string, paths map[string]string) (string, error) {
|
|||||||
return NamedTreePrefix + hex.EncodeToString(sum[:]), nil
|
return NamedTreePrefix + hex.EncodeToString(sum[:]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MeshPackagesOf are the mesh Go modules a go.sum names (the module path of each line under
|
// MeshRequiresOf are the mesh Go modules a go.mod requires (the module path of each `require` line under
|
||||||
// trunk.ForgeModulePrefix), sorted and each once; nil for none. They are what a module with no reported import set
|
// trunk.ForgeModulePrefix, alone or in a block, at any version, the zero version and `// indirect` included), sorted and
|
||||||
// takes the version line of (ADR 0593 §2).
|
// each once; nil for none. They are a module's mesh packages from the take-in, with no build needed (design 47 H-A-157):
|
||||||
func MeshPackagesOf(goSum []byte) []string {
|
// a go.sum names none required at the zero version (ADR 0573 §2), so it is never read for them.
|
||||||
|
func MeshRequiresOf(goMod []byte) []string {
|
||||||
seen := map[string]bool{}
|
seen := map[string]bool{}
|
||||||
for _, line := range strings.Split(string(goSum), "\n") {
|
inBlock := false
|
||||||
|
for _, line := range strings.Split(string(goMod), "\n") {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
if i := strings.Index(line, "//"); i >= 0 {
|
||||||
|
line = strings.TrimSpace(line[:i])
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case line == "require (":
|
||||||
|
inBlock = true
|
||||||
|
continue
|
||||||
|
case inBlock && line == ")":
|
||||||
|
inBlock = false
|
||||||
|
continue
|
||||||
|
case strings.HasPrefix(line, "require "):
|
||||||
|
line = strings.TrimSpace(strings.TrimPrefix(line, "require "))
|
||||||
|
case !inBlock:
|
||||||
|
continue
|
||||||
|
}
|
||||||
f := strings.Fields(line)
|
f := strings.Fields(line)
|
||||||
if len(f) < 2 || !strings.HasPrefix(f[0], trunk.ForgeModulePrefix) {
|
if len(f) != 2 || !strings.HasPrefix(f[0], trunk.ForgeModulePrefix) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, _, ok := trunk.PackageRepository(f[0]); ok {
|
if _, _, ok := trunk.PackageRepository(f[0]); ok {
|
||||||
@@ -405,41 +423,49 @@ func sortedKeys[V any](m map[string]V) []string { return slices.Sorted(maps.Keys
|
|||||||
// commit or no directory, is in missing, sorted; versions is nil when packages is empty.
|
// commit or no directory, is in missing, sorted; versions is nil when packages is empty.
|
||||||
func HeldVersionsOf(packages []string, modules map[string]meshcatalog.ModulesByModuleValue) (versions sdkstep.PackageVersions, missing []string) {
|
func HeldVersionsOf(packages []string, modules map[string]meshcatalog.ModulesByModuleValue) (versions sdkstep.PackageVersions, missing []string) {
|
||||||
for _, pkg := range packages {
|
for _, pkg := range packages {
|
||||||
repository, dir, ok := trunk.PackageRepository(pkg)
|
key := HolderOf(pkg, modules)
|
||||||
commit, depth := "", -1
|
if key == "" {
|
||||||
if ok {
|
|
||||||
for _, key := range slices.Sorted(maps.Keys(modules)) {
|
|
||||||
m := modules[key]
|
|
||||||
if !trunk.SameRepository(m.Repository, repository) || m.Commit == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
at := strings.Trim(m.Path, "/")
|
|
||||||
switch {
|
|
||||||
case at == "":
|
|
||||||
continue // a value that names no directory says nothing of where the package lies
|
|
||||||
case at == meshcatalogclient.RootPath:
|
|
||||||
at = ""
|
|
||||||
case dir != at && !strings.HasPrefix(dir, at+"/"):
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if d := len(at); d > depth {
|
|
||||||
commit, depth = m.Commit, d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if commit == "" {
|
|
||||||
missing = append(missing, pkg)
|
missing = append(missing, pkg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if versions == nil {
|
if versions == nil {
|
||||||
versions = sdkstep.PackageVersions{}
|
versions = sdkstep.PackageVersions{}
|
||||||
}
|
}
|
||||||
versions[pkg] = commit
|
versions[pkg] = modules[key].Commit
|
||||||
}
|
}
|
||||||
slices.Sort(missing)
|
slices.Sort(missing)
|
||||||
return versions, missing
|
return versions, missing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HolderOf is the key of the held module of the package's repository whose directory holds the package's directory (the
|
||||||
|
// deepest, a module at the repository's root holding every directory) and that names a commit; "" for none.
|
||||||
|
func HolderOf(pkg string, modules map[string]meshcatalog.ModulesByModuleValue) string {
|
||||||
|
repository, dir, ok := trunk.PackageRepository(pkg)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
holder, depth := "", -1
|
||||||
|
for _, key := range slices.Sorted(maps.Keys(modules)) {
|
||||||
|
m := modules[key]
|
||||||
|
if !trunk.SameRepository(m.Repository, repository) || m.Commit == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
at := strings.Trim(m.Path, "/")
|
||||||
|
switch {
|
||||||
|
case at == "":
|
||||||
|
continue // a value that names no directory says nothing of where the package lies
|
||||||
|
case at == meshcatalogclient.RootPath:
|
||||||
|
at = ""
|
||||||
|
case dir != at && !strings.HasPrefix(dir, at+"/"):
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d := len(at); d > depth {
|
||||||
|
holder, depth = key, d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return holder
|
||||||
|
}
|
||||||
|
|
||||||
// digestOf is the content digest of the package at import path pkg in a published module, and whether it holds it
|
// digestOf is the content digest of the package at import path pkg in a published module, and whether it holds it
|
||||||
// (its packages are sorted by import path).
|
// (its packages are sorted by import path).
|
||||||
func digestOf(p meshcatalog.PackagesByModuleValue, pkg string) (string, bool) {
|
func digestOf(p meshcatalog.PackagesByModuleValue, pkg string) (string, bool) {
|
||||||
@@ -455,3 +481,21 @@ func digestOf(p meshcatalog.PackagesByModuleValue, pkg string) (string, bool) {
|
|||||||
// NamedTreePrefix opens a module's tree when it is computed over the paths its artifacts name, not the directory's own
|
// NamedTreePrefix opens a module's tree when it is computed over the paths its artifacts name, not the directory's own
|
||||||
// git tree (novox/hq ADR 0499 clause 2): the indexer alone computes it (NamedTree).
|
// git tree (novox/hq ADR 0499 clause 2): the indexer alone computes it (NamedTree).
|
||||||
const NamedTreePrefix = "named:"
|
const NamedTreePrefix = "named:"
|
||||||
|
|
||||||
|
// WithPins is the fingerprint fp with the pins a build of it is made against (design 47 H-A-167): fp itself when no
|
||||||
|
// package is pinned, else `src2:` and the hex sha256 of fp and, sorted, the lines "pin <package> <version>" of each pin,
|
||||||
|
// joined by a newline. A package kept with no version (none released) is no pin.
|
||||||
|
func WithPins(fp string, pins sdkstep.PackageVersions) string {
|
||||||
|
var lines []string
|
||||||
|
for p, v := range pins {
|
||||||
|
if v != "" {
|
||||||
|
lines = append(lines, "pin "+p+" "+v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if fp == "" || len(lines) == 0 {
|
||||||
|
return fp
|
||||||
|
}
|
||||||
|
sort.Strings(lines)
|
||||||
|
sum := sha256.Sum256([]byte(fp + "\n" + strings.Join(lines, "\n")))
|
||||||
|
return meshcatalogclient.SourcePrefix2 + hex.EncodeToString(sum[:])
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,20 @@ func versionLineTakesASiblingDirectoryByItsContent(t *testing.T) {
|
|||||||
if got := ReplacedSiblings(goMod, repo); len(got) != 1 || got[0] != buildrun {
|
if got := ReplacedSiblings(goMod, repo); len(got) != 1 || got[0] != buildrun {
|
||||||
t.Fatalf("siblings %v, want buildrun alone (mesh-sdk is another repository, replaced by a version)", got)
|
t.Fatalf("siblings %v, want buildrun alone (mesh-sdk is another repository, replaced by a version)", got)
|
||||||
}
|
}
|
||||||
|
// Its mesh packages are every mesh package its go.mod requires, at any version, the zero version included (design 47
|
||||||
|
// H-A-157); a replace line or a module outside the forge is none.
|
||||||
|
for _, c := range []struct {
|
||||||
|
goMod string
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
{string(goMod), []string{buildrun, sdk}},
|
||||||
|
{"module x\n\nrequire " + sdk + " v0.0.0-00010101000000-000000000000 // indirect\nrequire github.com/nats-io/nats.go v1.37.0\n", []string{sdk}},
|
||||||
|
{"module x\n\nreplace " + sdk + " => ../sdk\n", nil},
|
||||||
|
} {
|
||||||
|
if got := MeshRequiresOf([]byte(c.goMod)); strings.Join(got, ",") != strings.Join(c.want, ",") {
|
||||||
|
t.Errorf("mesh packages of %q: %v, want %v", c.goMod, got, c.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
published := func(digest string) map[string]meshcatalog.PackagesByModuleValue {
|
published := func(digest string) map[string]meshcatalog.PackagesByModuleValue {
|
||||||
return map[string]meshcatalog.PackagesByModuleValue{buildrun: {Module: buildrun, Repository: repo, Requires: "r1",
|
return map[string]meshcatalog.PackagesByModuleValue{buildrun: {Module: buildrun, Repository: repo, Requires: "r1",
|
||||||
Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: buildrun, Digest: digest}}}}
|
Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: buildrun, Digest: digest}}}}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ import (
|
|||||||
type form struct {
|
type form struct {
|
||||||
fp, none string
|
fp, none string
|
||||||
versions sdkstep.PackageVersions
|
versions sdkstep.PackageVersions
|
||||||
|
// stands: fp is the held fingerprint of the build that reported the imports, made with the pins built (its held
|
||||||
|
// packages) from the import form raw; pinnedOf keeps it while the pins are those (H-A-172).
|
||||||
|
stands bool
|
||||||
|
raw string
|
||||||
|
built map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the
|
// formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the
|
||||||
@@ -24,15 +29,16 @@ type form struct {
|
|||||||
//
|
//
|
||||||
// - **The import form**, for a module whose last trunk build reported its imports (kept.Imports) when every import is
|
// - **The import form**, for a module whose last trunk build reported its imports (kept.Imports) when every import is
|
||||||
// published (the packages state): the content digest of each imported package and the requirements' digest of each
|
// published (the packages state): the content digest of each imported package and the requirements' digest of each
|
||||||
// mesh Go module holding one. Its versions are each holding module's published commit (another repository's only).
|
// mesh Go module holding one. Its versions are each holding module's published commit (another repository's only); an
|
||||||
|
// import set naming none of another repository while the go.mod requires one keeps the version line's (refined).
|
||||||
// - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs
|
// - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs
|
||||||
// the build that reported the imports was built from. While the import form computes to it, nothing the build was
|
// the build that reported the imports was built from. While the import form computes to it, nothing the build was
|
||||||
// built from changed: the module keeps the fingerprint it holds (prev), in whatever form, and its versions.
|
// built from changed: the module keeps the fingerprint it holds (prev), in whatever form, and its versions.
|
||||||
// Otherwise the import form is written, and ImportForm moves with it.
|
// Otherwise the import form is written, and ImportForm moves with it.
|
||||||
// - **The version line** otherwise (no import set, or an import none publishes): the version of each mesh Go module of
|
// - **The version line** otherwise (no import set, or an import none publishes): the version of each mesh Go module of
|
||||||
// another repository its go.sum names, read as the indexer always read it (fingerprint.HeldVersionsOf), and the
|
// another repository its go.mod requires, at any version (design 47 H-A-157), read as the indexer always read it
|
||||||
// content of each mesh Go module of its own repository its go.mod replaces by a directory (fingerprint.VersionLine),
|
// (fingerprint.HeldVersionsOf), and the content of each mesh Go module of its own repository its go.mod replaces by a
|
||||||
// so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone.
|
// directory (fingerprint.VersionLine), so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone.
|
||||||
// A package of another repository none of them publishes takes the commit the gate's source names for its repository
|
// A package of another repository none of them publishes takes the commit the gate's source names for its repository
|
||||||
// (heads, design 47 G A-365).
|
// (heads, design 47 G A-365).
|
||||||
// - **An accepted series** (DLV-I6): published and pins come from acceptedSeries, so a mesh Go module of another
|
// - **An accepted series** (DLV-I6): published and pins come from acceptedSeries, so a mesh Go module of another
|
||||||
@@ -51,10 +57,12 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
|||||||
case fp == "":
|
case fp == "":
|
||||||
return form{none: none}
|
return form{none: none}
|
||||||
case kept.ImportForm == fp && prev.Fp2 != "":
|
case kept.ImportForm == fp && prev.Fp2 != "":
|
||||||
return form{fp: prev.Fp2, versions: prev.Packages} // the build that reported the imports stands
|
// The build that reported the imports stands, and so do its versions.
|
||||||
|
return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins, heads),
|
||||||
|
stands: true, raw: fp, built: prev.Packages}
|
||||||
}
|
}
|
||||||
kept.ImportForm = fp
|
kept.ImportForm = fp
|
||||||
return form{fp: fp, versions: r.Versions}
|
return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)}
|
||||||
}
|
}
|
||||||
if logf != nil {
|
if logf != nil {
|
||||||
logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", "))
|
logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", "))
|
||||||
@@ -63,6 +71,34 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
|||||||
// The fingerprint written here is the version line's, not the import form's: no import form is held for the inputs it was
|
// The fingerprint written here is the version line's, not the import form's: no import form is held for the inputs it was
|
||||||
// computed from, so a later pass whose import form computes the same does not take this one for the build's (issue 1966).
|
// computed from, so a later pass whose import form computes the same does not take this one for the build's (issue 1966).
|
||||||
kept.ImportForm = ""
|
kept.ImportForm = ""
|
||||||
|
versions := lineVersions(module, repository, kept, held, pins, heads, logf)
|
||||||
|
in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published)
|
||||||
|
fp, none := fingerprint.Of(in)
|
||||||
|
if fp == "" {
|
||||||
|
return form{none: none}
|
||||||
|
}
|
||||||
|
return form{fp: fp, versions: versions}
|
||||||
|
}
|
||||||
|
|
||||||
|
// refined are an import form's versions: the first of sets that names a package, else, while the module's go.mod
|
||||||
|
// requires a mesh package of another repository (kept.Packages), the version line's, so a build's reported imports
|
||||||
|
// refine the go.mod's set and never empty it (design 47 H-A-157); nil when nothing names one.
|
||||||
|
func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) sdkstep.PackageVersions {
|
||||||
|
switch {
|
||||||
|
case len(versions) > 0:
|
||||||
|
return versions
|
||||||
|
case len(then) > 0:
|
||||||
|
return then
|
||||||
|
case len(fingerprint.OtherPackages(kept.Packages, repository)) > 0:
|
||||||
|
return lineVersions(module, repository, kept, held, pins, heads, nil)
|
||||||
|
}
|
||||||
|
return versions
|
||||||
|
}
|
||||||
|
|
||||||
|
// lineVersions are the version line's versions of the mesh Go modules of other repositories the module's go.mod requires
|
||||||
|
// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it, else the commit the gate's
|
||||||
|
// source names for its repository.
|
||||||
|
func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, logf func(string, ...any)) sdkstep.PackageVersions {
|
||||||
others := fingerprint.OtherPackages(kept.Packages, repository)
|
others := fingerprint.OtherPackages(kept.Packages, repository)
|
||||||
versions, unpublished := fingerprint.HeldVersionsOf(others, held)
|
versions, unpublished := fingerprint.HeldVersionsOf(others, held)
|
||||||
for p, v := range pins { // an accepted series' newest published version (acceptedSeries, DLV-I6)
|
for p, v := range pins { // an accepted series' newest published version (acceptedSeries, DLV-I6)
|
||||||
@@ -90,12 +126,7 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
|||||||
if len(unpublished) > 0 && logf != nil {
|
if len(unpublished) > 0 && logf != nil {
|
||||||
logf("%s: no module the indexer holds publishes %s, so its fingerprint takes no version of it", module, strings.Join(unpublished, ", "))
|
logf("%s: no module the indexer holds publishes %s, so its fingerprint takes no version of it", module, strings.Join(unpublished, ", "))
|
||||||
}
|
}
|
||||||
in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published)
|
return versions
|
||||||
fp, none := fingerprint.Of(in)
|
|
||||||
if fp == "" {
|
|
||||||
return form{none: none}
|
|
||||||
}
|
|
||||||
return form{fp: fp, versions: versions}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// inputsFrom is the fingerprint's inputs of module m from its kept inputs and the given toolchains, no package of
|
// inputsFrom is the fingerprint's inputs of module m from its kept inputs and the given toolchains, no package of
|
||||||
|
|||||||
@@ -118,10 +118,27 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
moved, _ := moduleOf(t, mods, "avahi")
|
moved, _ := moduleOf(t, mods, "avahi")
|
||||||
if moved.Fp2 == before.Fp2 || moved.Fp2 != moved.Inputs2.ImportForm || moved.Packages[meshSDK] != c3 {
|
if pin, kept := moved.Packages[meshSDK]; moved.Fp2 == before.Fp2 || moved.Fp2 != moved.Inputs2.ImportForm || !kept || pin != "" {
|
||||||
t.Fatalf("a change of an imported package: fp2 %q (was %q), import form %q, versions %v; want the import form at c3",
|
t.Fatalf("a change of an imported package: fp2 %q (was %q), import form %q, versions %v; want the import form, mesh-sdk kept unpinned (none released, H-A-161)",
|
||||||
moved.Fp2, before.Fp2, moved.Inputs2.ImportForm, moved.Packages)
|
moved.Fp2, before.Fp2, moved.Inputs2.ImportForm, moved.Packages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mesh-sdk releases 0.1.20: the import form's fingerprint takes the pin too and moves, once (H-A-172).
|
||||||
|
ix.Versions = newMem()
|
||||||
|
ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.20"), []byte(`{}`))
|
||||||
|
for range 2 {
|
||||||
|
if err := ix.Recompute(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == moved.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm {
|
||||||
|
t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want a new fingerprint pinned to v0.1.20, the import form kept",
|
||||||
|
m.Fp2, moved.Fp2, m.Packages, m.Inputs2.ImportForm)
|
||||||
|
} else if err := ix.Recompute(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if again, _ := moduleOf(t, mods, "avahi"); again.Fp2 != m.Fp2 {
|
||||||
|
t.Fatalf("a pass with nothing moved moved the pinned fingerprint %q to %q", m.Fp2, again.Fp2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A build of a fingerprint the module no longer holds says nothing of its inputs now: its imports are not kept.
|
// A build of a fingerprint the module no longer holds says nothing of its inputs now: its imports are not kept.
|
||||||
@@ -256,8 +273,8 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
before := step("trunk at c1", trunk(c1))
|
before := step("trunk at c1", trunk(c1))
|
||||||
if before.Packages[meshSDK] != c1 {
|
if pin, kept := before.Packages[meshSDK]; !kept || pin != "" {
|
||||||
t.Fatalf("with no series published, versions %v, want the commit form c1", before.Packages)
|
t.Fatalf("with no series published, versions %v, want mesh-sdk kept with no pin, never the commit (H-A-161)", before.Packages)
|
||||||
}
|
}
|
||||||
step("the build reports its imports", func() error {
|
step("the build reports its imports", func() error {
|
||||||
return ix.ApplyBuildEnd(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce"))
|
return ix.ApplyBuildEnd(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce"))
|
||||||
@@ -272,6 +289,12 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) {
|
|||||||
if m := step("trunk at c2", trunk(c2)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" {
|
if m := step("trunk at c2", trunk(c2)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" {
|
||||||
t.Errorf("a trunk merge moved avahi off its accepted series' newest: %q %v", m.Fp2, m.Packages)
|
t.Errorf("a trunk merge moved avahi off its accepted series' newest: %q %v", m.Fp2, m.Packages)
|
||||||
}
|
}
|
||||||
|
// mesh-sdk releases 0.1.20: an accepted series' older version never stands over a newer release (H-A-167).
|
||||||
|
ix.Versions = newMem()
|
||||||
|
ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.20"), []byte(`{}`))
|
||||||
|
if m := step("0.1.20 released", func() error { return nil }); m.Packages[meshSDK] != "v0.1.20" {
|
||||||
|
t.Errorf("a newer release left avahi on its series' older version: %v", m.Packages)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue 1966 (the indexer started while the bus's storage was down): a read of the packages state that failed, or that
|
// Issue 1966 (the indexer started while the bus's storage was down): a read of the packages state that failed, or that
|
||||||
@@ -370,22 +393,36 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t *
|
|||||||
head := strings.Repeat("c", 40)
|
head := strings.Repeat("c", 40)
|
||||||
contracts := "git.novox.be/novox/mesh-contracts/go/seats/findings"
|
contracts := "git.novox.be/novox/mesh-contracts/go/seats/findings"
|
||||||
held := map[string]meshcatalog.ModulesByModuleValue{"other": {Repository: "novox/mesh-sdk", Commit: strings.Repeat("d", 40), Path: "go"}}
|
held := map[string]meshcatalog.ModulesByModuleValue{"other": {Repository: "novox/mesh-sdk", Commit: strings.Repeat("d", 40), Path: "go"}}
|
||||||
|
// A build's imports of its own repository alone (design 47 H-A-157): they refine the go.mod's set and never empty it.
|
||||||
|
own := "git.novox.be/novox/mesh-catalog/modules/avahi/lib"
|
||||||
|
published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: head, Requires: "r1",
|
||||||
|
Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: own, Digest: "d1"}}}}
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
name string
|
name string
|
||||||
heads map[string]string
|
heads map[string]string
|
||||||
held map[string]meshcatalog.ModulesByModuleValue
|
held map[string]meshcatalog.ModulesByModuleValue
|
||||||
want string
|
imports []string
|
||||||
|
want string
|
||||||
}{
|
}{
|
||||||
{"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, head},
|
{"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, nil, head},
|
||||||
{"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, ""},
|
{"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, nil, ""},
|
||||||
{"a module the indexer holds publishes it", map[string]string{"novox/mesh-contracts": head},
|
{"a module the indexer holds publishes it", map[string]string{"novox/mesh-contracts": head},
|
||||||
map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, strings.Repeat("e", 40)},
|
map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, nil, strings.Repeat("e", 40)},
|
||||||
|
{"a build's imports naming none of another repository keep the go.mod's", map[string]string{"novox/mesh-contracts": head}, held, []string{own}, head},
|
||||||
} {
|
} {
|
||||||
kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}}
|
kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports}
|
||||||
f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, nil, nil, c.heads, nil)
|
f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, c.heads, nil)
|
||||||
if got := f.versions[contracts]; got != c.want {
|
if got := f.versions[contracts]; got != c.want {
|
||||||
t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want)
|
t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want)
|
||||||
}
|
}
|
||||||
|
if c.imports == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// The build that reported them stands, its held versions empty (a version line read from go.sum).
|
||||||
|
f = formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{Fp2: "src2:" + strings.Repeat("b", 64)}, c.held, published, nil, c.heads, nil)
|
||||||
|
if got := f.versions[contracts]; got != c.want || f.fp != "src2:"+strings.Repeat("b", 64) {
|
||||||
|
t.Errorf("%s, the build standing: version of %s = %q (fp %q), want %q", c.name, contracts, got, f.fp, c.want)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) {
|
t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (ix *Indexer) applyMoving(ctx context.Context, f whole, drop bool, moves ma
|
|||||||
if next.Manifest == "" {
|
if next.Manifest == "" {
|
||||||
next.None2 = "the manifest cannot be read: it cannot be kept as a value"
|
next.None2 = "the manifest cannot be read: it cannot be kept as a value"
|
||||||
} else {
|
} else {
|
||||||
packages := ix.goSumPackages(ctx, f, dir, cur, has)
|
packages := ix.goPackages(ctx, f, dir, cur, has)
|
||||||
in := inputsOfNamed(name, raw, f.Trees[dir], f.Locks[dir], objects[dir], packages, ix.baseFP(ctx))
|
in := inputsOfNamed(name, raw, f.Trees[dir], f.Locks[dir], objects[dir], packages, ix.baseFP(ctx))
|
||||||
next.Inputs2, next.None2, next.Paths = in.Kept, in.None2, in.ArtifactPaths
|
next.Inputs2, next.None2, next.Paths = in.Kept, in.None2, in.ArtifactPaths
|
||||||
if in.Kept != nil && has && cur.Inputs2 != nil {
|
if in.Kept != nil && has && cur.Inputs2 != nil {
|
||||||
@@ -365,79 +365,72 @@ func unreadInputs(tree string, locks, paths map[string]string, packages []string
|
|||||||
return in
|
return in
|
||||||
}
|
}
|
||||||
|
|
||||||
// goSumPackages are the version line's packages of the merge's directory dir (ADR 0573 §2, ADR 0593 §2): the mesh Go
|
// goPackages are the version line's packages of the merge's directory dir (ADR 0593 §2; design 47 H-A-157): the mesh Go
|
||||||
// modules of other repositories its go.sum names, and those of its own repository its go.mod replaces by a directory
|
// modules of other repositories its go.mod requires, at any version, and those of its own repository its go.mod replaces
|
||||||
// (siblingPackages), which no go.sum line names. A directory with no go.sum is no Go module and has none.
|
// by a directory (siblingPackages, H-A-136's sibling rule). A directory with no go.sum is no Go module and has none.
|
||||||
func (ix *Indexer) goSumPackages(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) []string {
|
func (ix *Indexer) goPackages(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) []string {
|
||||||
others := ix.otherPackages(ctx, f, dir, cur, has)
|
|
||||||
if f.Locks[dir]["go.sum"] == "" && len(f.Packages[dir]) == 0 {
|
if f.Locks[dir]["go.sum"] == "" && len(f.Packages[dir]) == 0 {
|
||||||
return others
|
return nil
|
||||||
|
}
|
||||||
|
ix.requirementsOf(ctx, f, dir, cur, has)
|
||||||
|
goMod, read := ix.goModOf(ctx, f, dir)
|
||||||
|
others := fingerprint.OtherPackages(f.Packages[dir], f.Repository) // carried: what the go.mod requires, read with the tree
|
||||||
|
switch {
|
||||||
|
case len(others) > 0:
|
||||||
|
case read:
|
||||||
|
others = fingerprint.OtherPackages(fingerprint.MeshRequiresOf(goMod), f.Repository)
|
||||||
|
case has && cur.Inputs2 != nil:
|
||||||
|
others = fingerprint.OtherPackages(cur.Inputs2.Packages, f.Repository)
|
||||||
|
}
|
||||||
|
var siblings []string
|
||||||
|
if read {
|
||||||
|
siblings = fingerprint.ReplacedSiblings(goMod, f.Repository)
|
||||||
|
} else if has && cur.Inputs2 != nil {
|
||||||
|
for _, p := range cur.Inputs2.Packages {
|
||||||
|
if repo, _, ok := trunk.PackageRepository(p); ok && trunk.SameRepository(repo, f.Repository) {
|
||||||
|
siblings = append(siblings, p)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
siblings := ix.siblingPackages(ctx, f, dir, cur, has)
|
|
||||||
if len(siblings) == 0 {
|
if len(siblings) == 0 {
|
||||||
return others
|
return others
|
||||||
}
|
}
|
||||||
return slices.Compact(slices.Sorted(slices.Values(append(slices.Clone(others), siblings...))))
|
return slices.Compact(slices.Sorted(slices.Values(append(slices.Clone(others), siblings...))))
|
||||||
}
|
}
|
||||||
|
|
||||||
// siblingPackages are the mesh Go modules of the merge's own repository the go.mod of dir replaces by a directory, read
|
// goModOf is the go.mod of the merge's directory dir, read from the forge (GoMod), and whether it was read; where it
|
||||||
// from the forge (GoMod); where it cannot be read, the held module's own-repository packages stand, said.
|
// cannot be, the held module's packages stand, said.
|
||||||
func (ix *Indexer) siblingPackages(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) []string {
|
func (ix *Indexer) goModOf(ctx context.Context, f whole, dir string) ([]byte, bool) {
|
||||||
held := func() []string {
|
|
||||||
if !has || cur.Inputs2 == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var out []string
|
|
||||||
for _, p := range cur.Inputs2.Packages {
|
|
||||||
if repo, _, ok := trunk.PackageRepository(p); ok && trunk.SameRepository(repo, f.Repository) {
|
|
||||||
out = append(out, p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
if ix.GoMod == nil {
|
if ix.GoMod == nil {
|
||||||
return held()
|
return nil, false
|
||||||
}
|
}
|
||||||
raw, err := ix.GoMod(ctx, f.Repository, f.Merge, dir)
|
raw, err := ix.GoMod(ctx, f.Repository, f.Merge, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ix.logf("%s at %s: the go.mod of %q cannot be read, so its module keeps the directory replaces it held: %v", f.Repository, f.Merge, dir, err)
|
ix.logf("%s at %s: the go.mod of %q cannot be read, so its module keeps the packages it held: %v", f.Repository, f.Merge, dir, err)
|
||||||
return held()
|
return nil, false
|
||||||
}
|
}
|
||||||
return fingerprint.ReplacedSiblings(raw, f.Repository)
|
return raw, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherPackages are the mesh Go modules of other repositories the go.sum of the merge's directory dir names: those the
|
// requirementsOf keeps what the go.sum of the merge's directory dir requires in the requirements state
|
||||||
// message carries (an older bridge), else the held module's while its go.sum's hash is unchanged, else the go.sum read
|
// (keepRequirements): read from the forge (GoSum) when its hash moved, or this process has not kept it yet, whatever
|
||||||
// from the forge (GoSum).
|
// packages the reader carried. It gives no package: those are the go.mod's (H-A-157).
|
||||||
func (ix *Indexer) otherPackages(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) []string {
|
func (ix *Indexer) requirementsOf(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) {
|
||||||
if carried := f.Packages[dir]; len(carried) > 0 {
|
|
||||||
return fingerprint.OtherPackages(carried, f.Repository) // its own repository's come with its tree
|
|
||||||
}
|
|
||||||
hash := f.Locks[dir]["go.sum"]
|
hash := f.Locks[dir]["go.sum"]
|
||||||
if hash == "" {
|
if hash == "" || ix.GoSum == nil {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
if has && cur.Inputs2 != nil && trunk.SameRepository(cur.Repository, f.Repository) && ix.requirementsKept(f.Repository, dir) {
|
if has && cur.Inputs2 != nil && trunk.SameRepository(cur.Repository, f.Repository) && ix.requirementsKept(f.Repository, dir) {
|
||||||
for _, h := range cur.Inputs2.Locks {
|
for _, h := range cur.Inputs2.Locks {
|
||||||
if h == hash {
|
if h == hash {
|
||||||
return fingerprint.OtherPackages(cur.Inputs2.Packages, f.Repository)
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ix.GoSum == nil {
|
|
||||||
if has && cur.Inputs2 != nil {
|
|
||||||
return fingerprint.OtherPackages(cur.Inputs2.Packages, f.Repository)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
raw, err := ix.GoSum(ctx, f.Repository, f.Merge, dir)
|
raw, err := ix.GoSum(ctx, f.Repository, f.Merge, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ix.logf("%s at %s: the go.sum of %q cannot be read, so its module keeps the packages it held: %v", f.Repository, f.Merge, dir, err)
|
ix.logf("%s at %s: the go.sum of %q cannot be read, so what it requires is not kept: %v", f.Repository, f.Merge, dir, err)
|
||||||
if has && cur.Inputs2 != nil {
|
return
|
||||||
return fingerprint.OtherPackages(cur.Inputs2.Packages, f.Repository)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
ix.keepRequirements(ctx, f.Repository, dir, raw)
|
ix.keepRequirements(ctx, f.Repository, dir, raw)
|
||||||
return fingerprint.OtherPackages(fingerprint.MeshPackagesOf(raw), f.Repository)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -401,8 +401,36 @@ func TestARootModuleHasTheDirectoryDot(t *testing.T) { // 1615/AC3: empty means
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t *testing.T) { // I1: issue 1851, ADR 0501 clause 6
|
func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t *testing.T) { // I1: issue 1851, ADR 0501 clause 6
|
||||||
ix, mods, _ := manifestsIndexer(t) // no build record of any module
|
|
||||||
avahi := catalogueManifest(t, "avahi")
|
avahi := catalogueManifest(t, "avahi")
|
||||||
|
// Its go.mod requires mesh-sdk at the zero version (ADR 0573 §2): the go.mod's require lines are its mesh packages, with
|
||||||
|
// no build, carried by the reader or read through GoMod (design 47 H-A-157). Its go.sum is still read for the
|
||||||
|
// requirements state, carried packages or not, so an older version it names is kept there (and cleared when gone).
|
||||||
|
for _, carried := range [][]string{nil, {meshSDK}} {
|
||||||
|
ix, mods, _ := manifestsIndexer(t)
|
||||||
|
ix.Requirements = newMem()
|
||||||
|
ix.GoMod = func(context.Context, string, string, string) ([]byte, error) {
|
||||||
|
return []byte("module avahi\n\nrequire " + meshSDK + " v0.0.0-00010101000000-000000000000\n"), nil
|
||||||
|
}
|
||||||
|
ix.GoSum = func(context.Context, string, string, string) ([]byte, error) {
|
||||||
|
return []byte(meshSDK + " v0.1.14 h1:x=\n"), nil
|
||||||
|
}
|
||||||
|
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
||||||
|
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
||||||
|
if carried != nil {
|
||||||
|
f.Packages = map[string][]string{"modules/avahi": carried}
|
||||||
|
}
|
||||||
|
if err := ix.Apply(context.Background(), f); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
m, _ := moduleOf(t, mods, "avahi")
|
||||||
|
if m.Inputs2 == nil || !slices.Equal(m.Inputs2.Packages, []string{meshSDK}) {
|
||||||
|
t.Errorf("carried %v: mesh packages %+v, want mesh-sdk, which its go.mod requires at the zero version", carried, m.Inputs2)
|
||||||
|
}
|
||||||
|
if _, kept := ix.Requirements.(*memStore).vals[meshSDK]; !kept {
|
||||||
|
t.Errorf("carried %v: the requirements state holds no %s, which the go.sum names", carried, meshSDK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ix, mods, _ := manifestsIndexer(t) // no build record of any module
|
||||||
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
||||||
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
||||||
if err := ix.Apply(context.Background(), f); err != nil {
|
if err := ix.Apply(context.Background(), f); err != nil {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (r Requirement) Versions() []string {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredOf is, per mesh Go module a go.sum names (as fingerprint.MeshPackagesOf takes them), the highest version it
|
// RequiredOf is, per mesh Go module a go.sum names (a line under trunk.ForgeModulePrefix whose path names a repository), the highest version it
|
||||||
// names, its module line or its go.mod line alike.
|
// names, its module line or its go.mod line alike.
|
||||||
func RequiredOf(goSum []byte) map[string]string {
|
func RequiredOf(goSum []byte) map[string]string {
|
||||||
out := map[string]string{}
|
out := map[string]string{}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (ix *Indexer) SeedModulesFrom(ctx context.Context, defs map[string]seatdef.
|
|||||||
seat := seatOf[a.Ref]
|
seat := seatOf[a.Ref]
|
||||||
sa := SeedArtifact{Name: name, Seat: seat}
|
sa := SeedArtifact{Name: name, Seat: seat}
|
||||||
in := nodebuildgo.StepsInput{Module: e.Module, Artifact: nodebuildgo.DetectedStepsByModuleArtifactKey(e.Module, name), Fingerprint: e.Fp,
|
in := nodebuildgo.StepsInput{Module: e.Module, Artifact: nodebuildgo.DetectedStepsByModuleArtifactKey(e.Module, name), Fingerprint: e.Fp,
|
||||||
Fetch: &nodebuildgo.Fetch{Repository: e.Repository, Commit: e.Commit, Packages: maps.Clone(e.Packages)}}
|
Fetch: &nodebuildgo.Fetch{Repository: e.Repository, Commit: e.Commit, Packages: PinsOf(e.Packages)}}
|
||||||
// The module's directory and its named paths go together, only when the entry names its paths (ADR 0499 clause
|
// The module's directory and its named paths go together, only when the entry names its paths (ADR 0499 clause
|
||||||
// 4); a request without them builds from the module's directory (sdk/buildstep FetchRequest).
|
// 4); a request without them builds from the module's directory (sdk/buildstep FetchRequest).
|
||||||
if paths := namedPaths(e, name); len(paths) > 0 {
|
if paths := namedPaths(e, name); len(paths) > 0 {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) {
|
|||||||
fp := "src2:" + strings.Repeat("a", 64)
|
fp := "src2:" + strings.Repeat("a", 64)
|
||||||
entries := map[string]meshcatalog.CatalogEntry{"avahi": {Module: "avahi", Repository: "novox/r", Commit: "c1", Path: "mods/avahi", Fp: fp, Manifest: map[string]any{},
|
entries := map[string]meshcatalog.CatalogEntry{"avahi": {Module: "avahi", Repository: "novox/r", Commit: "c1", Path: "mods/avahi", Fp: fp, Manifest: map[string]any{},
|
||||||
Artifacts: []meshcatalog.Artifact{{Ref: "avahi:program", Language: "go"}, {Ref: "avahi:image", Language: "go", Kind: "image"}},
|
Artifacts: []meshcatalog.Artifact{{Ref: "avahi:program", Language: "go"}, {Ref: "avahi:image", Language: "go", Kind: "image"}},
|
||||||
Packages: map[string]string{"git.novox.be/novox/mesh-sdk": "c9"},
|
Packages: map[string]string{"git.novox.be/novox/mesh-sdk": "v0.1.9", "git.novox.be/novox/mesh-contracts/go": ""}, // the second none released (H-A-161)
|
||||||
Inputs: &meshcatalog.EntryInputs{Paths: map[string][]string{"program": {"cmd"}}}}}
|
Inputs: &meshcatalog.EntryInputs{Paths: map[string][]string{"program": {"cmd"}}}}}
|
||||||
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 3, Kind: "trunk"}, entries)
|
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 3, Kind: "trunk"}, entries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -71,9 +71,12 @@ func TestTheSeedAsksStepsOfTheBuildSeatsOfTheTrunkEntries(t *testing.T) {
|
|||||||
t.Errorf("the image artifact is %+v", a)
|
t.Errorf("the image artifact is %+v", a)
|
||||||
}
|
}
|
||||||
in := got[0]
|
in := got[0]
|
||||||
if in.Module != "avahi" || in.Artifact != "avahi.program" || in.Fingerprint != fp || in.Fetch == nil || in.Fetch.Repository != "novox/r" || in.Fetch.Commit != "c1" || in.Fetch.Dir != "mods/avahi" || len(in.Fetch.Paths) != 1 || in.Fetch.Packages["git.novox.be/novox/mesh-sdk"] != "c9" {
|
if in.Module != "avahi" || in.Artifact != "avahi.program" || in.Fingerprint != fp || in.Fetch == nil || in.Fetch.Repository != "novox/r" || in.Fetch.Commit != "c1" || in.Fetch.Dir != "mods/avahi" || len(in.Fetch.Paths) != 1 || in.Fetch.Packages["git.novox.be/novox/mesh-sdk"] != "v0.1.9" {
|
||||||
t.Errorf("the steps input is %+v", in)
|
t.Errorf("the steps input is %+v", in)
|
||||||
}
|
}
|
||||||
|
if _, pinned := in.Fetch.Packages["git.novox.be/novox/mesh-contracts/go"]; pinned {
|
||||||
|
t.Errorf("a package kept with no version is pinned in the fetch: %v", in.Fetch.Packages)
|
||||||
|
}
|
||||||
if len(w.Held()) != 0 {
|
if len(w.Held()) != 0 {
|
||||||
t.Fatal("a call unanswered for no time wrote its finding")
|
t.Fatal("a call unanswered for no time wrote its finding")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type RepoRead struct {
|
|||||||
Trees map[string]string
|
Trees map[string]string
|
||||||
Manifests map[string]string
|
Manifests map[string]string
|
||||||
Locks map[string]map[string]string
|
Locks map[string]map[string]string
|
||||||
// Packages are the mesh packages each directory's go.sum names (fingerprint.MeshPackagesOf, novox/hq ADR 0573 §2).
|
// Packages are the mesh packages each directory's go.mod requires (fingerprint.MeshRequiresOf, design 47 H-A-157).
|
||||||
Packages map[string][]string
|
Packages map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
||||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||||
|
|
||||||
|
"mesh-delivery-indexer/internal/fingerprint"
|
||||||
"mesh-delivery-indexer/judge"
|
"mesh-delivery-indexer/judge"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -152,11 +153,13 @@ func (ix *Indexer) recomputeModules(ctx context.Context, overlay map[string]mesh
|
|||||||
}
|
}
|
||||||
ix.recompute.Lock()
|
ix.recompute.Lock()
|
||||||
defer ix.recompute.Unlock()
|
defer ix.recompute.Unlock()
|
||||||
return ix.recomputeLocked(ctx, overlay, w, repository)
|
return ix.recomputeLocked(ctx, overlay, w, repository, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// recomputeLocked is recomputeModules with ix.recompute held by the caller (a hold that moves, holds.go).
|
// recomputeLocked is recomputeModules with ix.recompute held by the caller (a hold that moves, holds.go).
|
||||||
func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshcatalog.ModulesByModuleValue, w *mergeWrite, repository string) error {
|
//
|
||||||
|
// only, when not nil, names the modules the pass moves (a re-pin, H-A-165): every other stands as held.
|
||||||
|
func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshcatalog.ModulesByModuleValue, w *mergeWrite, repository string, only map[string]bool) error {
|
||||||
if ix.Manifests == nil {
|
if ix.Manifests == nil {
|
||||||
return ix.writeOverlay(ctx, overlay, nil, w)
|
return ix.writeOverlay(ctx, overlay, nil, w)
|
||||||
}
|
}
|
||||||
@@ -215,7 +218,8 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
|||||||
ix.logf("no fingerprint is written by this pass: %v", err)
|
ix.logf("no fingerprint is written by this pass: %v", err)
|
||||||
return fmt.Errorf("no fingerprint is written: %w", err)
|
return fmt.Errorf("no fingerprint is written: %w", err)
|
||||||
}
|
}
|
||||||
series := ix.SeriesAll(ctx) // each package's series, the newest a user accepting it takes (DLV-I6)
|
series := ix.SeriesAll(ctx) // each package's series, the newest a user accepting it takes (DLV-I6)
|
||||||
|
released := ix.releasedOf(ctx) // each module's newest released version, what a package is pinned to (H-A-161)
|
||||||
type result struct {
|
type result struct {
|
||||||
fp, none string
|
fp, none string
|
||||||
tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint
|
tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint
|
||||||
@@ -287,18 +291,20 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
|||||||
r.none = strings.Join(missing, "; ")
|
r.none = strings.Join(missing, "; ")
|
||||||
case noToolchain != "":
|
case noToolchain != "":
|
||||||
r.none = noToolchain
|
r.none = noToolchain
|
||||||
if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads()); ok {
|
if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads(), released); ok {
|
||||||
r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs}
|
r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.sourceHeads(), ix.logf)
|
f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.sourceHeads(), ix.logf)
|
||||||
r.fp, r.none = f.fp, f.none
|
r.fp, r.none = f.fp, f.none
|
||||||
if r.fp != "" {
|
if r.fp != "" {
|
||||||
r.tcs, r.pkgs = toolchainsUsed(toolchains), f.versions
|
// a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167)
|
||||||
|
r.fp, r.pkgs = pinnedOf(f, held, released)
|
||||||
|
r.tcs = toolchainsUsed(toolchains)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, merged := overlay[module]; !merged && repository != "" && !trunk.SameRepository(k.cur.Repository, repository) &&
|
if _, merged := overlay[module]; !merged && (repository != "" && !trunk.SameRepository(k.cur.Repository, repository) &&
|
||||||
maps.Equal(k.held.Packages, map[string]string(r.pkgs)) {
|
!importsOf(r.pkgs, repository) || only != nil && !only[module]) {
|
||||||
// A module registered for another repository is moved by this repository's commit only when it imports a package the
|
// A module registered for another repository is moved by this repository's commit only when it imports a package the
|
||||||
// commit moved (A-476a, ADR 0593 §3); any other stands as held (A-476 c), and so it is for a base of this repository's.
|
// commit moved (A-476a, ADR 0593 §3); any other stands as held (A-476 c), and so it is for a base of this repository's.
|
||||||
r = result{fp: k.held.Fp2, none: k.held.None2, tcs: k.held.Toolchains, pkgs: sdkstep.PackageVersions(k.held.Packages)}
|
r = result{fp: k.held.Fp2, none: k.held.None2, tcs: k.held.Toolchains, pkgs: sdkstep.PackageVersions(k.held.Packages)}
|
||||||
@@ -492,7 +498,7 @@ func hasContext(m catalogue.Manifest) bool {
|
|||||||
// with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any
|
// with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any
|
||||||
// other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the
|
// other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the
|
||||||
// module has none until they agree.
|
// module has none until they agree.
|
||||||
func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) (string, sdkstep.PackageVersions, bool) {
|
func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, released map[string]string) (string, sdkstep.PackageVersions, bool) {
|
||||||
if k.held.Fp2 == "" {
|
if k.held.Fp2 == "" {
|
||||||
return "", nil, false
|
return "", nil, false
|
||||||
}
|
}
|
||||||
@@ -509,7 +515,11 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2,
|
|||||||
toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe}
|
toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe}
|
||||||
}
|
}
|
||||||
f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, heads, nil)
|
f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, heads, nil)
|
||||||
return f.fp, f.versions, f.none == "" && f.fp == k.held.Fp2
|
if f.none != "" || f.fp == "" {
|
||||||
|
return "", nil, false
|
||||||
|
}
|
||||||
|
fp, pkgs := pinnedOf(f, held, released)
|
||||||
|
return fp, pkgs, fp == k.held.Fp2
|
||||||
}
|
}
|
||||||
|
|
||||||
// toolchainsUsed are the toolchains a fingerprint was computed with, by language (an artifact's toolchain is its language's).
|
// toolchainsUsed are the toolchains a fingerprint was computed with, by language (an artifact's toolchain is its language's).
|
||||||
@@ -577,3 +587,41 @@ func (ix *Indexer) fillPaths(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// importsOf says whether pkgs name a package of repository: a pin is a released version (H-A-161), so a commit of
|
||||||
|
// repository moves a module of another only through a package of it the module imports (A-476a).
|
||||||
|
func importsOf(pkgs sdkstep.PackageVersions, repository string) bool {
|
||||||
|
for p := range pkgs {
|
||||||
|
if repo, _, ok := trunk.PackageRepository(p); ok && trunk.SameRepository(repo, repository) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repin moves the pins of every module whose packages hold a package of module (a held module's directory holds it) to
|
||||||
|
// module's newest released version, the pass of H-A-161 for those modules alone: a version-released of module starts it
|
||||||
|
// (design 47 H-A-165), so pins move on the event and never wait for a merge or a hand act. It answers how many it named.
|
||||||
|
func (ix *Indexer) Repin(ctx context.Context, module string) (int, error) {
|
||||||
|
if ix.Modules == nil || ix.Manifests == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
held, err := ix.heldModules(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
only := map[string]bool{}
|
||||||
|
for key, m := range held {
|
||||||
|
for p := range m.Packages {
|
||||||
|
if moduleOfKey(fingerprint.HolderOf(p, held)) == module {
|
||||||
|
only[key] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(only) == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
ix.recompute.Lock()
|
||||||
|
defer ix.recompute.Unlock()
|
||||||
|
return len(only), ix.recomputeLocked(ctx, nil, nil, "", only)
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||||
@@ -757,7 +758,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
|||||||
t.Errorf("no published mesh-sdk: fp2 %q none2 %q", u.Fp2, u.None2)
|
t.Errorf("no published mesh-sdk: fp2 %q none2 %q", u.Fp2, u.None2)
|
||||||
}
|
}
|
||||||
tools, _ := moduleOf(t, mods, "mesh-tools")
|
tools, _ := moduleOf(t, mods, "mesh-tools")
|
||||||
sdkMerge := func(commit, tree string) meshcatalog.ModulesByModuleValue {
|
sdkMerge := func(commit, tree, pin string) meshcatalog.ModulesByModuleValue {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
f := whole{Repository: "novox/mesh-sdk", Branch: "feat/x", Head: h1,
|
f := whole{Repository: "novox/mesh-sdk", Branch: "feat/x", Head: h1,
|
||||||
Merge: commit, Root: tree, Trees: map[string]string{"": tree}, Manifests: map[string]string{"": `{"module":"mesh-sdk","version":"1.0"}`}}
|
Merge: commit, Root: tree, Trees: map[string]string{"": tree}, Manifests: map[string]string{"": `{"module":"mesh-sdk","version":"1.0"}`}}
|
||||||
@@ -765,9 +766,10 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// A-476a: a commit of mesh-sdk moves avahi, of another repository, which imports its package, and leaves mesh-tools,
|
// A-476a: a commit of mesh-sdk moves avahi, of another repository, which imports its package, and leaves mesh-tools,
|
||||||
// which imports nothing it moved.
|
// which imports nothing it moved. Its pin is mesh-sdk's newest released version, never the commit; with none
|
||||||
|
// released it has no pin, the package kept for its kind-1 edge (H-A-161).
|
||||||
a, _ := moduleOf(t, mods, "avahi")
|
a, _ := moduleOf(t, mods, "avahi")
|
||||||
if a.Fp2 == "" || !reflect.DeepEqual(a.Packages, map[string]string{sdk: commit}) {
|
if a.Fp2 == "" || !reflect.DeepEqual(a.Packages, map[string]string{sdk: pin}) {
|
||||||
t.Fatalf("after mesh-sdk's merge %.8s: fp2 %q none2 %q packages %v", commit, a.Fp2, a.None2, a.Packages)
|
t.Fatalf("after mesh-sdk's merge %.8s: fp2 %q none2 %q packages %v", commit, a.Fp2, a.None2, a.Packages)
|
||||||
}
|
}
|
||||||
if o, _ := moduleOf(t, mods, "mesh-tools"); o.Fp2 != tools.Fp2 || o.Packages != nil {
|
if o, _ := moduleOf(t, mods, "mesh-tools"); o.Fp2 != tools.Fp2 || o.Packages != nil {
|
||||||
@@ -781,8 +783,39 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
|||||||
stale.Fp2 = "src2:" + strings.Repeat("5", 64)
|
stale.Fp2 = "src2:" + strings.Repeat("5", 64)
|
||||||
mods.put("mesh-tools", mustEncode(t, stale))
|
mods.put("mesh-tools", mustEncode(t, stale))
|
||||||
tools = stale
|
tools = stale
|
||||||
first := sdkMerge(strings.Repeat("1", 40), "tree-sdk-1")
|
first := sdkMerge(strings.Repeat("1", 40), "tree-sdk-1", "")
|
||||||
second := sdkMerge(strings.Repeat("2", 40), "tree-sdk-2")
|
// mesh-sdk releases 0.1.20 (0.1.9 before it): the release re-pins avahi with no merge, its fingerprint moving with the
|
||||||
|
// pin so it is built again against the release, and leaves mesh-tools, which holds none of it (H-A-165, H-A-167). A
|
||||||
|
// re-pin that fails is no release acknowledged: the package-published delivered again re-pins.
|
||||||
|
ix.Versions, ix.Heard = newMem(), newMem()
|
||||||
|
ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.9"), []byte(`{}`))
|
||||||
|
revisions := ix.Revisions
|
||||||
|
ix.Revisions = newMemObjects(1 << 20)
|
||||||
|
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 3, Kind: "trunk"}, map[string]meshcatalog.CatalogEntry{
|
||||||
|
"mesh-sdk": {Module: "mesh-sdk", Manifest: map[string]any{}, Artifacts: []meshcatalog.Artifact{{Ref: "mesh-sdk:go"}}}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := KeepRevision(context.Background(), ix.Revisions, rev, objects); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
release := meshbuilds.PackagePublished{Module: "mesh-sdk", Artifact: "mesh-sdk:go", Digest: "sha256:g", Version: "0.1.20", Source: 7, Branch: "main"}
|
||||||
|
mods.keysErr = errors.New("the bus did not answer")
|
||||||
|
if err := ix.HearPackagePublished(context.Background(), release); err == nil {
|
||||||
|
t.Fatal("a release whose re-pin failed was acknowledged")
|
||||||
|
}
|
||||||
|
mods.keysErr = nil
|
||||||
|
if err := ix.HearPackagePublished(context.Background(), release); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ix.Revisions = revisions
|
||||||
|
if a, _ := moduleOf(t, mods, "avahi"); a.Fp2 == first.Fp2 || a.Fp2 == "" || !reflect.DeepEqual(a.Packages, map[string]string{sdk: "v0.1.20"}) {
|
||||||
|
t.Fatalf("after mesh-sdk's release: fp2 %q (was %q) packages %v, want a new fingerprint pinned to v0.1.20", a.Fp2, first.Fp2, a.Packages)
|
||||||
|
}
|
||||||
|
if o, _ := moduleOf(t, mods, "mesh-tools"); o.Fp2 != tools.Fp2 {
|
||||||
|
t.Errorf("a re-pin moved mesh-tools, which holds no package of mesh-sdk: %q (was %q)", o.Fp2, tools.Fp2)
|
||||||
|
}
|
||||||
|
second := sdkMerge(strings.Repeat("2", 40), "tree-sdk-2", "v0.1.20")
|
||||||
if second.Fp2 == first.Fp2 {
|
if second.Fp2 == first.Fp2 {
|
||||||
t.Errorf("a mesh-sdk trunk merge kept avahi's fingerprint %q", first.Fp2)
|
t.Errorf("a mesh-sdk trunk merge kept avahi's fingerprint %q", first.Fp2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,19 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||||
|
|
||||||
|
"mesh-delivery-indexer/internal/fingerprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The catalog's released versions (design 47 G §349, §372, §374): the indexer keeps, for the seat mesh-catalog, each module's
|
// The catalog's released versions (design 47 G §349, §372, §374): the indexer keeps, for the seat mesh-catalog, each module's
|
||||||
@@ -123,8 +128,9 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag
|
|||||||
if raw, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil {
|
if raw, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if found && !isFloor(raw) {
|
} else if found && !isFloor(raw) {
|
||||||
ix.logf("versions: %s %s is released already, so the package-published of %s is heard again and changes nothing", p.Module, p.Version, p.Artifact)
|
// A package-published delivered again after a re-pin failed (H-A-167): the re-pin is made again, nothing else.
|
||||||
return nil
|
ix.logf("versions: %s %s is released already, so the package-published of %s is heard again and only re-pins", p.Module, p.Version, p.Artifact)
|
||||||
|
return ix.repin(ctx, p.Module, p.Version)
|
||||||
}
|
}
|
||||||
entry, err := ix.entryOf(ctx, p.Module)
|
entry, err := ix.entryOf(ctx, p.Module)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -234,6 +240,13 @@ func (ix *Indexer) releaseVersion(ctx context.Context, p meshbuilds.PackagePubli
|
|||||||
}
|
}
|
||||||
ix.logf("versions: %s %s is released and version-released is said (%d artifacts, source %d)", p.Module, p.Version, len(v.Artifacts), v.Source)
|
ix.logf("versions: %s %s is released and version-released is said (%d artifacts, source %d)", p.Module, p.Version, len(v.Artifacts), v.Source)
|
||||||
}
|
}
|
||||||
|
if !late {
|
||||||
|
// The release re-pins every module whose packages hold one of it (design 47 H-A-165); one that fails is not
|
||||||
|
// acknowledged, so the package-published is delivered again (H-A-167).
|
||||||
|
if err := ix.repin(ctx, p.Module, p.Version); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if err := ix.trimVersions(ctx, p.Module); err != nil {
|
if err := ix.trimVersions(ctx, p.Module); err != nil {
|
||||||
ix.logf("versions: %s's oldest versions are not deleted: %v", p.Module, err)
|
ix.logf("versions: %s's oldest versions are not deleted: %v", p.Module, err)
|
||||||
}
|
}
|
||||||
@@ -352,3 +365,107 @@ func isFloor(raw []byte) bool {
|
|||||||
var v meshcatalog.VersionEntry
|
var v meshcatalog.VersionEntry
|
||||||
return json.Unmarshal(raw, &v) == nil && len(v.Artifacts) == 0
|
return json.Unmarshal(raw, &v) == nil && len(v.Artifacts) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// releasedOf is the newest released version of each module the state versions keeps (§349; design 47 H-A-161), by module;
|
||||||
|
// nil when the indexer keeps no such state or it cannot be listed, said.
|
||||||
|
func (ix *Indexer) releasedOf(ctx context.Context) map[string]string {
|
||||||
|
if ix.Versions == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
all, err := ix.Versions.Keys(ctx)
|
||||||
|
if err != nil {
|
||||||
|
ix.logf("versions: the state cannot be listed, so no package is pinned by this pass: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := map[string]string{}
|
||||||
|
for _, k := range all {
|
||||||
|
m, v, ok := meshcatalog.ParseVersionsByModuleVersionKey(k)
|
||||||
|
if _, parts := versionParts(v); !ok || !parts {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if cur, has := out[m]; !has || compareVersions(v, cur) > 0 {
|
||||||
|
out[m] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// releasedPins are a module's pins (its catalog entry's packages, which the builder builds it against) from the versions its
|
||||||
|
// fingerprint was computed with (design 47 H-A-161, G §370): a package the held module holding it has released is pinned
|
||||||
|
// to that module's newest released version, as Go names it (v<version>); a version already in that form (an accepted
|
||||||
|
// series' newest, DLV-I6) stands; any other, a commit, is no pin: its package is kept with no version, so its kind-1 edge
|
||||||
|
// stands (H §746) and no build is made against a commit. nil for none.
|
||||||
|
func releasedPins(versions sdkstep.PackageVersions, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) sdkstep.PackageVersions {
|
||||||
|
if len(versions) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := sdkstep.PackageVersions{}
|
||||||
|
for p, v := range versions {
|
||||||
|
rel := released[moduleOfKey(fingerprint.HolderOf(p, held))]
|
||||||
|
series := sdkstep.PackageSemver.MatchString(v)
|
||||||
|
_, plain := versionParts(strings.TrimPrefix(v, "v"))
|
||||||
|
switch {
|
||||||
|
case rel != "" && (!series || !plain || compareVersions(rel, strings.TrimPrefix(v, "v")) > 0):
|
||||||
|
out[p] = "v" + rel // never an older series' version over a newer release (H-A-167)
|
||||||
|
case series:
|
||||||
|
out[p] = v
|
||||||
|
default:
|
||||||
|
out[p] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// pinnedOf is a form's fingerprint and its pins (releasedPins): the pins are part of what a build is made of, so every
|
||||||
|
// form's fingerprint takes them (design 47 H-A-167, H-A-172; ADR 0573 §4) and a re-pin moves it, the module a mover
|
||||||
|
// built again against the release; a fingerprint with no pin is the form's as it is. The held fingerprint of a build that
|
||||||
|
// stands is kept while its pins are the ones it was built with, else its import form takes the new pins.
|
||||||
|
func pinnedOf(f form, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) (string, sdkstep.PackageVersions) {
|
||||||
|
pins := releasedPins(f.versions, held, released)
|
||||||
|
if f.stands {
|
||||||
|
if maps.Equal(f.built, map[string]string(pins)) {
|
||||||
|
return f.fp, pins
|
||||||
|
}
|
||||||
|
return fingerprint.WithPins(f.raw, pins), pins
|
||||||
|
}
|
||||||
|
return fingerprint.WithPins(f.fp, pins), pins
|
||||||
|
}
|
||||||
|
|
||||||
|
// moduleOfKey is the module a modules key names; "" for none.
|
||||||
|
func moduleOfKey(key string) string {
|
||||||
|
if key == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if m, err := meshcatalogclient.ParseModulesKey(key); err == nil {
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
|
// PinsOf are the pins a build is asked with from a catalog entry's packages: each package with a version; one kept with
|
||||||
|
// none (no released version, H-A-161) is no pin. nil for none.
|
||||||
|
func PinsOf(packages map[string]string) sdkstep.PackageVersions {
|
||||||
|
var out sdkstep.PackageVersions
|
||||||
|
for p, v := range packages {
|
||||||
|
if v == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if out == nil {
|
||||||
|
out = sdkstep.PackageVersions{}
|
||||||
|
}
|
||||||
|
out[p] = v
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// repin is Repin of a release of module at version, said in the journal; its failure is the caller's error.
|
||||||
|
func (ix *Indexer) repin(ctx context.Context, module, version string) error {
|
||||||
|
n, err := ix.Repin(ctx, module)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("the modules pinned to %s are not re-pinned to %s: %w", module, version, err)
|
||||||
|
}
|
||||||
|
if n > 0 {
|
||||||
|
ix.logf("versions: %d modules re-pinned to %s %s", n, module, version)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func TestTools(t *testing.T) {
|
|||||||
for _, tl := range UnloggedTools(stdio.State("pipelines"), stdio.Log("step-log"), nil, nil) {
|
for _, tl := range UnloggedTools(stdio.State("pipelines"), stdio.Log("step-log"), nil, nil) {
|
||||||
names = append(names, tl.Name)
|
names = append(names, tl.Name)
|
||||||
}
|
}
|
||||||
want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_cancel runner_rerun runner_start runner_run runner_accept runner_place runner_ask_again runner_health runner_waiting runner_unlogged runner_unlogged_append"
|
want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_cancel runner_rerun runner_start runner_run runner_accept runner_place runner_end_again runner_ask_again runner_health runner_waiting runner_unlogged runner_unlogged_append"
|
||||||
if got := strings.Join(names, " "); got != want {
|
if got := strings.Join(names, " "); got != want {
|
||||||
t.Errorf("tools %q, want %q", got, want)
|
t.Errorf("tools %q, want %q", got, want)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ func VerbTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.
|
|||||||
}
|
}
|
||||||
return whyOf(in.Why)
|
return whyOf(in.Why)
|
||||||
}),
|
}),
|
||||||
|
verbTool[seat.EndAgainInput](ask, "end_again", seat.VerbEndAgain,
|
||||||
|
"Judge a running pipeline's end once more by the seat verb end-again (design 47 H H-A-163, H-A-164): it ends as at a step's end, failed as soon as it can no longer pass (a mover with no registration named), and says pipeline-ended; one that still cannot end is answered running. The pipeline's key and why; written in the hand-act log. A pipeline not running is refused by the verb.",
|
||||||
|
obj([]string{"pipeline", "why"}, map[string]any{"pipeline": str, "why": str}),
|
||||||
|
func(in seat.EndAgainInput) string {
|
||||||
|
if in.Pipeline == "" {
|
||||||
|
return "end-again names the pipeline"
|
||||||
|
}
|
||||||
|
return whyOf(in.Why)
|
||||||
|
}),
|
||||||
verbTool[seat.AskAgainInput](ask, "ask_again", seat.VerbAskAgain,
|
verbTool[seat.AskAgainInput](ask, "ask_again", seat.VerbAskAgain,
|
||||||
"Ask a declined approval step of a pipeline once more by the seat verb ask-again: the pipeline's key, the mover's module (needed when the pipeline moves several) and why.",
|
"Ask a declined approval step of a pipeline once more by the seat verb ask-again: the pipeline's key, the mover's module (needed when the pipeline moves several) and why.",
|
||||||
obj([]string{"pipeline", "why"}, map[string]any{"pipeline": str, "module": str, "why": str}),
|
obj([]string{"pipeline", "why"}, map[string]any{"pipeline": str, "module": str, "why": str}),
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ func TestVerbTools(t *testing.T) {
|
|||||||
{"place", "runner_place", "seat:mesh-pipeline-runner.place", "", map[string]any{"pipeline": "main.6", "why": "urgent"},
|
{"place", "runner_place", "seat:mesh-pipeline-runner.place", "", map[string]any{"pipeline": "main.6", "why": "urgent"},
|
||||||
seat.PlaceInput{Pipeline: "main.6", Why: "urgent"}},
|
seat.PlaceInput{Pipeline: "main.6", Why: "urgent"}},
|
||||||
{"place no why", "runner_place", "", "names why", map[string]any{"pipeline": "main.6"}, nil},
|
{"place no why", "runner_place", "", "names why", map[string]any{"pipeline": "main.6"}, nil},
|
||||||
|
// H-A-164: runner_end_again asks the verb end-again with the pipeline and why.
|
||||||
|
{"end-again", "runner_end_again", "seat:mesh-pipeline-runner.end-again", "", map[string]any{"pipeline": "main.20", "why": "left running"},
|
||||||
|
seat.EndAgainInput{Pipeline: "main.20", Why: "left running"}},
|
||||||
|
{"end-again no why", "runner_end_again", "", "names why", map[string]any{"pipeline": "main.20"}, nil},
|
||||||
{"ask-again no why", "runner_ask_again", "", "names why", map[string]any{"pipeline": "p"}, nil},
|
{"ask-again no why", "runner_ask_again", "", "names why", map[string]any{"pipeline": "p"}, nil},
|
||||||
} {
|
} {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
Kept: keptReader(ctx, kept), Toolchain: toolchainReader(ctx, toolchains),
|
Kept: keptReader(ctx, kept), Toolchain: toolchainReader(ctx, toolchains),
|
||||||
Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders, Ended: hearer.EndedAtPlacing}
|
Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders, Ended: hearer.EndedAtPlacing}
|
||||||
hearer.AskSteps = starter.AskSteps
|
hearer.AskSteps = starter.AskSteps
|
||||||
|
hearer.Unplaced = func(p seat.Pipeline, module string) string { return starter.Unplaced(p, module, rv.Catalog.View) }
|
||||||
hearer.Release = func(key string) {
|
hearer.Release = func(key string) {
|
||||||
if _, err := starter.Release(hearer.Store, key, rv.Catalog.View); err != nil {
|
if _, err := starter.Release(hearer.Store, key, rv.Catalog.View); err != nil {
|
||||||
logger.Printf("the movers of %s waiting for a build are not placed: %v", key, err)
|
logger.Printf("the movers of %s waiting for a build are not placed: %v", key, err)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func answerVerbs(conn *process.Conn, seats *seatlist.Part, v pipeline.Verbs) (fu
|
|||||||
return conn.AnswerSeat(seat.Seat, seatlist.Definition(seats.Reader, seat.Seat), writeHandlers(v))
|
return conn.AnswerSeat(seat.Seat, seatlist.Definition(seats.Reader, seat.Seat), writeHandlers(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, and ask-again; and
|
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, end-again, start, and ask-again; and
|
||||||
// the test runs' verbs test-runs and test-runs-drop (A-469g, A-470i).
|
// the test runs' verbs test-runs and test-runs-drop (A-469g, A-470i).
|
||||||
func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
||||||
return map[string]process.SeatHandler{
|
return map[string]process.SeatHandler{
|
||||||
@@ -47,6 +47,7 @@ func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
|||||||
seat.VerbRerun: verbOf(func(c string, in seat.RerunInput) (any, error) { return v.Rerun(c, in) }),
|
seat.VerbRerun: verbOf(func(c string, in seat.RerunInput) (any, error) { return v.Rerun(c, in) }),
|
||||||
seat.VerbAccept: verbOf(func(c string, in seat.AcceptInput) (any, error) { return v.Accept(c, in) }),
|
seat.VerbAccept: verbOf(func(c string, in seat.AcceptInput) (any, error) { return v.Accept(c, in) }),
|
||||||
seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }),
|
seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }),
|
||||||
|
seat.VerbEndAgain: verbOf(func(c string, in seat.EndAgainInput) (any, error) { return v.EndAgain(c, in) }),
|
||||||
seat.VerbPlace: verbOf(func(c string, in seat.PlaceInput) (any, error) { return v.Place(c, in) }),
|
seat.VerbPlace: verbOf(func(c string, in seat.PlaceInput) (any, error) { return v.Place(c, in) }),
|
||||||
seat.VerbStart: verbOf(func(c string, in seat.StartInput) (any, error) { return v.Start(c, in) }),
|
seat.VerbStart: verbOf(func(c string, in seat.StartInput) (any, error) { return v.Start(c, in) }),
|
||||||
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
|
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func TestEveryWriteVerbIsServed(t *testing.T) {
|
|||||||
got = append(got, v)
|
got = append(got, v)
|
||||||
}
|
}
|
||||||
slices.Sort(got)
|
slices.Sort(got)
|
||||||
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbPlace, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRuns, seat.VerbTestRunsDrop}
|
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbEndAgain, seat.VerbPlace, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRuns, seat.VerbTestRunsDrop}
|
||||||
slices.Sort(want)
|
slices.Sort(want)
|
||||||
if !slices.Equal(got, want) {
|
if !slices.Equal(got, want) {
|
||||||
t.Errorf("the process answers %v, want %v", got, want)
|
t.Errorf("the process answers %v, want %v", got, want)
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ func (h *Hearer) endReader(reader RunReader, run string, r Run) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ended := endPipeline(&p, now)
|
ended := endPipeline(&p, now, h.Unplaced)
|
||||||
if _, err := h.Store.Update(reader.Pipeline, p, rev); errors.Is(err, ErrChanged) {
|
if _, err := h.Store.Update(reader.Pipeline, p, rev); errors.Is(err, ErrChanged) {
|
||||||
continue
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|||||||
@@ -541,6 +541,28 @@ func (s *Starter) Resume(store Updater, branch string, half Half) (int, error) {
|
|||||||
return asked, first
|
return asked, first
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unplaced says why mover module of p has no step placed (H-A-171): "<module> has no registration" when the registrations
|
||||||
|
// do not name it (A-327), else "<module> waits on the publish of <package>, …", the packages it awaits not yet published
|
||||||
|
// as the catalog half of p's branch holds its edges (§746).
|
||||||
|
func (s *Starter) Unplaced(p seat.Pipeline, module string, view func(branch string) (Half, bool)) string {
|
||||||
|
if s.Registration == nil {
|
||||||
|
return module + " has no registration"
|
||||||
|
}
|
||||||
|
if _, ok := s.Registration(module); !ok {
|
||||||
|
return module + " has no registration"
|
||||||
|
}
|
||||||
|
var waiting []string
|
||||||
|
if view != nil {
|
||||||
|
if half, ok := view(p.Branch); ok {
|
||||||
|
_, waiting, _ = ready(p, module, half.Entries)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(waiting) == 0 {
|
||||||
|
return module + " waits on the publish of the movers it builds on"
|
||||||
|
}
|
||||||
|
return module + " waits on the publish of " + strings.Join(waiting, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
// Registered places, on a registration-changed of reg's module, the steps of that module's mover in every running pipeline
|
// Registered places, on a registration-changed of reg's module, the steps of that module's mover in every running pipeline
|
||||||
// that moves it with none placed, from the registration (design 47 G §21, §23, A-327): a pipeline started before its module
|
// that moves it with none placed, from the registration (design 47 G §21, §23, A-327): a pipeline started before its module
|
||||||
// had a registration. Each is written by compare-and-set, so it is placed once, its steps asked, and said; a run on request
|
// had a registration. Each is written by compare-and-set, so it is placed once, its steps asked, and said; a run on request
|
||||||
@@ -610,7 +632,12 @@ func (s *Starter) placeWaiting(store Updater, due func(seat.Pipeline) bool, reg
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
before := len(p.Steps)
|
before := len(p.Steps)
|
||||||
asks, _, ended, notAsked := s.placeMovers(&p, reg, half.Entries, now)
|
asks, unregistered, ended, notAsked := s.placeMovers(&p, reg, half.Entries, now)
|
||||||
|
// Until its registration arrives, the pipeline says it waits on it (A-327): a mover with no registration has no step,
|
||||||
|
// and it holds the pipeline's end only while every placed mover's required steps passed (H-A-163, H-A-171).
|
||||||
|
for _, m := range unregistered {
|
||||||
|
s.logf("%s: %s has no registration yet: its steps wait on its registration, which places them (A-327)", key, m)
|
||||||
|
}
|
||||||
if len(p.Steps) == before {
|
if len(p.Steps) == before {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package pipeline
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -280,6 +282,23 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T
|
|||||||
if n != 1 || err != nil || len(p.Steps) == 0 || len(asks.asks) == before {
|
if n != 1 || err != nil || len(p.Steps) == 0 || len(asks.asks) == before {
|
||||||
t.Errorf("the pipeline a runner before this one set aside: placed %d (%v), %d steps, %d asks more, want it started as a newly started one", n, err, len(p.Steps), len(asks.asks)-before)
|
t.Errorf("the pipeline a runner before this one set aside: placed %d (%v), %d steps, %d asks more, want it started as a newly started one", n, err, len(p.Steps), len(asks.asks)-before)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A-327: a mover with no registration, in a pipeline placed from the half held later (the queue's turn, the half held),
|
||||||
|
// is said to wait on its registration, so the pipeline that cannot end before it is placed says why.
|
||||||
|
var logged []string
|
||||||
|
s.Logf = func(f string, a ...any) { logged = append(logged, fmt.Sprintf(f, a...)) }
|
||||||
|
held = false
|
||||||
|
taken = catalog.TakeInTaken{Branch: "next", Source: 8, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c4", Fingerprint: "src2:dd"}, {Module: "contracts", Commit: "c4", Fingerprint: "src2:ee"}}}
|
||||||
|
if n, err := s.TakenIn(taken, late); n != 1 || err != nil {
|
||||||
|
t.Fatalf("the take-in of two movers started %d (%v)", n, err)
|
||||||
|
}
|
||||||
|
held, logged = true, nil
|
||||||
|
if n, err := s.Waiting(store.memStore, "next", late); n != 1 || err != nil {
|
||||||
|
t.Fatalf("the half of next placed %d (%v), want next.8's registered mover", n, err)
|
||||||
|
}
|
||||||
|
if !slices.ContainsFunc(logged, func(l string) bool { return strings.Contains(l, "next.8: contracts has no registration yet") }) {
|
||||||
|
t.Errorf("placing next.8 said %q, want that contracts waits on its registration (A-327)", logged)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// R1/AC1 (design 47 H §747): a start names an event, never a sweep. A take-in starts the pipelines of its own entries
|
// R1/AC1 (design 47 H §747): a start names an event, never a sweep. A take-in starts the pipelines of its own entries
|
||||||
|
|||||||
@@ -158,6 +158,9 @@ type Hearer struct {
|
|||||||
// Turn takes a pipeline's end into the queue, its running key deleted and the next placed (design 47 H §748;
|
// Turn takes a pipeline's end into the queue, its running key deleted and the next placed (design 47 H §748;
|
||||||
// Starter.Turn); nil takes none.
|
// Starter.Turn); nil takes none.
|
||||||
Turn func(key string)
|
Turn func(key string)
|
||||||
|
// Unplaced says why a mover of a pipeline has no step placed, for the why of its end (H-A-171; Starter.Unplaced): it
|
||||||
|
// waits on its registration or on a publish; nil says only that it has no step placed.
|
||||||
|
Unplaced func(p seat.Pipeline, module string) string
|
||||||
// Rejoin keys a pipeline running again once its approval is answered and it still runs (H-A-106 (b); Starter.Rejoin);
|
// Rejoin keys a pipeline running again once its approval is answered and it still runs (H-A-106 (b); Starter.Rejoin);
|
||||||
// nil keys none.
|
// nil keys none.
|
||||||
Rejoin func(key string)
|
Rejoin func(key string)
|
||||||
@@ -568,16 +571,22 @@ 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
|
// 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;
|
// 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) or on the publish of a mover it
|
||||||
// waiting when a required step did not pass is `not asked` (§26). It says whether the pipeline ended now, its end count one
|
// builds on (§746), holds the end only while the pipeline could still pass: once a placed mover's required step did not
|
||||||
// higher.
|
// pass and none is open, it ends failed, the why naming each unplaced mover with the reason unplaced gives (H-A-163,
|
||||||
func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
// H-A-171; nil says only that it has no step placed). 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, unplaced func(seat.Pipeline, string) string) bool {
|
||||||
if p.Outcome != seat.PipelineOutcomeRunning {
|
if p.Outcome != seat.PipelineOutcomeRunning {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// A mover with no step placed waits on its registration or a publish: 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, H-A-171).
|
||||||
|
var waiting []string
|
||||||
for _, m := range p.Movers {
|
for _, m := range p.Movers {
|
||||||
if !placed(*p, m.Module) {
|
if !placed(*p, m.Module) {
|
||||||
return false
|
waiting = append(waiting, m.Module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var held []string
|
var held []string
|
||||||
@@ -598,6 +607,9 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
|||||||
held = append(held, strings.TrimSpace(s.Module+" "+s.Artifact+" "+s.Step)+" "+s.Outcome)
|
held = append(held, strings.TrimSpace(s.Module+" "+s.Artifact+" "+s.Step)+" "+s.Outcome)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(waiting) > 0 && len(held) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if len(notAsked) > 0 {
|
if len(notAsked) > 0 {
|
||||||
if len(held) == 0 {
|
if len(held) == 0 {
|
||||||
return false
|
return false
|
||||||
@@ -611,6 +623,13 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
|||||||
p.Outcome, p.Why = seat.PipelineOutcomePassed, ""
|
p.Outcome, p.Why = seat.PipelineOutcomePassed, ""
|
||||||
if len(held) > 0 {
|
if len(held) > 0 {
|
||||||
p.Outcome, p.Why = seat.PipelineOutcomeFailed, "required steps not passed: "+strings.Join(held, ", ")
|
p.Outcome, p.Why = seat.PipelineOutcomeFailed, "required steps not passed: "+strings.Join(held, ", ")
|
||||||
|
for _, m := range waiting {
|
||||||
|
why := m + " has no step placed"
|
||||||
|
if unplaced != nil {
|
||||||
|
why = unplaced(*p, m)
|
||||||
|
}
|
||||||
|
p.Why += "; " + why
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for i := range p.Movers {
|
for i := range p.Movers {
|
||||||
m := &p.Movers[i]
|
m := &p.Movers[i]
|
||||||
@@ -622,7 +641,7 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
|
|||||||
|
|
||||||
// endPipeline is endPipeline with each mover's widens computed into its value at the end (§71, A-207; H-A-51).
|
// endPipeline is endPipeline with each mover's widens computed into its value at the end (§71, A-207; H-A-51).
|
||||||
func (h *Hearer) endPipeline(p *seat.Pipeline, now time.Time) bool {
|
func (h *Hearer) endPipeline(p *seat.Pipeline, now time.Time) bool {
|
||||||
if !endPipeline(p, now) {
|
if !endPipeline(p, now, h.Unplaced) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if h.Widens != nil {
|
if h.Widens != nil {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
"git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||||
|
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||||
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
||||||
@@ -291,23 +292,57 @@ 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
|
// 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) or on the publish of a mover it
|
||||||
|
// builds on (§746), 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 each with its own reason (H-A-163, H-A-171).
|
||||||
func TestAnOptionalStepStillWaitingHoldsNoEnd(t *testing.T) {
|
func TestAnOptionalStepStillWaitingHoldsNoEnd(t *testing.T) {
|
||||||
now := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)
|
now := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)
|
||||||
|
// lib is registered and awaits core's package, which core's passed build has not published yet; contracts has no
|
||||||
|
// registration.
|
||||||
|
starter := &Starter{Registration: func(m string) (catalog.Registration, bool) { return catalog.Registration{Module: m}, m != "contracts" }}
|
||||||
|
view := func(string) (Half, bool) {
|
||||||
|
return Half{Entries: map[string]catalog.CatalogEntry{"lib": {Edges: []catalog.Edge{{From: "core:go", To: "lib:program", Kind: 1}}}}}, true
|
||||||
|
}
|
||||||
|
unplaced := func(p seat.Pipeline, m string) string { return starter.Unplaced(p, m, view) }
|
||||||
for name, c := range map[string]struct {
|
for name, c := range map[string]struct {
|
||||||
review string
|
review, build, unit string
|
||||||
ends bool
|
waiting []string
|
||||||
}{"optional review waiting": {seat.StepResultStatusOptional, true}, "required review waiting": {seat.StepResultStatusRequired, false}} {
|
ends bool
|
||||||
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Steps: []seat.StepResult{
|
outcome string
|
||||||
{Step: seat.StepResultStepBuild, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
why []string
|
||||||
{Step: seat.StepResultStepReview, Status: c.review, Outcome: seat.StepResultOutcomeWaiting},
|
}{
|
||||||
{Step: seat.StepResultStepApproval, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
"optional review waiting": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, nil, true, seat.PipelineOutcomePassed, nil},
|
||||||
|
"required review waiting": {seat.StepResultStatusRequired, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, nil, false, "", nil},
|
||||||
|
"unregistered mover, the placed one passed": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, []string{"contracts"}, false, "", nil},
|
||||||
|
"unregistered mover, the placed one failed": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomePassed, []string{"contracts"}, true, seat.PipelineOutcomeFailed, []string{"contracts has no registration"}},
|
||||||
|
"unregistered mover, failed and a step open": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomeRunning, []string{"contracts"}, false, "", nil},
|
||||||
|
"unregistered mover, the placed one could not run": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomeCouldNotRun, []string{"contracts"}, true, seat.PipelineOutcomeFailed, []string{"contracts has no registration"}},
|
||||||
|
"a mover waiting on a publish, the placed one failed": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomePassed, []string{"contracts", "lib"}, true, seat.PipelineOutcomeFailed,
|
||||||
|
[]string{"contracts has no registration", "lib waits on the publish of core:go"}},
|
||||||
|
} {
|
||||||
|
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app"}, {Module: "core"}}, 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},
|
||||||
|
{Step: seat.StepResultStepBuild, Module: "core", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
|
||||||
}}
|
}}
|
||||||
if got := endPipeline(&p, now); got != c.ends {
|
for _, m := range c.waiting {
|
||||||
|
p.Movers = append(p.Movers, seat.Mover{Module: m})
|
||||||
|
}
|
||||||
|
if got := endPipeline(&p, now, unplaced); got != c.ends {
|
||||||
t.Errorf("%s: ended = %v, want %v", name, got, c.ends)
|
t.Errorf("%s: ended = %v, want %v", name, got, c.ends)
|
||||||
}
|
}
|
||||||
if c.ends && p.Outcome != seat.PipelineOutcomePassed {
|
if c.ends && p.Outcome != c.outcome {
|
||||||
t.Errorf("%s: outcome %s", name, p.Outcome)
|
t.Errorf("%s: outcome %s, want %s", name, p.Outcome, c.outcome)
|
||||||
|
}
|
||||||
|
for _, w := range c.why {
|
||||||
|
if !strings.Contains(p.Why, w) {
|
||||||
|
t.Errorf("%s: why %q, want it to name %q", name, p.Why, w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if strings.Contains(p.Why, "lib has no registration") {
|
||||||
|
t.Errorf("%s: why %q names a registered mover as having no registration", name, p.Why)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,6 +244,24 @@ func (v Verbs) Cancel(caller string, in seat.CancelInput) (seat.CancelAnswer, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EndAgain judges a running pipeline's end once more by hand, recorded in the hand-act log first (design 47 H §746,
|
||||||
|
// H-A-163, H-A-164): it ends as at a step's end, failed as soon as it can no longer pass, and says it, taking its turn in
|
||||||
|
// the queue; one that still cannot end is answered running. A pipeline not running is refused.
|
||||||
|
func (v Verbs) EndAgain(_ string, in seat.EndAgainInput) (seat.EndAgainAnswer, error) {
|
||||||
|
p, _, err := v.change(in.Pipeline, seat.EventStepEnded, func() error {
|
||||||
|
return v.record(seat.VerbEndAgain, "judged the end of the pipeline "+in.Pipeline+" again", in.Why)
|
||||||
|
}, func(p *seat.Pipeline, _ time.Time) (int, error) {
|
||||||
|
if p.Outcome != seat.PipelineOutcomeRunning {
|
||||||
|
return -1, fmt.Errorf("the pipeline %s is %s, not running", in.Pipeline, p.Outcome)
|
||||||
|
}
|
||||||
|
return -1, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return seat.EndAgainAnswer{}, err
|
||||||
|
}
|
||||||
|
return seat.EndAgainAnswer{Pipeline: p}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Rerun asks one step again, recorded in the hand-act log first (§22, §39): the step goes back to running under a new ask,
|
// Rerun asks one step again, recorded in the hand-act log first (§22, §39): the step goes back to running under a new ask,
|
||||||
// the ask saying it is a rerun and the caller the bus proved; a failed pipeline runs again and ends once more with its end
|
// the ask saying it is a rerun and the caller the bus proved; a failed pipeline runs again and ends once more with its end
|
||||||
// count one higher (§325), an approval never asked waiting again. A review waits again; an approval is asked again by
|
// count one higher (§325), an approval never asked waiting again. A review waits again; an approval is asked again by
|
||||||
|
|||||||
@@ -156,6 +156,30 @@ func TestAcceptRerunAndCancelWriteByCompareAndSetAndRecordTheirHandAct(t *testin
|
|||||||
t.Errorf("%d hand acts recorded, want accept, rerun, cancel (3): %v", n, *acts)
|
t.Errorf("%d hand acts recorded, want accept, rerun, cancel (3): %v", n, *acts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-163, H-A-164: end-again judges a running pipeline's end once more, a hand act; a pipeline the judgement before
|
||||||
|
// left running (a mover waiting on its registration, a placed one failed, nothing open) ends failed naming that mover.
|
||||||
|
if _, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: pkey, Why: "again"}); err == nil || len(*acts) != 3 {
|
||||||
|
t.Errorf("end-again of a cancelled pipeline = %v, %d hand acts, want refused and none recorded", err, len(*acts))
|
||||||
|
}
|
||||||
|
store["main.20"] = struct {
|
||||||
|
p seat.Pipeline
|
||||||
|
rev uint64
|
||||||
|
}{seat.Pipeline{Pipeline: "main.20", Branch: "main", Source: 20, Outcome: seat.PipelineOutcomeRunning,
|
||||||
|
Movers: []seat.Mover{{Module: "app"}, {Module: "contracts"}}, Steps: []seat.StepResult{
|
||||||
|
{Step: seat.StepResultStepBuild, Module: "app", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeFailed}}}, 1}
|
||||||
|
// contracts is named by no registration (H-A-171).
|
||||||
|
v.Hearer.Unplaced = func(p seat.Pipeline, m string) string { return (&Starter{}).Unplaced(p, m, nil) }
|
||||||
|
if _, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: "main.20"}); err == nil {
|
||||||
|
t.Error("an end-again with no why was taken")
|
||||||
|
}
|
||||||
|
e, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: "main.20", Why: "left running by the judgement before H-A-163"})
|
||||||
|
if err != nil || e.Pipeline.Outcome != seat.PipelineOutcomeFailed || e.Pipeline.EndCount != 1 || !strings.Contains(e.Pipeline.Why, "contracts has no registration") {
|
||||||
|
t.Fatalf("end-again = %+v, %v, want main.20 ended failed naming contracts", e.Pipeline, err)
|
||||||
|
}
|
||||||
|
if last := (*said)[len(*said)-1]; !strings.HasPrefix(last, "pipeline-ended.") || len(*acts) != 4 || !strings.Contains((*acts)[3], "mesh-pipeline-runner.end-again") {
|
||||||
|
t.Errorf("end-again said %q and recorded %v, want pipeline-ended and its hand act", last, *acts)
|
||||||
|
}
|
||||||
|
|
||||||
// H-A-101 (1): on a pipeline of two movers a verb names the mover's module; one naming none, or a module the pipeline
|
// H-A-101 (1): on a pipeline of two movers a verb names the mover's module; one naming none, or a module the pipeline
|
||||||
// does not move, is refused, and the module named picks that mover's step.
|
// does not move, is refused, and the module named picks that mover's step.
|
||||||
two, store2, _, _, _, _ := verbsFixture()
|
two, store2, _, _, _, _ := verbsFixture()
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ func TestManifest(t *testing.T) {
|
|||||||
{"uses operator-channel", equalSets(m.Uses, []string{"operator-channel"})},
|
{"uses operator-channel", equalSets(m.Uses, []string{"operator-channel"})},
|
||||||
// RN25 (§539): the runner's tools carry the prefix runner_.
|
// RN25 (§539): the runner's tools carry the prefix runner_.
|
||||||
{"first-view tools", equalSets(m.Tools, []string{"runner_first_views", "runner_first_view_again", "runner_health", "runner_unlogged", "runner_unlogged_append",
|
{"first-view tools", equalSets(m.Tools, []string{"runner_first_views", "runner_first_view_again", "runner_health", "runner_unlogged", "runner_unlogged_append",
|
||||||
"runner_start", "runner_run", "runner_accept", "runner_ask_again", "runner_place", "runner_waiting",
|
"runner_start", "runner_run", "runner_accept", "runner_ask_again", "runner_place", "runner_end_again", "runner_waiting",
|
||||||
"runner_test_runs", "runner_test_runs_drop"})},
|
"runner_test_runs", "runner_test_runs_drop"})},
|
||||||
// A-305 (ADR 0227 rule 8, ADR 0240 rule 2): the process is judged by its unit, as every process of mesh-delivery,
|
// A-305 (ADR 0227 rule 8, ADR 0240 rule 2): the process is judged by its unit, as every process of mesh-delivery,
|
||||||
// never by a tool of its own; runner_health stays a tool.
|
// never by a tool of its own; runner_health stays a tool.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"rerun",
|
"rerun",
|
||||||
"accept",
|
"accept",
|
||||||
"cancel",
|
"cancel",
|
||||||
|
"end-again",
|
||||||
"place",
|
"place",
|
||||||
"ask-again",
|
"ask-again",
|
||||||
"test-runs",
|
"test-runs",
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
"runner_accept",
|
"runner_accept",
|
||||||
"runner_ask_again",
|
"runner_ask_again",
|
||||||
"runner_place",
|
"runner_place",
|
||||||
|
"runner_end_again",
|
||||||
"runner_waiting",
|
"runner_waiting",
|
||||||
"runner_test_runs",
|
"runner_test_runs",
|
||||||
"runner_test_runs_drop"
|
"runner_test_runs_drop"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// at a commit of the repository that builds it. The indexer reads it so at each trunk merge (its packages state's series
|
// at a commit of the repository that builds it. The indexer reads it so at each trunk merge (its packages state's series
|
||||||
// keys), and the checker so at a delivery group member's head for a package new in the group, so the judge is handed one
|
// keys), and the checker so at a delivery group member's head for a package new in the group, so the judge is handed one
|
||||||
// name for each package whoever reads it (mesh-sdk composer.Request.Packages).
|
// name for each package whoever reads it (mesh-sdk composer.Request.Packages).
|
||||||
|
// Design 47 H1, proof 2: this comment is the mesh-delivery-sdk half of a two-module change its pipeline delivers.
|
||||||
package packagename
|
package packagename
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user