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, or did not finish, gives // none. The gateResult says whether its namespace's exit was observed: // when it was not, the caller must stop. func (e *Engineer) dependencyStage(ctx context.Context, r stepRow, dir string) (checks.Run, gateResult) { dirs := checks.GoModuleDirs(dir) if existingDir(e.O.Runner.GoRoot) == "" || len(dirs) == 0 { return checks.Run{}, gateResult{terminated: true} } 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{}, res } return checks.Run{Code: res.code, Output: res.output, Evidence: res.evidence}, res }