oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thin
2
3import (
4 "context"
5 "maps"
6 "slices"
7 "time"
8
9 "amadan.net/oficina/equipo/internal/runner/checks"
10 "amadan.net/oficina/equipo/internal/runner/workspace"
11)
12
13// goUnmet reports whether the runner's Go cannot honour what the base's
14// own go.mod files and gate files ask (checks.GoRequirement), read from
15// base objects the candidate cannot change. Unknown is not unmet: the
16// gate runs, and Go says why it cannot.
17func (e *Engineer) goUnmet(ctx context.Context, tree workspace.TaskTree, base string) bool {
18 local, err := checks.RunnerGoVersion(e.O.Runner.GoRoot)
19 if e.O.Runner.GoRoot == "" || err != nil {
20 return false
21 }
22 listing, err := gateListing(ctx, tree.Git, tree.GitDir, base)
23 if err != nil {
24 e.log("checks go requirement", err)
25 return false
26 }
27 files := map[string][]byte{}
28 for _, name := range slices.Sorted(maps.Keys(listing)) {
29 if mode := listing[name]; checks.GoRequirementFile(name) && (mode == "100644" || mode == "100755") && len(files) < 512 {
30 if raw, err := gateGit(ctx, tree.Git, tree.GitDir, 1<<20, "cat-file", "blob", base+":"+name); err == nil {
31 files[name] = raw
32 }
33 }
34 }
35 return checks.ReadGoRequirement(files).Unmet(local)
36}
37
38// dependencyStage runs Equipo's own `go mod download` for the tree's
39// modules in the check profile (checks.DependencyStage), before the gate.
40// Its exit code and Go's own lines are the only evidence that a gate
41// needed the network; a stage that did not run, or did not finish, gives
42// none. The gateResult says whether its namespace's exit was observed:
43// when it was not, the caller must stop.
44func (e *Engineer) dependencyStage(ctx context.Context, r stepRow, dir string) (checks.Run, gateResult) {
45 dirs := checks.GoModuleDirs(dir)
46 if existingDir(e.O.Runner.GoRoot) == "" || len(dirs) == 0 {
47 return checks.Run{}, gateResult{terminated: true}
48 }
49 res := e.runGate(ctx, r, dir, gate{name: "dependencies", argv: checks.DependencyStage(dirs), limit: 5 * time.Minute})
50 if !res.terminated || res.reason != "" {
51 return checks.Run{}, res
52 }
53 return checks.Run{Code: res.code, Output: res.output, Evidence: res.evidence}, res
54}
55