mesh/merge-gate head 5c606fd1d48b merged into trunk 372faebf2824 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head 5c606fd1d48b merged into trunk 372faebf2824 — pass: its merge-check.sh passed (run 2)
mesh/delivery delivered
mesh/delivery-group group feat/350-one-build-per-change delivered: every member is delivered
The artifact store takes writes from anything on its network, so a record planted under another merge's key could have been registered: the walk now takes a scratch build only when the build seat's own verdict for one of its pull requests names its key and digests. Deleting by digest also took builds another check shared (review of #311; novox/hq ADR 0350).
40 lines
1.6 KiB
Go
40 lines
1.6 KiB
Go
package link
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// The builds a walk may take are read from the build seat's own outcomes of its checks (novox/hq ADR 0350 §2): only
|
|
// checks of the walk's pull requests, only builds made, newest first.
|
|
func TestNatsTheBuildsAWalkMayTakeAreTheChecksOutcomesOfItsPullRequests(t *testing.T) {
|
|
js := aBus(t)
|
|
since := time.Now().Add(-time.Minute)
|
|
say := func(r BuildResult) {
|
|
body, _ := json.Marshal(r)
|
|
if _, err := js.Context().Publish(BuildOutcomeOf(TheBuildMachine), body); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
mine := &CheckRequest{Owner: "novox", Repo: "shop", Number: 7}
|
|
built := CheckBuilt{Module: "app", Key: "r1:1", Made: []MadeArtifact{{Name: "server", Reference: "s/app/server@sha256:a"}}}
|
|
say(BuildResult{ID: "build-1", Checked: mine, Check: &CheckOutcome{Verdict: "pass", Built: []CheckBuilt{built,
|
|
{Module: "web", NotBuilt: "it has no reuse key"}}}})
|
|
say(BuildResult{ID: "build-2", Checked: &CheckRequest{Owner: "novox", Repo: "shop", Number: 8},
|
|
Check: &CheckOutcome{Verdict: "pass", Built: []CheckBuilt{built}}})
|
|
say(BuildResult{ID: "build-3", Repository: "novox/shop", Commit: "c0ffee"}) // a build, not a check
|
|
newer := built
|
|
newer.Key = "r1:2"
|
|
say(BuildResult{ID: "build-4", Checked: mine, Check: &CheckOutcome{Verdict: "pass", Built: []CheckBuilt{newer}}})
|
|
|
|
got, err := ReadCheckBuilds(t.Context(), js, TheBuildMachine, []PullRef{{Owner: "novox", Repo: "shop", Number: 7}}, since)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(got) != 2 || got[0].Check != "build-4" || got[0].Built.Key != "r1:2" || got[1].Check != "build-1" ||
|
|
got[1].Pull.Number != 7 {
|
|
t.Fatalf("read %+v", got)
|
|
}
|
|
}
|