oficina / equipo Public

CI: compile once before the parallel shards

Run dd9e43c, 23 shards on an empty cache: each shard compiled the same
packages, because Go does not share a compile between processes that
start together. Every shard took 150 to 370 s (gitleaks 120 s), and two
timing-sensitive tests failed under the load. 10-compile builds every
package and test binary once; the shards then find them in the cache.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev ec9347b4673b4f570f195f5325412186c48594a6 parent dd9e43c
4 files changed, +29 −1
  • .amadan/ci.d/10-compile +4 −0
  • Makefile +11 −1
  • internal/equipotest/foundation_test.go +3 −0
  • scripts/ci-test.py +11 −0
diff --git a/.amadan/ci.d/10-compile b/.amadan/ci.d/10-compile
new file mode 100755
index 00000000..9bcee5c8
--- /dev/null
+++ b/.amadan/ci.d/10-compile
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Build every package and test binary once, so the shards of the next
+# step do not each compile them. A few seconds when the cache is warm.
+exec "$(dirname "$0")/../../scripts/ci-box.py" run make ci-compile
diff --git a/Makefile b/Makefile
index f1e03c8f..9b85a1bc 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ RUNNER_RELEASE_DIR = releases/equipo-runner-linux-amd64-$(RELEASE_VERSION)
# and a suite running beside it would be measured too.
.NOTPARALLEL:
-.PHONY: build release test test-lane ci-shard test-quarantine vet fmt-check staticcheck govulncheck gitleaks budget perf migration-check runner-adapter-test runner-namespace-test runner-host runner-dead-references ci
+.PHONY: build release test test-lane ci-shard ci-compile test-quarantine vet fmt-check staticcheck govulncheck gitleaks budget perf migration-check runner-adapter-test runner-namespace-test runner-host runner-dead-references ci
RASTRILLO := go run amadan.net/rastrillo/rastrillo/cmd/rastrillo
@@ -98,6 +98,16 @@ test-lane:
ci-shard:
RASTRILLO='$(RASTRILLO)' python3 scripts/ci-test.py shard
+# ci-compile builds every package and every test binary once, before the
+# shards of 20-check start. Go does not share a compile between processes
+# that start together: 23 shards on an empty cache each compiled the same
+# packages, and every one of them took as long as the whole job used to.
+# After this the shards find their packages in the cache. With a warm
+# cache it takes a few seconds.
+ci-compile:
+ go build ./...
+ python3 scripts/ci-test.py compile
+
test-quarantine:
python3 scripts/ci-test.py quarantine
diff --git a/internal/equipotest/foundation_test.go b/internal/equipotest/foundation_test.go
index de739fba..04975a1b 100644
--- a/internal/equipotest/foundation_test.go
+++ b/internal/equipotest/foundation_test.go
@@ -238,6 +238,9 @@ func TestCIGateSteps(t *testing.T) {
for _, path := range paths {
_, shards, _ := strings.Cut(filepath.Base(path), "@")
for _, target := range run(path) {
+ if target == "ci-compile" {
+ continue // fills the build cache for the shards; checks nothing itself
+ }
if target != "ci-shard" {
steps = append(steps, target)
continue
diff --git a/scripts/ci-test.py b/scripts/ci-test.py
index aa609ea7..b1b04aba 100755
--- a/scripts/ci-test.py
+++ b/scripts/ci-test.py
@@ -5,6 +5,7 @@
scripts/ci-test.py lane NAME one lane (make test-lane LANE=NAME)
scripts/ci-test.py shard the shard AMADAN_SHARD names (make ci-shard)
scripts/ci-test.py quarantine the quarantined tests (make test-quarantine)
+ scripts/ci-test.py compile build every test binary once (make ci-compile)
scripts/ci-test.py lanes print each lane and its packages
The slow packages each have a lane of their own and "rest" holds every
@@ -257,6 +258,14 @@ def run_all():
return budget_test(all_packages(), env)
+def run_compile():
+ """Build every test binary and keep none: what stays is the build
+ cache the shards then share."""
+ cmd = ["go", "test", "-tags", TAGS, "-c", "-o", os.devnull, "./..."]
+ print("+ " + " ".join(cmd), flush=True)
+ return subprocess.call(cmd)
+
+
def run_shard():
index = int(os.environ.get("AMADAN_SHARD", "-1"))
count = int(os.environ.get("AMADAN_SHARD_COUNT", "0"))
@@ -381,6 +390,8 @@ def main(argv):
return run_lane(argv[1])
if argv == ["shard"]:
return run_shard()
+ if argv == ["compile"]:
+ return run_compile()
if argv == ["quarantine"]:
return run_quarantine()
if argv == ["lanes"]: