oficina / equipo Public

ci-flakes: read each step's and shard's log, each flake once

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 9780571b1c4ddfc961781158749961e7941d88e4 parent 9a903eb
1 file changed, +14 −2
  • scripts/ci-flakes.py +14 −2
diff --git a/scripts/ci-flakes.py b/scripts/ci-flakes.py
index d2efad5e..e2a9761e 100755
--- a/scripts/ci-flakes.py
+++ b/scripts/ci-flakes.py
@@ -44,7 +44,9 @@ def root():
def flakes(log):
- return [dict(zip(("package", "test", "lane", "commit", "seconds", "load"), m.groups())) for m in FLAKE.finditer(log)]
+ """The flakes in a log, each once however often the log repeats it."""
+ found = dict.fromkeys(m.groups() for m in FLAKE.finditer(log))
+ return [dict(zip(("package", "test", "lane", "commit", "seconds", "load"), groups)) for groups in found]
def origin_branches():
@@ -76,10 +78,20 @@ def fetch(repo, branch):
"run": "%s %s %s" % (branch, status.get("sha", ""), status.get("updated_at", "")),
"branch": branch, "commit": status.get("sha", ""), "state": status["state"],
"at": int(status.get("updated_at") or time.time()),
- "flakes": flakes(status.get("log", "")),
+ "flakes": flakes("\n".join(logs(status))),
}, ""
+def logs(status):
+ """Every log in a run: the whole one, each step's, each shard's. They
+ repeat one another; a long log may be cut in one and whole in another."""
+ found = [status.get("log") or ""]
+ for step in status.get("steps") or []:
+ found.append(step.get("log") or "")
+ found += [shard.get("log") or "" for shard in step.get("shards") or []]
+ return found
+
+
def from_log(path):
with open(path, errors="replace") as f:
found = flakes(f.read())