oficina / equipo Public

CI: a commit with .amadan/cold starts from an empty build cache

A scratch branch can now measure a cold hosted run: prepare empties the
restored build cache when the commit carries .amadan/cold. Only on a
hosted CI machine, and never on main.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 6ba2126011a2a5222b1c66822ee5e849f80da6b5 parent 3d86170
1 file changed, +20 −0
  • scripts/ci-box.py +20 −0
diff --git a/scripts/ci-box.py b/scripts/ci-box.py
index ecd93397..c17e2ac4 100755
--- a/scripts/ci-box.py
+++ b/scripts/ci-box.py
@@ -45,6 +45,7 @@ from concurrent.futures import ThreadPoolExecutor
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PINS = os.path.join(ROOT, "scripts", "ci-box.json")
+COLD = os.path.join(ROOT, ".amadan", "cold")
# Where things sit inside the box. Fixed, whatever the job's own paths
# are: Go keys a compiled package on its source directory, so a checkout
@@ -421,6 +422,24 @@ def cache():
(CACHE_LIMIT / 1024 ** 3, dropped / 1024 ** 3, kept / 1024 ** 3))
+def cold_start():
+ """Empty the restored build cache when the commit carries .amadan/cold:
+ a scratch branch's way to measure a cold run, where every shard
+ compiles and no test result replays. Only on a hosted CI machine, whose
+ cache is a copy; never commit the file to main."""
+ if not os.path.exists(COLD):
+ return
+ gocache = go_env("GOCACHE")
+ size, files = tree_size(gocache)
+ for name in os.listdir(gocache) if os.path.isdir(gocache) else []:
+ path = os.path.join(gocache, name)
+ if os.path.isdir(path) and not os.path.islink(path):
+ shutil.rmtree(path, ignore_errors=True)
+ else:
+ os.unlink(path)
+ say("cold run (.amadan/cold): emptied the build cache, %.2f GiB in %d files" % (size / 1024 ** 3, files))
+
+
def facts():
def out(*command):
try:
@@ -454,6 +473,7 @@ def prepare():
if os.environ.get("AMADAN_CI") == "1":
deepen()
set_file_times()
+ cold_start()
with open(os.path.join(box_dir(), "prepared"), "w") as f:
f.write("%d\n" % time.time())
say("ready in %.1fs" % (time.time() - started))