checks: Go held to the base; needs-network only from our own stage
Astra review of f03d79bb, two Important findings:
1. checks.NeedsNetwork matched gate text (golang.org/toolchain@ alone),
so a checksum mismatch, a corrupt archive or a test quoting Go's
words made a real failure ChecksCannotRun. Gate output is the
candidate's; it must not establish an environmental result.
3. MAKEFLAGS=GOTOOLCHAIN=local also overrides a newer pin; local Go
then refuses ("go.mod requires go >= ...") and a valid repository is
sent for repair because the runner is too old.
Fix:
- Before the gate, Equipo runs its own dependency stage in the check
profile: go mod download in each module directory (go.mod, not
vendored, not under vendor/testdata/node_modules/dot dirs), on copies
of go.mod and go.sum (-modfile) so the checked tree stays the
candidate's. checks.NeedsNetwork(stage, gate) is true only when that
stage exited non-zero and every line it printed is Go refusing an
offline download (a module under GOPROXY=off, a Go release under
GOSUMDB=off), and the gate failed with no independent failure of its
own (--- FAIL, panic, or a .go diagnostic other than Go failing to
fetch a module, offline or into the read-only cache). Gate text can
only keep a failure a failure. The Mac worker, which has no such
stage, no longer lets its gate text downgrade a failure.
- Before anything runs, the runner's Go (GOROOT/VERSION) is held to
the base's own requirement, read from base objects with the gate
helpers: go and toolchain directives in every go.mod are minimums; a
release a Makefile/.mk pins is honoured by the same minor at that
patch or newer (make runs with GOTOOLCHAIN=local); a release another
gate file pins is honoured only exactly. Unmet reports ChecksCannotRun
with the existing reviewed reason checks_unavailable ("this runner
cannot run the checks"); no gate runs. A candidate that raises the
requirement is still judged (its gate fails in Go's words).
- needsMacOS moves to checks.NeedsMacOS with its test (split by
feature); the thin size record is updated to the measured lines.
Tests first: in checks, TestNeedsNetworkNeedsTheDependencyStage
(checksum mismatch, corrupt archive, quoted diagnostic, stage passed,
mixed test/compile/panic/other write, stray stage line), TestGoRequirement
(newer go and toolchain directives, newer submodule, vendored copies
ignored, Makefile pins of an older minor and a newer patch, +auto
minimums, script pins), TestRunnerGoVersion, TestDependencyStage (real
go: module discovery, offline refusal, a proxy download that leaves the
candidate's go.sum empty); in thin, TestChecksGoToolchainAndDependencies
through Exec in a real containment namespace (newer base requirement,
version-specific base build, candidate raising the requirement, a
pinned patch of this minor, offline dependency, mixed failure, quoted
diagnostic). All failed before the fix.
Mutation checks, each failed, then restored:
- gate text alone decides: "newer go.mod: counted as needs-network";
witness "cannot_run (needs_network), want failed"
- ignore independent failures: "mixed test"; witness "cannot_run
(needs_network), want failed"
- any "go:" line is a refusal: "corrupt archive: counted as needs-network"
- any .go diagnostic is dependency-caused: "mixed test"
- stage exit code ignored: "stage passed: counted as needs-network"
- stage without -modfile: "the stage wrote the candidate's uses/go.sum"
- no dependency stage in the judge: witness "failed, want cannot_run
(needs_network)"
- no toolchain check in the judge: witness "failed, want cannot_run
(checks_unavailable)"
- requirement read from the candidate: witness "cannot_run
(checks_unavailable), want failed"
- Makefile pins as minimums: "make pins an older minor: unmet=false"
- exact pins accept newer: "script pins another patch: unmet=false"
- toolchain directive ignored: "newer toolchain directive: unmet=false"
Proposed for copy review, not added: a log line naming the releases,
for when checks_unavailable is this toolchain case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 files changed,
+611
−82
.rastrillo/budgets.txt+1 −1internal/runner/checks/macos.go+28 −0internal/runner/checks/macos_test.go+22 −0internal/runner/checks/network.go+214 −9internal/runner/checks/network_test.go+176 −20internal/runner/thin/check_go_test.go+106 −0internal/runner/thin/engineer.go+2 −1internal/runner/thin/go_checks.go+52 −0internal/runner/thin/index.go+3 −2internal/runner/thin/judge.go+7 −26internal/runner/thin/judge_test.go+0 −19internal/runner/thin/worker.go+0 −4
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 7c7988d2..b43ddce4 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full |
| perf GET /releases/* skip Verified runner release file downloads, not browser GET screens. |
| perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen. |
| time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s; |
| -size internal/runner/thin 28140 21846 Fable follow-up gates and guards, then main started at repo creation; measured 28140/21846 source/test lines (start steps logged as fixed codes; tool socket bound by descriptor). |
| +size internal/runner/thin 28171 21933 Fable follow-up gates and guards, then main started at repo creation; measured 28171/21933 source/test lines (tool socket bound by descriptor; checks hold Go to the base and take needs-network only from their own dependency stage). |
| time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes. |
| time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing. |
| time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s). |
diff --git a/internal/runner/checks/macos.go b/internal/runner/checks/macos.go| new file mode 100644 |
| index 00000000..a13f4d1c |
| --- /dev/null |
| +++ b/internal/runner/checks/macos.go |
| @@ -0,0 +1,28 @@ |
| +package checks |
| + |
| +import ( |
| + "path" |
| + "strings" |
| +) |
| + |
| +// NeedsMacOS reports whether checking this change needs Apple's tools: |
| +// the change touches Swift, Objective-C or Xcode files, or the gate |
| +// itself calls Xcode's tools. A Linux runner cannot check those, so it |
| +// says so rather than pass or fail. |
| +func NeedsMacOS(changed []string, gateText string) bool { |
| + for _, f := range changed { |
| + switch strings.ToLower(path.Ext(f)) { |
| + case ".swift", ".m", ".mm", ".xib", ".storyboard", ".xcconfig", ".entitlements": |
| + return true |
| + } |
| + if strings.Contains(f, ".xcodeproj/") || strings.Contains(f, ".xcworkspace/") || path.Base(f) == "Package.swift" || path.Base(f) == "Podfile" { |
| + return true |
| + } |
| + } |
| + for _, tool := range []string{"xcodebuild", "xcrun", "swift build", "swift test", "fastlane"} { |
| + if strings.Contains(gateText, tool) { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
diff --git a/internal/runner/checks/macos_test.go b/internal/runner/checks/macos_test.go| new file mode 100644 |
| index 00000000..7988ad2e |
| --- /dev/null |
| +++ b/internal/runner/checks/macos_test.go |
| @@ -0,0 +1,22 @@ |
| +package checks |
| + |
| +import "testing" |
| + |
| +// A Linux runner says honestly that it cannot check Apple code. |
| +func TestNeedsMacOS(t *testing.T) { |
| + for _, tc := range []struct { |
| + changed []string |
| + gate string |
| + want bool |
| + }{ |
| + {[]string{"ios/Woodstar/AccountNavigationHost.swift"}, "./scripts/ci.sh", true}, |
| + {[]string{"ios/Woodstar.xcodeproj/project.pbxproj"}, "", true}, |
| + {[]string{"internal/x.go", "web/a.js"}, "go test ./...", false}, |
| + {[]string{"README.md"}, "xcodebuild test -scheme App", true}, |
| + {nil, "make ci", false}, |
| + } { |
| + if got := NeedsMacOS(tc.changed, tc.gate); got != tc.want { |
| + t.Fatalf("NeedsMacOS(%v, %q) = %v", tc.changed, tc.gate, got) |
| + } |
| + } |
| +} |
diff --git a/internal/runner/checks/network.go b/internal/runner/checks/network.go| index 3150a912..5a950a14 100644 |
| --- a/internal/runner/checks/network.go |
| +++ b/internal/runner/checks/network.go |
| @@ -1,13 +1,218 @@ |
| package checks |
| -import "regexp" |
| +import ( |
| + "errors" |
| + "go/version" |
| + "io/fs" |
| + "os" |
| + "path" |
| + "path/filepath" |
| + "regexp" |
| + "slices" |
| + "strings" |
| +) |
| -// offline matches a gate that needed the network: a module or toolchain |
| -// download (a Go release fetched as golang.org/toolchain is refused |
| -// offline even when cached, since GOSUMDB=off cannot verify it) or a |
| -// name lookup. |
| -var offline = regexp.MustCompile(`GOPROXY=off|module lookup disabled|golang\.org/toolchain@|disabled by GOSUMDB=off|Could not resolve host|Temporary failure in name resolution|ENOTFOUND|EAI_AGAIN`) |
| +// Run is a command's exit code and combined output. |
| +type Run struct { |
| + Code int |
| + Output string |
| +} |
| -// NeedsNetwork reports whether a gate's output shows it needed the |
| -// network, so it could neither pass nor fail honestly offline. |
| -func NeedsNetwork(output string) bool { return offline.MatchString(output) } |
| +// Go's own refusals to download offline, as `go mod download` prints them |
| +// under GOPROXY=off and GOSUMDB=off: a module the cache lacks, and a Go |
| +// release (golang.org/toolchain), which is verified against the checksum |
| +// database even when cached. |
| +// Go's progress lines there are neither evidence nor a disqualification. |
| +var neutralLine = regexp.MustCompile(`^go: (?:no module dependencies to download|downloading \S+ \S+)$`) |
| +var offlineRefusal = regexp.MustCompile(`^go: (?:download go1\.[0-9a-z.]+ for [a-z0-9]+/[a-z0-9]+: )?(?:[^\s@:]+@[^\s@:]+: module lookup disabled by GOPROXY=off|golang\.org/toolchain@v0\.0\.1-go1\.[0-9a-z.]+-[a-z0-9]+: verifying module: checksum database disabled by GOSUMDB=off)$`) |
| + |
| +// A failure of the gate's own, beyond dependencies it could not fetch: a |
| +// failing test, a panic, or a compiler or vet diagnostic other than Go |
| +// failing to fetch a module (offline, or into the read-only cache, which |
| +// is how a build in the check profile reports a module the cache lacks). |
| +// These lines only decide what does not count against the stage's |
| +// evidence; they never establish it. |
| +var independentFailure = regexp.MustCompile(`(?m)^(?:--- FAIL: |panic: |\S+\.go:[0-9]+(?::[0-9]+)?: )`) |
| +var offlineDiagnostic = regexp.MustCompile(`^\S+\.go:[0-9]+(?::[0-9]+)?: (?:module lookup disabled by GOPROXY=off|(?:mkdir|open) /opt/go-mod/cache/download/\S+: read-only file system)$`) |
| + |
| +// NeedsNetwork reports whether a failed gate could neither pass nor fail |
| +// honestly offline. Only Equipo's own dependency stage can show it: the |
| +// stage failed, and every line it printed is Go refusing an offline |
| +// download. The gate's output is the candidate's, so it can only keep a |
| +// failure a failure: a failing test, a panic or another diagnostic there |
| +// means the gate failed on its own. |
| +func NeedsNetwork(stage, gate Run) bool { |
| + if gate.Code == 0 || !offlineDependencies(stage) { |
| + return false |
| + } |
| + for _, line := range strings.Split(gate.Output, "\n") { |
| + if independentFailure.MatchString(line) && !offlineDiagnostic.MatchString(line) { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +func offlineDependencies(stage Run) bool { |
| + seen := false |
| + for _, line := range strings.Split(stage.Output, "\n") { |
| + if line = strings.TrimSpace(line); line == "" || neutralLine.MatchString(line) { |
| + continue |
| + } |
| + if !offlineRefusal.MatchString(line) { |
| + return false |
| + } |
| + seen = true |
| + } |
| + return stage.Code != 0 && seen |
| +} |
| + |
| +// GoModuleDirs lists the directories under root ("." first) holding a |
| +// module's go.mod whose dependencies come from the module cache: not |
| +// vendored, and not under vendor, testdata, node_modules or a directory |
| +// Go ignores (a leading dot or underscore). Symlinks are not followed. |
| +func GoModuleDirs(root string) []string { |
| + dir, err := os.OpenRoot(root) |
| + if err != nil { |
| + return nil |
| + } |
| + defer dir.Close() |
| + var out []string |
| + _ = fs.WalkDir(dir.FS(), ".", func(name string, d fs.DirEntry, err error) error { |
| + if err != nil || len(out) >= 64 { |
| + return fs.SkipDir |
| + } |
| + if d.IsDir() { |
| + if base := d.Name(); name != "." && (ignoredDir(base)) { |
| + return fs.SkipDir |
| + } |
| + return nil |
| + } |
| + if d.Name() != "go.mod" || !d.Type().IsRegular() { |
| + return nil |
| + } |
| + if info, err := dir.Lstat(path.Join(path.Dir(name), "vendor/modules.txt")); err != nil || !info.Mode().IsRegular() { |
| + out = append(out, path.Dir(name)) |
| + } |
| + return nil |
| + }) |
| + slices.Sort(out) |
| + return out |
| +} |
| + |
| +func ignoredDir(base string) bool { |
| + return base == "vendor" || base == "testdata" || base == "node_modules" || strings.HasPrefix(base, ".") || strings.HasPrefix(base, "_") |
| +} |
| + |
| +// DependencyStage is the argv of Equipo's own dependency stage: `go mod |
| +// download` in each module directory, stopping at the first failure. It |
| +// works on copies of go.mod and go.sum (-modfile), so the tree the gate |
| +// then checks is exactly the candidate's. |
| +func DependencyStage(dirs []string) []string { |
| + const script = `t=$(mktemp -d) || exit 1 |
| +i=0 |
| +for d; do |
| + i=$((i+1)); mkdir -p "$t/$i" || exit 1 |
| + cp -- "$d/go.mod" "$t/$i/go.mod" || exit 1 |
| + if [ -f "$d/go.sum" ]; then cp -- "$d/go.sum" "$t/$i/go.sum" || exit 1; fi |
| + (cd -- "$d" && go mod download -modfile="$t/$i/go.mod") || exit $? |
| +done` |
| + return append([]string{"/usr/bin/bash", "-c", script, "equipo-dependencies"}, dirs...) |
| +} |
| + |
| +// GoRequirement is what a repository's own files ask of the Go toolchain. |
| +type GoRequirement struct { |
| + // Minimum is the highest go or toolchain directive in any go.mod. |
| + Minimum string |
| + // Make are the releases Makefiles pin. make runs with |
| + // GOTOOLCHAIN=local (gotoolchain.Environment), so a newer patch of |
| + // the same minor release stands in. |
| + Make []string |
| + // Exact are the releases other gate files pin. Nothing overrides |
| + // those, so only that release runs them. |
| + Exact []string |
| +} |
| + |
| +// GoRequirementFile reports whether a repository file is read for its Go |
| +// requirement: a go.mod (not a vendored or test-data copy), a Makefile or |
| +// .mk file, or an Amadan gate file. |
| +func GoRequirementFile(name string) bool { |
| + for _, part := range strings.Split(path.Dir(name), "/") { |
| + if part != "." && ignoredDir(part) && part != ".amadan" { |
| + return false |
| + } |
| + } |
| + base := path.Base(name) |
| + return base == "go.mod" || base == "Makefile" || base == "makefile" || base == "GNUmakefile" || path.Ext(name) == ".mk" || name == ".amadan/ci" || strings.HasPrefix(name, ".amadan/ci.d/") |
| +} |
| + |
| +var goDirective = regexp.MustCompile(`(?m)^[ \t]*(go|toolchain)[ \t]+(\S+)[ \t]*(?://.*)?$`) |
| +var toolchainPin = regexp.MustCompile(`\bGOTOOLCHAIN[ \t]*(?::=|::=|\?=|=)[ \t]*['"]?(go1\.[0-9]+(?:\.[0-9]+)?(?:(?:rc|beta)[0-9]+)?)(\+auto|\+path)?`) |
| + |
| +// ReadGoRequirement reads the requirement from files named by |
| +// GoRequirementFile (path to content). |
| +func ReadGoRequirement(files map[string][]byte) GoRequirement { |
| + var r GoRequirement |
| + raise := func(v string) { |
| + if version.IsValid(v) && (r.Minimum == "" || version.Compare(v, r.Minimum) > 0) { |
| + r.Minimum = v |
| + } |
| + } |
| + for name, body := range files { |
| + text := string(body) |
| + if path.Base(name) == "go.mod" { |
| + for _, m := range goDirective.FindAllStringSubmatch(text, -1) { |
| + v := m[2] |
| + if m[1] == "go" { |
| + v = "go" + v |
| + } |
| + raise(v) |
| + } |
| + continue |
| + } |
| + makefile := path.Base(name) != "ci" && !strings.HasPrefix(name, ".amadan/") |
| + for _, m := range toolchainPin.FindAllStringSubmatch(text, -1) { |
| + switch { |
| + case m[2] != "": |
| + raise(m[1]) |
| + case makefile: |
| + r.Make = append(r.Make, m[1]) |
| + default: |
| + r.Exact = append(r.Exact, m[1]) |
| + } |
| + } |
| + } |
| + return r |
| +} |
| + |
| +// Unmet reports whether the local toolchain (go1.x.y) cannot honour r. |
| +func (r GoRequirement) Unmet(local string) bool { |
| + if r.Minimum != "" && version.Compare(local, r.Minimum) < 0 { |
| + return true |
| + } |
| + for _, pin := range r.Make { |
| + if version.Lang(pin) != version.Lang(local) || version.Compare(local, pin) < 0 { |
| + return true |
| + } |
| + } |
| + for _, pin := range r.Exact { |
| + if version.Compare(local, pin) != 0 { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// RunnerGoVersion is the release of the Go tree at goRoot, from the first |
| +// line of its VERSION file. |
| +func RunnerGoVersion(goRoot string) (string, error) { |
| + raw, err := os.ReadFile(filepath.Join(goRoot, "VERSION")) |
| + if err != nil { |
| + return "", err |
| + } |
| + v, _, _ := strings.Cut(string(raw), "\n") |
| + if v = strings.TrimSpace(v); !version.IsValid(v) { |
| + return "", errors.New("go root has no release version") |
| + } |
| + return v, nil |
| +} |
diff --git a/internal/runner/checks/network_test.go b/internal/runner/checks/network_test.go| index 455d2782..e59b3197 100644 |
| --- a/internal/runner/checks/network_test.go |
| +++ b/internal/runner/checks/network_test.go |
| @@ -1,30 +1,186 @@ |
| package checks |
| -import "testing" |
| +import ( |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "slices" |
| + "testing" |
| -// TestNeedsNetworkIncludesToolchainFetch: production 2026-11-22, a |
| -// gate asked for a Go release it did not have. The download was refused |
| -// offline ("checksum database disabled by GOSUMDB=off") and the checks |
| -// counted as failed, so Engineering was sent to repair a candidate that |
| -// was not at fault. A gate that needs to fetch a toolchain cannot pass or |
| -// fail honestly here: it needs the network, as a module lookup does. |
| -func TestNeedsNetworkIncludesToolchainFetch(t *testing.T) { |
| - for _, out := range []string{ |
| - "go: golang.org/toolchain@v0.0.1-go1.26.5.linux-amd64: verifying module: checksum database disabled by GOSUMDB=off\nmake: *** [Makefile:82: deps] Error 1", |
| - "go: downloading go1.27.1 (linux/amd64)\ngo: download go1.27.1 for linux/amd64: golang.org/toolchain@v0.0.1-go1.27.1.linux-amd64: module lookup disabled by GOPROXY=off", |
| - "go: amadan.net/oficina/home/handoff@v0.0.0-20261120140933-17cdcaff3345: module lookup disabled by GOPROXY=off", |
| + "golang.org/x/mod/module" |
| + modzip "golang.org/x/mod/zip" |
| +) |
| + |
| +const ( |
| + toolchainRefused = "go: golang.org/toolchain@v0.0.1-go1.26.5.linux-amd64: verifying module: checksum database disabled by GOSUMDB=off" |
| + moduleRefused = "go: amadan.net/oficina/home/handoff@v0.0.0-20261120140933-17cdcaff3345: module lookup disabled by GOPROXY=off" |
| +) |
| + |
| +// TestNeedsNetworkNeedsTheDependencyStage: only Equipo's own dependency |
| +// stage can say a gate needed the network: it failed, and everything Go |
| +// printed there is its refusal to download a module or a Go release |
| +// offline. Gate text, which the candidate controls, can only keep a |
| +// failure a failure (Astra, review of f03d79bb). |
| +func TestNeedsNetworkNeedsTheDependencyStage(t *testing.T) { |
| + offline := Run{Code: 1, Output: moduleRefused + "\n" + toolchainRefused + "\n"} |
| + gateDeps := Run{Code: 2, Output: "go mod download in . failed (the hub's git rate limit?); retrying in 5s\napp.go:32:2: module lookup disabled by GOPROXY=off\nx.go:3:8: mkdir /opt/go-mod/cache/download/example.invalid: read-only file system\nFAIL\tamadan.net/oficina/home [setup failed]\nFAIL\nmake: *** [Makefile:82: deps] Error 1\n"} |
| + if !NeedsNetwork(offline, gateDeps) { |
| + t.Fatal("an offline dependency stage and a gate failing on dependencies is not needs-network") |
| + } |
| + for name, tc := range map[string]struct{ stage, gate Run }{ |
| + "checksum mismatch": {Run{Code: 1, Output: "verifying example.com/m@v1.0.0: checksum mismatch\n\tdownloaded: h1:aaa=\n\tgo.sum: h1:bbb=\n\nSECURITY ERROR\nThis download does NOT match an earlier download recorded in go.sum.\n"}, gateDeps}, |
| + "corrupt archive": {Run{Code: 1, Output: "go: golang.org/toolchain@v0.0.1-go1.26.5.linux-amd64: zip: not a valid zip file\n"}, gateDeps}, |
| + // The stage passed; the gate quotes Go's refusals (a test's own |
| + // output, or printed outright) and fails. |
| + "quoted diagnostic": {Run{}, Run{Code: 1, Output: " door_test.go:12: got \"" + toolchainRefused + "\"\n" + toolchainRefused + "\n" + moduleRefused + "\nFAIL\n"}}, |
| + "stage passed": {Run{Code: 0, Output: toolchainRefused}, gateDeps}, |
| + "mixed test": {offline, Run{Code: 1, Output: gateDeps.Output + "--- FAIL: TestDoorPages (0.01s)\n"}}, |
| + "mixed compile": {offline, Run{Code: 1, Output: gateDeps.Output + "./calma.go:12:2: undefined: doorView\n"}}, |
| + "mixed panic": {offline, Run{Code: 1, Output: gateDeps.Output + "panic: runtime error: index out of range\n"}}, |
| + "mixed other write": {offline, Run{Code: 1, Output: gateDeps.Output + "x.go:3:8: open /workspace/gen.go: read-only file system\n"}}, |
| + "stage other line": {Run{Code: 1, Output: moduleRefused + "\nbash: cd: handoff: No such file or directory\n"}, gateDeps}, |
| + "stage empty": {Run{Code: 1}, gateDeps}, |
| + "stage only progress": {Run{Code: 1, Output: "go: no module dependencies to download\n"}, gateDeps}, |
| + "gate passed": {offline, Run{}}, |
| + "newer go.mod": {Run{Code: 1, Output: "go: go.mod requires go >= 1.27.0 (running go 1.26.10; GOTOOLCHAIN=local)\n"}, gateDeps}, |
| } { |
| - if !NeedsNetwork(out) { |
| - t.Fatalf("offline gate counted as a failure: %q", out) |
| + if NeedsNetwork(tc.stage, tc.gate) { |
| + t.Errorf("%s: counted as needs-network", name) |
| } |
| } |
| - for _, out := range []string{ |
| - "--- FAIL: TestDoorPages (0.01s)\n render_test.go:12: missing door\nFAIL", |
| - "go: go.mod requires go >= 1.27.0 (running go 1.26.10; GOTOOLCHAIN=local)", |
| - "./calma.go:12:2: undefined: doorView", |
| +} |
| + |
| +// TestGoRequirement: the runner's Go must meet what the base's own |
| +// go.mod files and gate files ask. go and toolchain directives are |
| +// minimums; a release a Makefile pins is honoured by the same minor |
| +// release at that patch or newer (make runs with GOTOOLCHAIN=local); a |
| +// release any other gate file pins is honoured only exactly. |
| +func TestGoRequirement(t *testing.T) { |
| + home := map[string]string{"go.mod": "module amadan.net/oficina/home\n\ngo 1.26.0\n\ntoolchain go1.26.5\n", "handoff/go.mod": "module x\n\ngo 1.25.0\n", "Makefile": "export GOTOOLCHAIN := go1.26.5\nbuild:\n\tgo build ./...\n"} |
| + for _, tc := range []struct { |
| + name string |
| + files map[string]string |
| + met bool |
| + }{ |
| + {"home", home, true}, |
| + {"newer go directive", map[string]string{"go.mod": "module x\n\ngo 1.27.0\n"}, false}, |
| + {"newer toolchain directive", map[string]string{"go.mod": "module x\n\ngo 1.26.0\ntoolchain go1.27.1\n"}, false}, |
| + {"newer submodule", map[string]string{"go.mod": "module x\n\ngo 1.26.0\n", "tools/go.mod": "module y\n\ngo 1.26.11\n"}, false}, |
| + {"vendored go.mod ignored", map[string]string{"go.mod": "module x\n\ngo 1.26.0\n", "vendor/example.com/y/go.mod": "module y\n\ngo 1.30\n", "internal/testdata/go.mod": "module z\n\ngo 1.30\n"}, true}, |
| + {"make pins an older minor", map[string]string{"Makefile": "export GOTOOLCHAIN := go1.25.4\n"}, false}, |
| + {"make pins a newer patch", map[string]string{"build/go.mk": "GOTOOLCHAIN ?= go1.26.11\n"}, false}, |
| + {"make pins a minimum", map[string]string{"GNUmakefile": "export GOTOOLCHAIN=go1.26.3+auto\n"}, true}, |
| + {"make pins a newer minimum", map[string]string{"Makefile": "export GOTOOLCHAIN = go1.27.0+auto\n"}, false}, |
| + {"make asks for local", map[string]string{"Makefile": "export GOTOOLCHAIN := local\n"}, true}, |
| + {"script pins another patch", map[string]string{".amadan/ci.d/10-vet": "#!/bin/sh\nexport GOTOOLCHAIN=go1.26.5\nexec go vet ./...\n"}, false}, |
| + {"script pins this release", map[string]string{".amadan/ci": "GOTOOLCHAIN='go1.26.10' go test ./...\n"}, true}, |
| + {"no Go", map[string]string{"package.json": "{}"}, true}, |
| } { |
| - if NeedsNetwork(out) { |
| - t.Fatalf("candidate failure counted as offline: %q", out) |
| + files := map[string][]byte{} |
| + for name, body := range tc.files { |
| + if !GoRequirementFile(name) && name != "package.json" && name != "vendor/example.com/y/go.mod" && name != "internal/testdata/go.mod" { |
| + t.Fatalf("%s: %s not read", tc.name, name) |
| + } |
| + if GoRequirementFile(name) { |
| + files[name] = []byte(body) |
| + } |
| + } |
| + if got := ReadGoRequirement(files).Unmet("go1.26.10"); got == tc.met { |
| + t.Errorf("%s: unmet=%v", tc.name, got) |
| + } |
| + } |
| +} |
| + |
| +func TestRunnerGoVersion(t *testing.T) { |
| + root := t.TempDir() |
| + if _, err := RunnerGoVersion(root); err == nil { |
| + t.Fatal("missing VERSION accepted") |
| + } |
| + os.WriteFile(filepath.Join(root, "VERSION"), []byte("go1.26.10\ntime 2026-11-05T00:00:00Z\n"), 0o600) |
| + if v, err := RunnerGoVersion(root); err != nil || v != "go1.26.10" { |
| + t.Fatalf("%q %v", v, err) |
| + } |
| + os.WriteFile(filepath.Join(root, "VERSION"), []byte("devel +abc\n"), 0o600) |
| + if _, err := RunnerGoVersion(root); err == nil { |
| + t.Fatal("unversioned toolchain accepted") |
| + } |
| +} |
| + |
| +// TestDependencyStage: the stage downloads each module's dependencies |
| +// from the read-only cache, in Go's own words, and leaves the tree's |
| +// go.mod and go.sum exactly as the candidate wrote them. |
| +func TestDependencyStage(t *testing.T) { |
| + goBin, err := exec.LookPath("go") |
| + if err != nil { |
| + t.Skip("go is not installed") |
| + } |
| + tree := t.TempDir() |
| + write := func(name, body string) { |
| + p := filepath.Join(tree, name) |
| + os.MkdirAll(filepath.Dir(p), 0o700) |
| + if err := os.WriteFile(p, []byte(body), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + write("go.mod", "module example.com/app\n\ngo 1.21\n") |
| + write("app.go", "package app\n") |
| + write("dep/go.mod", "module example.com/dep\n\ngo 1.21\n\nrequire example.invalid/missing v1.0.0\n") |
| + write("dep/go.sum", "") |
| + write("vendored/go.mod", "module example.com/vendored\n\ngo 1.21\n\nrequire example.invalid/v v1.0.0\n") |
| + write("vendored/vendor/modules.txt", "# example.invalid/v v1.0.0\n") |
| + for _, skipped := range []string{"vendor/x/go.mod", "testdata/go.mod", ".hidden/go.mod", "node_modules/x/go.mod", "_old/go.mod"} { |
| + write(skipped, "module skipped\n") |
| + } |
| + dirs := GoModuleDirs(tree) |
| + if !slices.Equal(dirs, []string{".", "dep"}) { |
| + t.Fatalf("module dirs %q", dirs) |
| + } |
| + proxy := "off" |
| + run := func(dirs []string) Run { |
| + argv := DependencyStage(dirs) |
| + cmd := exec.Command(argv[0], argv[1:]...) |
| + cmd.Dir = tree |
| + cmd.Env = []string{"PATH=" + filepath.Dir(goBin) + ":/usr/bin:/bin", "HOME=" + t.TempDir(), "TMPDIR=" + t.TempDir(), "GOMODCACHE=" + t.TempDir(), "GOCACHE=" + t.TempDir(), "GOPROXY=" + proxy, "GOSUMDB=off", "GOTOOLCHAIN=local", "GOFLAGS=-modcacherw", "GOWORK=off", "GOENV=off", "GOTELEMETRY=off"} |
| + out, _ := cmd.CombinedOutput() |
| + return Run{Code: cmd.ProcessState.ExitCode(), Output: string(out)} |
| + } |
| + if res := run([]string{"."}); res.Code != 0 { |
| + t.Fatalf("a module with nothing to download failed: %+v", res) |
| + } |
| + res := run(dirs) |
| + if res.Code == 0 || !NeedsNetwork(res, Run{Code: 1, Output: "make: *** [ci] Error 1\n"}) { |
| + t.Fatalf("missing module not refused offline in Go's words: %+v", res) |
| + } |
| + // A download that succeeds (from a local proxy here) records its sums |
| + // in the stage's copy, never in the candidate's go.sum. |
| + dir := t.TempDir() |
| + lib := filepath.Join(dir, "lib") |
| + os.MkdirAll(lib, 0o700) |
| + os.WriteFile(filepath.Join(lib, "go.mod"), []byte("module example.com/lib\n\ngo 1.21\n"), 0o600) |
| + os.WriteFile(filepath.Join(lib, "lib.go"), []byte("package lib\n"), 0o600) |
| + at := filepath.Join(dir, "proxy/example.com/lib/@v") |
| + os.MkdirAll(at, 0o700) |
| + os.WriteFile(filepath.Join(at, "list"), []byte("v1.0.0\n"), 0o600) |
| + os.WriteFile(filepath.Join(at, "v1.0.0.info"), []byte(`{"Version":"v1.0.0"}`), 0o600) |
| + os.WriteFile(filepath.Join(at, "v1.0.0.mod"), []byte("module example.com/lib\n\ngo 1.21\n"), 0o600) |
| + z, err := os.Create(filepath.Join(at, "v1.0.0.zip")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := modzip.CreateFromDir(z, module.Version{Path: "example.com/lib", Version: "v1.0.0"}, lib); err != nil { |
| + t.Fatal(err) |
| + } |
| + z.Close() |
| + write("uses/go.mod", "module example.com/uses\n\ngo 1.21\n\nrequire example.com/lib v1.0.0\n") |
| + write("uses/go.sum", "") |
| + write("uses/uses.go", "package uses\n\nimport _ \"example.com/lib\"\n") |
| + proxy = "file://" + filepath.Join(dir, "proxy") |
| + if res := run([]string{"uses"}); res.Code != 0 { |
| + t.Fatalf("download from the proxy failed: %+v", res) |
| + } |
| + for _, name := range []string{"dep/go.sum", "uses/go.sum"} { |
| + if raw, _ := os.ReadFile(filepath.Join(tree, name)); len(raw) != 0 { |
| + t.Fatalf("the stage wrote the candidate's %s: %q", name, raw) |
| } |
| } |
| } |
diff --git a/internal/runner/thin/check_go_test.go b/internal/runner/thin/check_go_test.go| new file mode 100644 |
| index 00000000..c8872dd1 |
| --- /dev/null |
| +++ b/internal/runner/thin/check_go_test.go |
| @@ -0,0 +1,106 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "go/version" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/checks" |
| + "amadan.net/oficina/equipo/internal/runner/containment" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestChecksGoToolchainAndDependencies (Astra, review of f03d79bb): the |
| +// runner's Go is held to the base's requirement before any gate runs, |
| +// and only Equipo's own dependency stage can make a failed gate "needs |
| +// network"; the candidate's output can only keep a failure a failure. |
| +func TestChecksGoToolchainAndDependencies(t *testing.T) { |
| + out, err := exec.Command("go", "env", "GOROOT").Output() |
| + if err != nil { |
| + t.Skip("go is not installed") |
| + } |
| + goRoot := strings.TrimSpace(string(out)) |
| + local, err := checks.RunnerGoVersion(goRoot) |
| + if err != nil { |
| + t.Skip("the test's Go has no release version") |
| + } |
| + other := "go1.20.1" |
| + if version.Lang(local) == "go1.20" { |
| + other = "go1.21.1" |
| + } |
| + const sum = "example.invalid/dep v1.0.0 h1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\nexample.invalid/dep v1.0.0/go.mod h1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n" |
| + needsDep := map[string]string{"go.mod": "module example.com/x\n\ngo 1.21\n\nrequire example.invalid/dep v1.0.0\n", "go.sum": sum, "x.go": "package x\n\nimport _ \"example.invalid/dep\"\n"} |
| + plain := map[string]string{"go.mod": "module example.com/x\n\ngo 1.21\n", "x.go": "package x\n"} |
| + with := func(files map[string]string, name, body string) map[string]string { |
| + out := map[string]string{name: body} |
| + for k, v := range files { |
| + if k != name { |
| + out[k] = v |
| + } |
| + } |
| + return out |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + base, candidate map[string]string |
| + outcome, reason string |
| + }{ |
| + {"newer base requirement", with(plain, "go.mod", "module example.com/x\n\ngo 1.99.0\n"), nil, wire.ChecksCannotRun, "checks_unavailable"}, |
| + {"version-specific base build", with(plain, "Makefile", "export GOTOOLCHAIN := "+other+"\nci:\n\ttrue\n"), nil, wire.ChecksCannotRun, "checks_unavailable"}, |
| + {"candidate raises the requirement", plain, map[string]string{"go.mod": "module example.com/x\n\ngo 1.99.0\n"}, wire.ChecksFailed, ""}, |
| + {"pinned patch of this minor", with(plain, "Makefile", "export GOTOOLCHAIN := "+version.Lang(local)+".0\nci:\n\tgo vet ./...\n"), nil, wire.ChecksPassed, ""}, |
| + {"offline dependency", with(needsDep, "Makefile", "ci:\n\tgo vet ./...\n"), nil, wire.ChecksCannotRun, "needs_network"}, |
| + {"mixed failure", with(needsDep, "Makefile", "ci:\n\t@echo '--- FAIL: TestDoor (0.00s)'; go vet ./...\n"), nil, wire.ChecksFailed, ""}, |
| + {"quoted diagnostic", with(plain, "Makefile", "ci:\n\t@echo 'go: golang.org/toolchain@v0.0.1-go1.26.5.linux-amd64: verifying module: checksum database disabled by GOSUMDB=off'; echo 'go: example.invalid/dep@v1.0.0: module lookup disabled by GOPROXY=off'; exit 1\n"), nil, wire.ChecksFailed, ""}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + e, f, r, _ := hubRig(t) |
| + seed := filepath.Join(filepath.Dir(f.dir), "seed") |
| + if _, ok := tc.base["Makefile"]; !ok { |
| + tc.base = with(tc.base, "Makefile", "ci:\n\tgo vet ./...\n") |
| + } |
| + for name, body := range tc.base { |
| + writeFile(t, seed, name, body) |
| + } |
| + gitOut(t, seed, "add", "-A") |
| + gitOut(t, seed, "commit", "-qm", "base") |
| + r.BaseSHA = gitOut(t, seed, "rev-parse", "HEAD") |
| + gitOut(t, seed, "checkout", "-q", "-B", r.Branch) |
| + writeFile(t, seed, "NEWS", "candidate\n") |
| + for name, body := range tc.candidate { |
| + writeFile(t, seed, name, body) |
| + } |
| + gitOut(t, seed, "add", "-A") |
| + gitOut(t, seed, "commit", "-qm", "candidate") |
| + r.CandidateSHA = gitOut(t, seed, "rev-parse", "HEAD") |
| + gitOut(t, seed, "push", "-q", "--force", f.dir, "main", r.Branch) |
| + r.Specialist = wire.SpecialistChecks |
| + scratch := filepath.Join(filepath.Dir(f.dir), "sandbox") |
| + _ = os.Mkdir(scratch, 0o700) |
| + self, _ := os.Executable() |
| + m, err := containment.New(containment.Config{Binary: "/usr/bin/bwrap", RunnerBinary: self, ScratchRoot: scratch}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + // A module cache as a runner has one, without the module. |
| + cache := t.TempDir() |
| + _ = os.MkdirAll(filepath.Join(cache, "cache/download"), 0o700) |
| + e.O.Manager, e.O.Runner.GoRoot, e.O.Runner.ModuleCache = m, goRoot, cache |
| + if err := e.O.State.AcceptDispatch(context.Background(), "d", r.DispatchCommand); err != nil { |
| + t.Fatal(err) |
| + } |
| + rep := e.Exec(context.Background(), r, func(wire.StepReport) {}) |
| + if rep.Checks != tc.outcome || rep.Reason != tc.reason { |
| + t.Fatalf("checks %q (%q), want %q (%q)\n%s", rep.Checks, rep.Reason, tc.outcome, tc.reason, fmt.Sprint(rep.Output)) |
| + } |
| + if tc.reason == "checks_unavailable" && (rep.ExitCode != nil || rep.Output != "") { |
| + t.Fatalf("a gate ran for a toolchain this runner lacks: %+v", rep) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index 20afdb4a..5ad17fbb 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -18,6 +18,7 @@ import ( |
| "time" |
| "amadan.net/oficina/equipo/internal/runner" |
| + "amadan.net/oficina/equipo/internal/runner/checks" |
| "amadan.net/oficina/equipo/internal/runner/connect" |
| "amadan.net/oficina/equipo/internal/runner/forge" |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| @@ -348,7 +349,7 @@ func (e *Engineer) Exec(ctx context.Context, r stepRow, progress func(wire.StepR |
| } |
| if files, err := tree.ChangedFiles(ctx, sha); err == nil && len(files) > 0 { |
| // The instance places its checks on a Mac when it needs one. |
| - rep.Apple = needsMacOS(files, "") |
| + rep.Apple = checks.NeedsMacOS(files, "") |
| rep.LogTail = clip(strings.TrimSpace(rep.LogTail+"\nChanged: "+strings.Join(files[:min(len(files), 20)], ", ")), wire.MaxLogTail) |
| } |
| if err := e.O.State.setStepPhase(ctx, r, phaseCommitted, base, sha); err != nil { |
diff --git a/internal/runner/thin/go_checks.go b/internal/runner/thin/go_checks.go| new file mode 100644 |
| index 00000000..9545ff9a |
| --- /dev/null |
| +++ b/internal/runner/thin/go_checks.go |
| @@ -0,0 +1,52 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "maps" |
| + "slices" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/checks" |
| + "amadan.net/oficina/equipo/internal/runner/workspace" |
| +) |
| + |
| +// goUnmet reports whether the runner's Go cannot honour what the base's |
| +// own go.mod files and gate files ask (checks.GoRequirement), read from |
| +// base objects the candidate cannot change. Unknown is not unmet: the |
| +// gate runs, and Go says why it cannot. |
| +func (e *Engineer) goUnmet(ctx context.Context, tree workspace.TaskTree, base string) bool { |
| + local, err := checks.RunnerGoVersion(e.O.Runner.GoRoot) |
| + if e.O.Runner.GoRoot == "" || err != nil { |
| + return false |
| + } |
| + listing, err := gateListing(ctx, tree.Git, tree.GitDir, base) |
| + if err != nil { |
| + e.log("checks go requirement", err) |
| + return false |
| + } |
| + files := map[string][]byte{} |
| + for _, name := range slices.Sorted(maps.Keys(listing)) { |
| + if mode := listing[name]; checks.GoRequirementFile(name) && (mode == "100644" || mode == "100755") && len(files) < 512 { |
| + if raw, err := gateGit(ctx, tree.Git, tree.GitDir, 1<<20, "cat-file", "blob", base+":"+name); err == nil { |
| + files[name] = raw |
| + } |
| + } |
| + } |
| + return checks.ReadGoRequirement(files).Unmet(local) |
| +} |
| + |
| +// dependencyStage runs Equipo's own `go mod download` for the tree's |
| +// modules in the check profile (checks.DependencyStage), before the gate. |
| +// Its exit code and Go's own lines are the only evidence that a gate |
| +// needed the network; a stage that did not run gives none. |
| +func (e *Engineer) dependencyStage(ctx context.Context, r stepRow, dir string) checks.Run { |
| + dirs := checks.GoModuleDirs(dir) |
| + if existingDir(e.O.Runner.GoRoot) == "" || len(dirs) == 0 { |
| + return checks.Run{} |
| + } |
| + res := e.runGate(ctx, r, dir, gate{name: "dependencies", argv: checks.DependencyStage(dirs), limit: 5 * time.Minute}) |
| + if !res.terminated || res.reason != "" { |
| + return checks.Run{} |
| + } |
| + return checks.Run{Code: res.code, Output: res.output} |
| +} |
diff --git a/internal/runner/thin/index.go b/internal/runner/thin/index.go| index 86263e2e..2ce22dc2 100644 |
| --- a/internal/runner/thin/index.go |
| +++ b/internal/runner/thin/index.go |
| @@ -21,6 +21,7 @@ import ( |
| "unicode" |
| "unicode/utf8" |
| + "amadan.net/oficina/equipo/internal/runner/checks" |
| "amadan.net/oficina/equipo/internal/runner/workspace" |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| @@ -292,11 +293,11 @@ func (x *Index) describe(ctx context.Context, repo, branch, dir string) wire.Rep |
| e.Hints = bounded(hints(list, read), wire.MaxRepoHints) |
| var gateText string |
| e.Gate, gateText = listedGate(list, read) |
| - if runtime.GOOS != "darwin" && needsMacOS(list, gateText) { |
| + if runtime.GOOS != "darwin" && checks.NeedsMacOS(list, gateText) { |
| e.ChecksReason = "needs_macos" |
| } |
| // Protocol 2: what the instance places checks by. |
| - e.NeedsMacOS, e.Simulator = needsMacOS(nil, gateText), sharedScheme(list) |
| + e.NeedsMacOS, e.Simulator = checks.NeedsMacOS(nil, gateText), sharedScheme(list) |
| return e |
| } |
diff --git a/internal/runner/thin/judge.go b/internal/runner/thin/judge.go| index c3c11205..86ab5c24 100644 |
| --- a/internal/runner/thin/judge.go |
| +++ b/internal/runner/thin/judge.go |
| @@ -10,7 +10,6 @@ import ( |
| "io/fs" |
| "os" |
| "os/exec" |
| - "path" |
| "path/filepath" |
| "regexp" |
| "runtime" |
| @@ -194,28 +193,6 @@ func findGate(dir string) (gate, bool) { |
| return gate{}, false |
| } |
| -// needsMacOS reports whether checking this change needs Apple's tools: |
| -// the change touches Swift, Objective-C or Xcode files, or the gate |
| -// itself calls Xcode's tools. A Linux runner cannot check those, so it |
| -// says so rather than pass or fail. |
| -func needsMacOS(changed []string, gateText string) bool { |
| - for _, f := range changed { |
| - switch strings.ToLower(path.Ext(f)) { |
| - case ".swift", ".m", ".mm", ".xib", ".storyboard", ".xcconfig", ".entitlements": |
| - return true |
| - } |
| - if strings.Contains(f, ".xcodeproj/") || strings.Contains(f, ".xcworkspace/") || path.Base(f) == "Package.swift" || path.Base(f) == "Podfile" { |
| - return true |
| - } |
| - } |
| - for _, tool := range []string{"xcodebuild", "xcrun", "swift build", "swift test", "fastlane"} { |
| - if strings.Contains(gateText, tool) { |
| - return true |
| - } |
| - } |
| - return false |
| -} |
| - |
| // checks runs the repository's gate on the candidate. |
| func (e *Engineer) checks(ctx context.Context, r stepRow, progress func(wire.StepReport)) wire.StepReport { |
| rep := judgeReport(r) |
| @@ -301,21 +278,25 @@ func (e *Engineer) checks(ctx context.Context, r stepRow, progress func(wire.Ste |
| } |
| return done(wire.ChecksNone, "") |
| } |
| - mac := runtime.GOOS != "darwin" && needsMacOS(changed, g.text) |
| + mac := runtime.GOOS != "darwin" && checks.NeedsMacOS(changed, g.text) |
| if mac { |
| rep.LogTail = "Not run: " + g.name + " needs macOS to check this change, and this runner is " + runtime.GOOS + "." |
| return done(wire.ChecksCannotRun, "needs_macos") |
| } |
| + if e.goUnmet(ctx, tree, r.BaseSHA) { |
| + return done(wire.ChecksCannotRun, "checks_unavailable") |
| + } |
| if err := e.checkRepository(ctx, tree, r.CandidateSHA); err != nil { |
| e.log("checks repository", err) |
| rep.State, rep.Reason, rep.Termination = wire.StepFailed, "workspace_refused", true |
| return rep |
| } |
| + stage := e.dependencyStage(ctx, r, tree.Dir) |
| res := e.runGate(ctx, r, tree.Dir, g) |
| baseResult, baseGate := res, g |
| if certified { |
| rep.BaseChecks = wire.ChecksCannotRun |
| - if res.terminated && res.reason == "" && (res.code == 0 || !checks.NeedsNetwork(res.output)) { |
| + if res.terminated && res.reason == "" && (res.code == 0 || !checks.NeedsNetwork(stage, checks.Run{Code: res.code, Output: res.output})) { |
| rep.BaseChecks = wire.ChecksFailed |
| if res.code == 0 { |
| rep.BaseChecks = wire.ChecksPassed |
| @@ -368,7 +349,7 @@ func (e *Engineer) checks(ctx context.Context, r stepRow, progress func(wire.Ste |
| case res.reason != "": |
| rep.Gate, rep.Output = "", "" |
| return done(wire.ChecksCannotRun, "checks_unavailable") |
| - case res.code != 0 && checks.NeedsNetwork(gateOutput): |
| + case res.code != 0 && checks.NeedsNetwork(stage, checks.Run{Code: res.code, Output: gateOutput}): |
| // A gate that needs the network cannot pass or fail honestly here. |
| rep.Gate = "" |
| return done(wire.ChecksCannotRun, "needs_network") |
diff --git a/internal/runner/thin/judge_test.go b/internal/runner/thin/judge_test.go| index e77e5310..fb1aed5a 100644 |
| --- a/internal/runner/thin/judge_test.go |
| +++ b/internal/runner/thin/judge_test.go |
| @@ -56,25 +56,6 @@ func TestFindGate(t *testing.T) { |
| } |
| } |
| -// A Linux runner says honestly that it cannot check Apple code. |
| -func TestNeedsMacOS(t *testing.T) { |
| - for _, tc := range []struct { |
| - changed []string |
| - gate string |
| - want bool |
| - }{ |
| - {[]string{"ios/Woodstar/AccountNavigationHost.swift"}, "./scripts/ci.sh", true}, |
| - {[]string{"ios/Woodstar.xcodeproj/project.pbxproj"}, "", true}, |
| - {[]string{"internal/x.go", "web/a.js"}, "go test ./...", false}, |
| - {[]string{"README.md"}, "xcodebuild test -scheme App", true}, |
| - {nil, "make ci", false}, |
| - } { |
| - if got := needsMacOS(tc.changed, tc.gate); got != tc.want { |
| - t.Fatalf("needsMacOS(%v, %q) = %v", tc.changed, tc.gate, got) |
| - } |
| - } |
| -} |
| - |
| func TestLineTailKeepsTheLast200Lines(t *testing.T) { |
| tail := &lineTail{max: wire.MaxChecksLines} |
| for i := 1; i <= 500; i++ { |
diff --git a/internal/runner/thin/worker.go b/internal/runner/thin/worker.go| index c3a180c3..2b64539a 100644 |
| --- a/internal/runner/thin/worker.go |
| +++ b/internal/runner/thin/worker.go |
| @@ -11,7 +11,6 @@ import ( |
| "sync" |
| "time" |
| - "amadan.net/oficina/equipo/internal/runner/checks" |
| "amadan.net/oficina/equipo/internal/runner/mac" |
| "amadan.net/oficina/equipo/internal/runner/workspace" |
| "amadan.net/oficina/equipo/internal/wire" |
| @@ -216,9 +215,6 @@ func (w *Worker) Exec(ctx context.Context, r stepRow, progress func(wire.StepRep |
| case res.reason != "": |
| rep.Gate, rep.Output = "", "" |
| return done(wire.ChecksCannotRun, "checks_unavailable") |
| - case res.code != 0 && checks.NeedsNetwork(res.output): |
| - rep.Gate = "" |
| - return done(wire.ChecksCannotRun, "needs_network") |
| } |
| code := res.code |
| rep.ExitCode = &code |