mesh/merge-gate head 1666747a2246 merged into trunk 04730b54a8f2 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head 1666747a2246 merged into trunk 04730b54a8f2 — pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request
A fresh check asked when only the trunk moved rebuilt every image, though the reuse key said nothing it is built from changed: a controller check took about 12 minutes instead of 5.5. The check now keeps a build kept under its key when a verdict of the build seat names that key and every digest, names it as the build's own check so a walk takes it, and the cleanup keeps it while any check names it (novox/hq issue 703).
70 lines
3.0 KiB
Go
70 lines
3.0 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)
|
|
}
|
|
}
|
|
|
|
// A check reads the builds every pull request's checks made of the modules it builds, and a kept build is named as
|
|
// the check's that built it (novox/hq issue 703).
|
|
func TestNatsACheckReadsTheBuildsOfItsModulesAndAKeptBuildIsTheBuildersCheck(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)
|
|
}
|
|
}
|
|
app := CheckBuilt{Module: "app", Key: "r1:1", Made: []MadeArtifact{{Name: "server", Reference: "s/app/server@sha256:a"}}}
|
|
web := CheckBuilt{Module: "web", Key: "r1:2", Made: []MadeArtifact{{Name: "server", Reference: "s/web/server@sha256:b"}}}
|
|
say(BuildResult{ID: "build-1", Checked: &CheckRequest{Owner: "novox", Repo: "shop", Number: 7},
|
|
Check: &CheckOutcome{Verdict: "pass", Built: []CheckBuilt{app, web}}})
|
|
kept := app
|
|
kept.Kept = "build-1"
|
|
say(BuildResult{ID: "build-2", Checked: &CheckRequest{Owner: "novox", Repo: "till", Number: 3},
|
|
Check: &CheckOutcome{Verdict: "pass", Built: []CheckBuilt{kept}}})
|
|
|
|
got, err := ReadCheckBuildsOf(t.Context(), js, TheBuildMachine, []string{"app"}, since)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(got) != 2 || got[0].Check != "build-1" || got[0].Pull.Repo != "till" || got[1].Check != "build-1" ||
|
|
got[1].Built.Module != "app" {
|
|
t.Fatalf("read %+v", got)
|
|
}
|
|
}
|