The controller asks no build of anybody (ADR 0501 §5, ADR 0525 clause 6, ADR 0503 §3). Every module of a walk is taken from the builder's done key; a key not done yet waits, named in the plan, and never fails it. - C2b/C2c: internal/builder and cmd/mesh-controller's asks go (askABuild, onlyTheBuildersOwn, buildOneAsked, takeIn from an outcome, buildAgentsOwn, the builder's say and its fallback, the daemon hearing an outcome). The server follows the retired seats' built subjects only to let go of them, because the installer's carried user list names them. - C2d: replay, queue, cancel, clear, kill, pause, resume, delivery-check, check-here and merge-gate are refused by name. - C3: the check queues (CHECKS_READY, CHECKS_OTHER) and their workers, the checks-running and plans-building buckets and their grants, the build queue and its hold (plans_building.go, queue.go, link/holds.go, builds_nats.go, checks_nats.go). - C4: merge_gate*.go, the pull request's repo-check path, the Checked event and its layers; a pull request asks the controller nothing but to tell mesh-config what its head declares. - C5: the builds bucket is written only by key_takein. - C10 (help and refusals): the terminal's help lists only what is served. Integration tests of the plan's tiers, sends, stops and retries now run on a stand-in builder with a done key for every module (walk_keys_scaffold_integration_test.go); the tests of the asks, the queue, the merge gate and the replays are deleted.
96 lines
3.3 KiB
Go
96 lines
3.3 KiB
Go
package lint
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// What this repository no longer holds (R4g, design 47 acceptance test 24): the checker runs the build module's own steps
|
|
// and the repository's tests, so no script of the repository stands in for them. A file named here came back.
|
|
|
|
// root is this repository's root, from the package's directory.
|
|
const root = "../.."
|
|
|
|
func TestTheRepositoryHoldsNoMergeCheckScript(t *testing.T) {
|
|
for _, name := range []string{"merge-check.sh", "check-nested-modules.sh", "RELEASE-57.md", "testdata/store-tests"} {
|
|
if _, err := os.Stat(filepath.Join(root, name)); err == nil {
|
|
t.Errorf("%s is in the repository: the checker (ADR 0501 §5) runs its steps, and no script of the repository "+
|
|
"stands in for it", name)
|
|
}
|
|
}
|
|
}
|
|
|
|
// No module of this repository keeps a copy of its dependencies (issue 1305): the build module fetches them, and
|
|
// `go build ./...` with GOFLAGS=-mod=mod is how every build reads them.
|
|
func TestTheRepositoryHoldsNoVendorDirectory(t *testing.T) {
|
|
err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if d.IsDir() && d.Name() == ".git" {
|
|
return filepath.SkipDir
|
|
}
|
|
if d.IsDir() && d.Name() == "vendor" {
|
|
t.Errorf("%s is a vendor directory: dependencies are fetched, never kept (issue 1305)", path)
|
|
return filepath.SkipDir
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// sources are the controller's own Go files that are not tests: what the controller does, not what a test stands in for.
|
|
func sources(t *testing.T) map[string]string {
|
|
t.Helper()
|
|
out := map[string]string{}
|
|
err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if d.IsDir() && (d.Name() == ".git" || d.Name() == "testdata") {
|
|
return filepath.SkipDir
|
|
}
|
|
if d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
|
|
return nil
|
|
}
|
|
raw, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
out[path] = string(raw)
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return out
|
|
}
|
|
|
|
// The controller's tree holds no reference to a container runtime for a build (R4g, issue 1851): no socket of one, and no
|
|
// program run to build, pull or export an image. Builds are the build modules' (ADR 0501).
|
|
func TestTheControllerHoldsNoContainerRuntimeForABuild(t *testing.T) {
|
|
for path, src := range sources(t) {
|
|
for _, word := range []string{"docker.sock", `exec.Command("docker"`, `"docker", "pull"`, `"docker", "run"`, "buildah", "podman"} {
|
|
if strings.Contains(src, word) {
|
|
t.Errorf("%s names %s: a build runs on a build module, never through the controller", path, word)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// No file of the controller names the forge's statuses of the retired merge check (issue 1299, issue 1318): a pull request
|
|
// into any repository asks the controller nothing, and the checker's `mesh/check` is the only status it need name.
|
|
func TestNoFileOfTheControllerNamesTheRetiredMergeStatuses(t *testing.T) {
|
|
for path, src := range sources(t) {
|
|
for _, word := range []string{"mesh/merge-gate", "mesh/repo-check", "StatusContextGate", "StatusContextRepoCheck"} {
|
|
if strings.Contains(src, word) {
|
|
t.Errorf("%s names %s, which the controller no longer asks, says or judges", path, word)
|
|
}
|
|
}
|
|
}
|
|
}
|