Merge main into connections-s3-scheduler
Brings in staging-pi-root (release installs Pi for the owner runner).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+393
−58
.amadan/ci.d/{20-check@28 => 20-check@29}+6 −5Makefile+10 −2docs/superpowers/plans/HOSTED-CI-PROGRESS.md+89 −2internal/equipotest/foundation_test.go+1 −1internal/testci/lanes_test.go+98 −0scripts/ci-test.py+175 −48scripts/runner-reference-allowlist.json+7 −0scripts/staging-thin.py+7 −0
CI failed — run details
diff --git a/.amadan/ci.d/20-check@28 b/.amadan/ci.d/20-check@29| similarity index 70% |
| rename from .amadan/ci.d/20-check@28 |
| rename to .amadan/ci.d/20-check@29 |
| index 8bd34ec1..fa9d6d3f 100755 |
| --- a/.amadan/ci.d/20-check@28 |
| +++ b/.amadan/ci.d/20-check@29 |
| @@ -1,13 +1,14 @@ |
| #!/bin/sh |
| -# Everything but perf, as 28 shards side by side; AMADAN_SHARD picks one |
| -# (scripts/ci-test.py: LANES, BROWSER_LANES, then EXTRA_SHARDS). Seventeen |
| -# test lanes of about a minute each. Then five browser lanes: the |
| +# Everything but perf, as 29 shards side by side; AMADAN_SHARD picks one |
| +# (scripts/ci-test.py: LANES, BROWSER_LANES, then EXTRA_SHARDS). Eighteen |
| +# test lanes of 80 s at most on a cold run. Then five browser lanes: the |
| # -tags browser tests, each driving the pinned headless Chromium |
| # (scripts/ci-chromium.json). Then the quarantine: known flaky tests |
| # (scripts/ci-quarantine.txt), kept out of the lanes. Then runner-host: the exact bubblewrap build, |
| # the pinned programs, real namespaces and the cgroup move, uncached. Then |
| -# the static checks: build, vet, format, budgets, references and the |
| -# migration check; staticcheck; govulncheck; gitleaks. |
| +# the static checks: build, vet, format, budgets, references, the lanes |
| +# (every test in exactly one) and the migration check; staticcheck; |
| +# govulncheck; gitleaks. |
| # |
| # A failed test is retried once where it failed. A pass on the retry stays |
| # green and prints "FLAKE <package>:<test> <lane> <commit> <seconds>s |
diff --git a/Makefile b/Makefile| index f12af546..5f2e7679 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 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 |
| +.PHONY: build release test test-lane ci-shard ci-compile lanes-check 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 |
| @@ -130,6 +130,14 @@ ci-compile: |
| test-quarantine: |
| python3 scripts/ci-test.py quarantine |
| +# lanes-check fails when the lanes do not run every test exactly once: a |
| +# lane names a test or package that no longer exists, two lanes take the |
| +# same test, or a split package has no lane for the tests nobody names. |
| +# It also holds the shard count of .amadan/ci.d/20-check@N to the lanes. |
| +# It reads the test files every time, so it runs on CI uncached. |
| +lanes-check: |
| + python3 scripts/ci-test.py check |
| + |
| # The perf lane: every GET screen at 150ms to first byte, cold boot at |
| # 500ms. Serial (-p 1 -parallel 1) and uncached (-count=1), because a |
| # measurement taken beside other work, or replayed from a cache, is not |
| @@ -235,7 +243,7 @@ runner-host: runner-adapter-test runner-namespace-test |
| # fails the build the moment models.go and migrations/ disagree, |
| # instead of at boot on whatever machine notices next. If the app |
| # declares manifest resources, also add: rastrillo generate --check |
| -ci: copy-release-check runner-dead-references build vet fmt-check staticcheck govulncheck gitleaks budget test test-quarantine runner-host migration-check perf |
| +ci: copy-release-check runner-dead-references lanes-check build vet fmt-check staticcheck govulncheck gitleaks budget test test-quarantine runner-host migration-check perf |
| .PHONY: copy-release-check direct-release-check release-runner runner-prerequisites |
| copy-release-check: |
diff --git a/docs/superpowers/plans/HOSTED-CI-PROGRESS.md b/docs/superpowers/plans/HOSTED-CI-PROGRESS.md| index 27f19a2c..23f85a28 100644 |
| --- a/docs/superpowers/plans/HOSTED-CI-PROGRESS.md |
| +++ b/docs/superpowers/plans/HOSTED-CI-PROGRESS.md |
| @@ -101,7 +101,7 @@ between two delegated cgroups. So: |
| | `00-prepare` | fetch and verify the pinned programs and Chromium, pull the image, deepen the clone, set file times | |
| | `05-copy` | `make copy-release-check`: copy still marked COPY REVIEW REQUIRED fails here, not at the staging build | |
| | `10-compile` | compile every package and its tests once (the browser packages with `-tags browser` too), link no test; build rastrillo and the static check tools | |
| -| `20-check@28` | 17 test lanes, 5 browser lanes, the quarantine, `runner-host` (bubblewrap build, pinned codex, namespaces, cgroup move, uncached), and the static checks in four groups; a failed test is retried once | |
| +| `20-check@29` | 18 test lanes, 5 browser lanes, the quarantine, `runner-host` (bubblewrap build, pinned codex, namespaces, cgroup move, uncached), and the static checks in four groups (with `make lanes-check`); a failed test is retried once | |
| | `50-perf` | alone, it measures time | |
| | `90-cache` | report and trim the caches | |
| @@ -129,7 +129,11 @@ side, so everything that can run together is one step. |
| To rebalance: each shard's log ends with its time and its five slowest |
| tests; move names between lanes of a package, keep `20-check@N` equal to |
| -the lanes plus the extra shards (a test checks the count). |
| +the lanes plus the extra shards. `make lanes-check` (in the static checks |
| +shard) fails when a lane names a test or package that is gone, two lanes |
| +take the same test, a split package has no lane for the rest, or the |
| +count is wrong. "The rebalance of 2026-11-12" below says how to get every |
| +test's and subtest's time, which the five slowest do not give. |
| ## Before (docs-t1) |
| @@ -307,6 +311,89 @@ What each red was: |
| | TestClaudeFailureDiagnostics/partial | retried only. Failed in 0.11 s with `protocol_rejected`, last frame `malformed`: not a timeout, so likely a race in the test's fake or in the frame reader. First seen on `ci-cold-2`. | |
| +## The rebalance of 2026-11-12 (branch ci-rebalance) |
| + |
| +The check step had grown from about 63 s to 154 to 158 s on any run |
| +whose tests missed the cache: headless-rest took 154 s, with |
| +browser-headless-rest (118 to 131 s), thintest (106 to 109 s) and the |
| +quarantine (91 to 99 s) behind it. The browser lanes and the new |
| +Research, metered and preview tests had grown them. |
| + |
| +**Every test's time.** A shard's log names only its five slowest |
| +top-level tests, and headless-rest was mostly 25 subtests of |
| +TestHeadless. Scratch commit 43529308 (branch ci-rebalance-times, |
| +closed) carries `.amadan/cold` and an `.amadan/times` switch that makes |
| +each lane run `go test -json` in place of rastrillo and print the time |
| +of every test and subtest; its check step took 156 s, as main's did, so |
| +the switch costs nothing measurable. Cherry-pick it onto a scratch |
| +branch to measure again; never merge it. The quarantine now prints each |
| +test's time and each run's wall time itself. |
| + |
| +**What moved** (seconds are test time on that cold run): |
| + |
| +- headless (448 s over six lanes): 25 TestHeadless subtests and two |
| + token tests left headless-rest (153 s) for the other five lanes. Each |
| + is now 67 to 77 s. |
| +- thintest (105 s, no parallel tests): thintest-contract takes |
| + `^TestContract` (57 s), thintest the rest (48 s). The one new shard. |
| +- equipotest: its long tests call t.Parallel and wait together, about |
| + 15 s, so a lane is its serial tests plus that wait. The lanes take |
| + letters by serial time: A to D and Q (36 s), E to P (39 s), R (42 s), |
| + the rest (40 s). equipotest-d is now equipotest-e. |
| +- browser (409 s): browser-headless-connections takes the connections |
| + and paste-box drives (77 s); chat, work and rest are 79 s each. |
| + browser-thintest is gone: thintest's browser tests (91 s) joined |
| + plan3test's in browser-rest, whose shard had run 5 s. |
| +- quarantine: its nine TestHeadlessConnections subtests took 91 to 105 s |
| + in one go test. More than five entries of one test now run as even |
| + runs of at most five, side by side (`QUARANTINE_RUN`). |
| + |
| +**The guard.** `scripts/ci-test.py check` (`make lanes-check`, in the |
| +static checks shard) reads every package's test files and fails when a |
| +lane names a test, subtest or package that is gone, two lanes take the |
| +same test or subtest, a split package has no lane for the tests nobody |
| +names, a browser lane's pattern also takes a plain test, or |
| +`20-check@N` is not the lane count. TestLanesRunEveryTestOnce |
| +(internal/testci) holds its rules; each was broken once and seen red. |
| + |
| +**Measured**, each run on its own fresh machine, `.amadan/cold` except |
| +where it says warm. Check step, then its slowest shards: |
| + |
| +| run | layout | check | slowest shards | |
| +|---|---|---|---| |
| +| 2cc2894 main (tests missed the cache) | before | 154 s | headless-rest 154, browser-headless-rest 118, thintest 106 | |
| +| ccfa18e connections-s2-pi (same) | before | 158 s | headless-rest 158, browser-headless-rest 131, thintest 109 | |
| +| 52c8da1 ci-rebalance-cold-before | before | 154 s | headless-rest 154, browser-headless-rest 120, thintest 106 | |
| +| 4352930 ci-rebalance-times | before | 156 s | headless-rest 156, browser-headless-rest 121, thintest 107 | |
| +| c3cef28 ci-rebalance-cold-after-1 | first cut | 136 s | headless-guards 136 and headless-mac 123: two 45 s timeouts, each passed its retry | |
| +| 07ed24e ci-rebalance-cold-after-2 | first cut | 106 s | quarantine 106, browser-rest 100, headless-guards 93 | |
| +| c224aca ci-rebalance-cold-after-3 | final | 101 s | browser-rest 101, headless-guards 94, equipotest-r 93 | |
| +| b0f6606 ci-rebalance-cold-after-4 | final | 101 s | browser-rest 101, headless-guards 94, equipotest-r 92 | |
| +| 26055a6 ci-rebalance, warm | final | 76 s | browser-headless-chat 76, equipotest-r 70, equipotest-a 63 | |
| + |
| +Steps on a cold run: about 237 s before, 188 s after (prepare 14, |
| +copy 20, compile 22, check 101, perf 30). |
| + |
| +**The machine is busy at the start.** At the lane ends, before: load |
| +35 to 54, tasks waiting for a CPU 22 to 32 % of the last minute; after: |
| +load 42 to 62, 28 to 38 %. Memory and disk never waited. The work did |
| +not grow; it moved from the tail (headless-rest alone at load 15) into |
| +the first 90 s. So the step has one shard more and not several, and |
| +the next shard to add is a second thintest browser lane (browser-rest, |
| +101 s) only if the load allows it. In the first cut's run 1, two tests |
| +ran into a 45 s wait at load 28 to 35 and passed their retry |
| +(TestHeadless/1_first_token, a known one, and |
| +TestHeadless/3_empty_engineering); none did in the four runs after. |
| + |
| +**Warm runs** are unchanged at about 75 s (main 70e1e85: 72 s). An |
| +equipotest lane whose tests read a changed file reruns whole, 60 to 70 s |
| +with its wait: equipotest-r on both warm runs (TestReleaseStampContract |
| +first), main's D to P lane after main's change, and here equipotest-a, |
| +whose TestCIGateSteps reads scripts/ci-test.py. browser-headless-chat |
| +reran because its previous run flaked, and a flaked run leaves no cached |
| +pass. No lane split shortens these. |
| + |
| + |
| ## Open |
diff --git a/internal/equipotest/foundation_test.go b/internal/equipotest/foundation_test.go| index 4b09c5fd..73311d15 100644 |
| --- a/internal/equipotest/foundation_test.go |
| +++ b/internal/equipotest/foundation_test.go |
| @@ -175,7 +175,7 @@ func TestFoundationMigratesTwice(t *testing.T) { |
| // on a runner host, so the fake make sees what each step asks for. |
| func TestCIGateSteps(t *testing.T) { |
| root := filepath.Join("..", "..") |
| - want := []string{"copy-release-check", "build", "vet", "fmt-check", "staticcheck", "govulncheck", "gitleaks", "budget", "test", "test-quarantine", "runner-host", "runner-dead-references", "migration-check", "perf"} |
| + want := []string{"copy-release-check", "build", "vet", "fmt-check", "staticcheck", "govulncheck", "gitleaks", "budget", "test", "test-quarantine", "runner-host", "runner-dead-references", "lanes-check", "migration-check", "perf"} |
| sort.Strings(want) |
| // The step scripts run outside this process; their bytes are inputs. |
| testci.Files(t, filepath.Join(root, ".amadan"), filepath.Join(root, "scripts", "ci-test.py"), filepath.Join(root, "scripts", "ci-box.py")) |
diff --git a/internal/testci/lanes_test.go b/internal/testci/lanes_test.go| new file mode 100644 |
| index 00000000..874968f3 |
| --- /dev/null |
| +++ b/internal/testci/lanes_test.go |
| @@ -0,0 +1,98 @@ |
| +package testci_test |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/testci" |
| +) |
| + |
| +// The lanes split packages by test name, and every test must run in |
| +// exactly one of them: scripts/ci-test.py check (make lanes-check, in the |
| +// static checks shard) reads the real test files on CI. This holds its |
| +// rules on made-up packages: each broken layout names what is wrong, and |
| +// the good one passes. |
| +func TestLanesRunEveryTestOnce(t *testing.T) { |
| + testci.Files(t, "../../scripts/ci-test.py") |
| + inventory := map[string]any{ |
| + "packages": []string{"./a", "./b", "./c"}, |
| + "tests": map[string][]string{ |
| + "./a": {"TestAlpha", "TestBeta", "TestScenarios"}, |
| + "./b": {"TestOne", "TestTwo"}, |
| + "./c": {"TestC"}, |
| + }, |
| + "sources": map[string]string{"./a": `{"first", run}, {"second", run}`}, |
| + } |
| + good := [][]any{ |
| + {"a-scenarios", []string{"./a"}, []string{"TestScenarios/first"}}, |
| + {"a-more", []string{"./a"}, []string{"^TestA", "TestScenarios/second"}}, |
| + {"a-rest", []string{"./a"}, nil}, |
| + {"b", []string{"./b"}, nil}, |
| + {"rest", nil, nil}, |
| + } |
| + with := func(name string, lane []any) [][]any { |
| + var out [][]any |
| + for _, l := range good { |
| + if l[0] != name { |
| + out = append(out, l) |
| + } |
| + } |
| + if lane != nil { |
| + out = append(out, lane) |
| + } |
| + return out |
| + } |
| + for _, c := range []struct { |
| + name string |
| + lanes [][]any |
| + want string // "" is no problem |
| + }{ |
| + {"good", good, ""}, |
| + {"the same subtest in two lanes", with("a-more", []any{"a-more", []string{"./a"}, []string{"^TestA", "TestScenarios/first"}}), |
| + "./a TestScenarios/first runs in more than one lane: a-more, a-scenarios"}, |
| + {"a whole test beside its subtest", with("a-more", []any{"a-more", []string{"./a"}, []string{"TestScenarios"}}), |
| + "./a TestScenarios runs in more than one lane: a-more whole; a-scenarios some of it"}, |
| + {"two patterns take one test", with("a-more", []any{"a-more", []string{"./a"}, []string{"^Test[A-Z]"}}), |
| + "./a TestScenarios runs in more than one lane"}, |
| + {"a renamed test", with("a-more", []any{"a-more", []string{"./a"}, []string{"TestGamma"}}), |
| + "lane a-more: TestGamma names no test in ./a"}, |
| + {"a renamed subtest", with("a-scenarios", []any{"a-scenarios", []string{"./a"}, []string{"TestScenarios/third"}}), |
| + "lane a-scenarios: ./a has no subtest 'third' of TestScenarios"}, |
| + {"a pattern that takes nothing", with("a-more", []any{"a-more", []string{"./a"}, []string{"^TestZ"}}), |
| + "lane a-more: ^TestZ names no test in ./a"}, |
| + {"a split package with nowhere for the rest", with("a-rest", nil), |
| + "./a: want one lane that names no tests and runs what the others do not; have []"}, |
| + {"a package in two whole lanes", with("", []any{"b-again", []string{"./b"}, nil}), |
| + "./b: want one lane that names no tests and runs what the others do not; have ['b', 'b-again']"}, |
| + {"a deleted package", with("", []any{"gone", []string{"./gone"}, nil}), |
| + "lane gone: no package ./gone (renamed or deleted?)"}, |
| + {"tests across packages", with("b", []any{"b", []string{"./b", "./c"}, []string{"TestOne"}}), |
| + "lane b names tests, so it must name one package"}, |
| + {"no lane for the other packages", with("rest", nil), |
| + "want one lane that names no package"}, |
| + } { |
| + out := python(t, nil, "-c", loadCITest+` |
| +args = json.loads(sys.argv[1]) |
| +lanes = [tuple(l) for l in json.loads(sys.argv[2])] |
| +print(json.dumps(m.lane_problems(lanes, set(args["packages"]), args["tests"], args["sources"]))) |
| +`, mustJSON(t, inventory), mustJSON(t, c.lanes)) |
| + var problems []string |
| + if err := json.Unmarshal([]byte(out), &problems); err != nil { |
| + t.Fatalf("%s: %v: %s", c.name, err, out) |
| + } |
| + if c.want == "" { |
| + if len(problems) != 0 { |
| + t.Errorf("%s: want no problems, got %q", c.name, problems) |
| + } |
| + continue |
| + } |
| + found := false |
| + for _, p := range problems { |
| + found = found || strings.Contains(p, c.want) |
| + } |
| + if !found { |
| + t.Errorf("%s: want a problem containing %q, got %q", c.name, c.want, problems) |
| + } |
| + } |
| +} |
diff --git a/scripts/ci-test.py b/scripts/ci-test.py| index 666ad961..0e070ce6 100755 |
| --- a/scripts/ci-test.py |
| +++ b/scripts/ci-test.py |
| @@ -9,6 +9,7 @@ |
| scripts/ci-test.py retried LANE ARGS... go test ARGS, with the one retry |
| scripts/ci-test.py lanes print each lane and its packages |
| scripts/ci-test.py browser print each package's browser tests |
| + scripts/ci-test.py check every test in exactly one lane (make lanes-check) |
| The slow packages each have a lane of their own and "rest" holds every |
| other package. The browser tests (files built only with -tags browser) |
| @@ -64,26 +65,34 @@ TIMEOUT = "15m" |
| # and anything starting with ^ is a regular expression over test names. |
| # A lane of the same package without tests runs everything the others do |
| # not name, so a new test always lands somewhere. Split a package when its |
| -# lane is the slowest shard, by the times its shard prints; the measured |
| -# seconds beside each lane are test time on a 32 CPU hosted machine. |
| -HEADLESS, RUNNER, EQUIPOTEST = "./internal/headless", "./internal/runner", "./internal/equipotest" |
| +# lane is the slowest shard, by the times its shard prints. The seconds |
| +# beside each lane are its tests' time on a cold run on a 32 CPU hosted |
| +# machine (2026-11-12, every shard started on an empty cache); a shard |
| +# takes about 3 s more, and a LATE one its wait too. `scripts/ci-test.py |
| +# check` (make lanes-check, in the static checks) fails when a lane names |
| +# a test or package that does not exist, two lanes take the same test, or |
| +# a package lacks the lane that runs what the others do not name. |
| +HEADLESS, RUNNER, EQUIPOTEST, THINTEST = "./internal/headless", "./internal/runner", "./internal/equipotest", "./internal/thintest" |
| LANES = [ |
| - ("headless-work", [HEADLESS], ["TestHeadless/4c_rebase", "TestHeadless/4b_ask", "TestHeadless/4c_checks_card", "TestHeadless/4_step_crash"]), # 54 |
| - ("headless-review", [HEADLESS], ["TestHeadless/4_review", "TestHeadless/2b_access", "TestHeadless/runner_crash", "TestHeadless/2b_first_message", "TestHeadless/4_checks_honest", "TestHeadless/7_stream_resume", "TestHeadless/2b_notebook", "TestHeadless/2b_move_in"]), # 50 |
| - ("headless-connections", [HEADLESS], ["TestHeadlessConnections"]), # 52 without the quarantined |
| - ("headless-mac", [HEADLESS], ["TestMacWorker", "TestHeadlessAttachments", "TestHeadlessPrewarm"]), # 43 |
| - ("headless-guards", [HEADLESS], ["TestHeadlessCopyRotation", "TestHeadlessPolicyGuards", "TestHeadlessRunnerKillLeavesNoCopies", "TestHeadlessNewHouseRuleStartsFresh"]), # 41 |
| - ("headless-rest", [HEADLESS], None), # 52 of TestHeadless and the small ones |
| - ("thintest", ["./internal/thintest"], None), # 47 |
| - ("runner-thin", ["./internal/runner/thin"], None), # 38 |
| - ("runner-bug", [RUNNER], ["TestDirectBugWorkflow", "TestEnrolKeepsTheRole"]), # 65 |
| - ("runner-plans", [RUNNER], ["TestPlanWorkflowCandidateOrder", "TestPlanWorkflowFeature", "TestCoordinatorRecoveryCallRefusalKeepsServing", "TestCoordinatorRefusalMatrix"]), # 54 |
| - ("runner-rest", [RUNNER], None), # 36 |
| - ("equipotest-a", [EQUIPOTEST], ["^Test[A-C]"]), # the whole package: 183 |
| - ("equipotest-d", [EQUIPOTEST], ["^Test[D-P]"]), |
| - ("equipotest-r", [EQUIPOTEST], ["^TestR"]), |
| - ("equipotest-rest", [EQUIPOTEST], None), |
| - ("plan3test", ["./internal/plan3test"], None), # 35 |
| + ("headless-work", [HEADLESS], ["TestHeadless/4c_rebase", "TestHeadless/4b_ask", "TestHeadless/4c_checks_card", "TestHeadless/4_step_crash"]), # 75 |
| + ("headless-review", [HEADLESS], ["TestHeadless/4_review", "TestHeadless/2b_access", "TestHeadless/runner_crash", "TestHeadless/2b_first_message", "TestHeadless/4_checks_honest", "TestHeadless/7_stream_resume", "TestHeadless/2b_notebook", "TestHeadless/2b_move_in", "TestHeadless/2b_desk_failure", "TestHeadless/cancel"]), # 76 |
| + ("headless-connections", [HEADLESS], ["TestHeadlessConnections", "TestHeadlessTokenPasteEndToEnd", "TestHeadlessTokenConnection"]), # 76 without the quarantined |
| + ("headless-mac", [HEADLESS], ["TestMacWorker", "TestHeadlessAttachments", "TestHeadlessPrewarm", "TestHeadless/1_first_token", "TestHeadless/6_quick_messages", "TestHeadless/8_instance_restart", "TestHeadless/3_runner_offline"]), # 77 |
| + ("headless-guards", [HEADLESS], ["TestHeadlessCopyRotation", "TestHeadlessPolicyGuards", "TestHeadlessRunnerKillLeavesNoCopies", "TestHeadlessNewHouseRuleStartsFresh", "TestHeadless/3_engineering", "TestHeadless/3_step_cancel", "TestHeadless/3_step_contained", "TestHeadless/3_empty_repo", "TestHeadless/3_empty_engineering", "TestHeadless/3_empty_merge", "TestHeadless/3_empty_merge_rebuilt", "TestHeadless/3_empty_fix_round"]), # 76 |
| + ("headless-rest", [HEADLESS], None), # 67: the rest of TestHeadless, Research, batching and the small ones |
| + ("thintest-contract", [THINTEST], ["^TestContract"]), # 57 |
| + ("thintest", [THINTEST], None), # 48 |
| + ("runner-thin", ["./internal/runner/thin"], None), # 54 |
| + ("runner-bug", [RUNNER], ["TestDirectBugWorkflow", "TestEnrolKeepsTheRole"]), # 47 |
| + ("runner-plans", [RUNNER], ["TestPlanWorkflowCandidateOrder", "TestPlanWorkflowFeature", "TestCoordinatorRecoveryCallRefusalKeepsServing", "TestCoordinatorRefusalMatrix"]), # 51 |
| + ("runner-rest", [RUNNER], None), # 34 |
| + # equipotest's long tests call t.Parallel and wait together at the |
| + # end, about 15 s; a lane is its serial tests plus that wait. |
| + ("equipotest-a", [EQUIPOTEST], ["^Test[A-D]", "^TestQ"]), # 36 serial |
| + ("equipotest-e", [EQUIPOTEST], ["^Test[E-P]"]), # 39 serial |
| + ("equipotest-r", [EQUIPOTEST], ["^TestR"]), # 42 serial |
| + ("equipotest-rest", [EQUIPOTEST], None), # 40 serial |
| + ("plan3test", ["./internal/plan3test"], None), # 41 |
| ("rest", None, None), # every package no other lane names |
| ] |
| @@ -98,11 +107,11 @@ LANES = [ |
| # The browser tests wait on the page with short deadlines, so none of |
| # these is LATE. |
| BROWSER_LANES = [ |
| - ("browser-headless-chat", [HEADLESS], ["TestBrowserChat", "TestBrowserChatSendStaysOnPage", "TestBrowserMoveIn", "TestBrowserComposer", "TestBrowserComposerReconcile", "TestBrowserComposerFocus", "TestBrowserComposerDock", "TestBrowserDraftStreamsFormatted", "TestBrowserDraftIsTheMessage", "TestBrowserRefreshRace"]), # 88 |
| - ("browser-headless-work", [HEADLESS], ["TestBrowserTaskCard", "TestBrowserReceiptFollowsReview", "TestBrowserRailFollowsWork", "TestBrowserTaskThread", "TestBrowserAskAfterMerge", "TestBrowserReceiptsDesktop", "TestBrowserReceiptsTouch", "TestBrowserNotebook", "TestBrowserEmptyExplore", "TestNotebookScreenshots", "TestBrowserNotebookLook"]), # 75 |
| - ("browser-headless-rest", [HEADLESS], None), # 74: the connections pages, thinking and cards, any new one |
| - ("browser-thintest", ["./internal/thintest"], None), # 80 |
| - ("browser-rest", None, None), # plan3test and any new package |
| + ("browser-headless-chat", [HEADLESS], ["TestBrowserChat", "TestBrowserChatSendStaysOnPage", "TestBrowserComposer", "TestBrowserComposerReconcile", "TestBrowserComposerFocus", "TestBrowserComposerDock", "TestBrowserDraftStreamsFormatted", "TestBrowserDraftIsTheMessage"]), # 79 |
| + ("browser-headless-work", [HEADLESS], ["TestBrowserTaskCard", "TestBrowserReceiptFollowsReview", "TestBrowserRailFollowsWork", "TestBrowserTaskThread", "TestBrowserAskAfterMerge", "TestBrowserReceiptsDesktop", "TestBrowserReceiptsTouch"]), # 79 |
| + ("browser-headless-connections", [HEADLESS], ["^TestBrowserConnections", "TestBrowserPasteBox", "TestBrowserPasteCopiesItsBox"]), # 77 |
| + ("browser-headless-rest", [HEADLESS], None), # 79: thinking and cards, moving in, the notebook, any new one |
| + ("browser-rest", None, None), # 92: thintest's (91), plan3test's and any new package's |
| ] |
| # Shards after the lanes: work that is not a lane of packages but runs |
| @@ -112,7 +121,7 @@ BROWSER_LANES = [ |
| EXTRA_SHARDS = [ |
| ["test-quarantine"], |
| ["runner-host"], |
| - ["runner-dead-references", "build", "vet", "fmt-check", "budget", "migration-check"], |
| + ["runner-dead-references", "lanes-check", "build", "vet", "fmt-check", "budget", "migration-check"], |
| ["staticcheck"], |
| ["govulncheck"], |
| ["gitleaks"], |
| @@ -133,6 +142,11 @@ TEST_TOOLS = ["bwrap", "claude", "codex", "git", "python3", "sh", "srt", "tar"] |
| TEST_TOOL_DIRS = {"try-bin": "~/.local/share/equipo/try/bin", "pi": os.environ.get("EQUIPO_PI_ROOT") or "/opt/equipo-pi"} |
| QUARANTINE = "scripts/ci-quarantine.txt" |
| +# The quarantine runs each quarantined test's entries in one go test, the |
| +# go tests side by side; more subtests of one test than this are split |
| +# into even runs of at most this many (nine TestHeadlessConnections |
| +# subtests took 91 to 105 s in one). |
| +QUARANTINE_RUN = 5 |
| TEST_FUNC = re.compile(r"^func (Test[A-Za-z0-9_]*)\(\w+ \*testing\.T\)", re.M) |
| @@ -163,7 +177,7 @@ BUILD_JOBS_MANY = 16 # for the lane of many small packages, where -p is also ho |
| CHECK_CPUS = 8 |
| SETTLE, BUSY = 10, 10.0 |
| LATE = { |
| - "equipotest-a": 30, "equipotest-d": 30, "equipotest-r": 30, "equipotest-rest": 30, |
| + "equipotest-a": 30, "equipotest-e": 30, "equipotest-r": 30, "equipotest-rest": 30, |
| "plan3test": 30, "rest": 30, |
| "runner-dead-references": 30, "staticcheck": 30, "govulncheck": 30, "gitleaks": 30, |
| } |
| @@ -218,6 +232,32 @@ def lane_flags(name): |
| return [] |
| +_files = {} |
| + |
| + |
| +def test_files(tags): |
| + """{package: (directory, test file names)} as go list sees them with tags.""" |
| + if tags not in _files: |
| + fmt = "{{.ImportPath}}|{{.Dir}}|{{join .TestGoFiles \" \"}} {{join .XTestGoFiles \" \"}}" |
| + out = subprocess.check_output(["go", "list", "-tags", tags, "-f", fmt, "./..."], text=True) |
| + found = {} |
| + for line in out.splitlines(): |
| + path, directory, names = line.split("|", 2) |
| + found["." + path[len(MODULE):]] = (directory, set(names.split())) |
| + _files[tags] = found |
| + return _files[tags] |
| + |
| + |
| +def read_tests(directory, names): |
| + """The top-level tests in the named files, and the files' text.""" |
| + tests, text = set(), [] |
| + for name in sorted(names): |
| + with open(os.path.join(directory, name)) as f: |
| + text.append(f.read()) |
| + tests.update(TEST_FUNC.findall(text[-1])) |
| + return tests, "\n".join(text) |
| + |
| + |
| _browser = None |
| @@ -227,24 +267,12 @@ def browser_tests(): |
| global _browser |
| if _browser is not None: |
| return _browser |
| - fmt = "{{.ImportPath}}|{{.Dir}}|{{join .TestGoFiles \" \"}} {{join .XTestGoFiles \" \"}}" |
| - |
| - def files(tags): |
| - out = subprocess.check_output(["go", "list", "-tags", tags, "-f", fmt, "./..."], text=True) |
| - found = {} |
| - for line in out.splitlines(): |
| - path, directory, names = line.split("|", 2) |
| - found["." + path[len(MODULE):]] = (directory, set(names.split())) |
| - return found |
| - plain, browser = files(TAGS), files(BROWSER_TAGS) |
| + plain, browser = test_files(TAGS), test_files(BROWSER_TAGS) |
| _browser = {} |
| for package, (directory, names) in sorted(browser.items()): |
| - tests = [] |
| - for name in sorted(names - plain.get(package, ("", set()))[1]): |
| - with open(os.path.join(directory, name)) as f: |
| - tests += TEST_FUNC.findall(f.read()) |
| + tests, _ = read_tests(directory, names - plain.get(package, ("", set()))[1]) |
| if tests: |
| - _browser[package] = sorted(set(tests)) |
| + _browser[package] = sorted(tests) |
| return _browser |
| @@ -277,6 +305,96 @@ def browser_runs(name): |
| sys.exit(f"ci-test: unknown browser lane {name!r}") |
| +def lane_problems(lanes, packages, tests, sources, kind="lane"): |
| + """What is wrong with one list of lanes, as messages; none when every |
| + test of every package runs in exactly one lane. packages is every |
| + package these lanes may run, tests {package: top-level tests} and |
| + sources {package: its test files' text}, for the subtest names.""" |
| + problems = [] |
| + rest = [name for name, ps, _ in lanes if ps is None] |
| + if len(rest) != 1: |
| + problems.append(f"want one {kind} that names no package, for every package the others do not name; have {rest}") |
| + named = {} |
| + for name, ps, ts in lanes: |
| + if ps is None: |
| + if ts: |
| + problems.append(f"{kind} {name} names tests but no package") |
| + continue |
| + if ts and len(ps) != 1: |
| + problems.append(f"{kind} {name} names tests, so it must name one package, not {ps}") |
| + for p in ps: |
| + if p not in packages: |
| + problems.append(f"{kind} {name}: no package {p} (renamed or deleted?)") |
| + named.setdefault(p, []).append((name, ts)) |
| + claims = {} # (package, test) -> [(lane, subtest or None)] |
| + for p, entries in sorted(named.items()): |
| + whole = [name for name, ts in entries if not ts] |
| + if len(whole) != 1: |
| + problems.append(f"{p}: want one {kind} that names no tests and runs what the others do not; have {whole}") |
| + for name, ts in entries: |
| + for t in ts or []: |
| + if t.startswith("^"): |
| + try: |
| + found = [x for x in tests.get(p, []) if re.search(t, x)] |
| + except re.error as e: |
| + problems.append(f"{kind} {name}: {t}: {e}") |
| + continue |
| + sub = None |
| + else: |
| + top, _, sub = t.partition("/") |
| + found = [top] if top in tests.get(p, []) else [] |
| + if found and sub and f'"{sub}"' not in sources.get(p, ""): |
| + problems.append(f"{kind} {name}: {p} has no subtest {sub!r} of {top}") |
| + if not found: |
| + problems.append(f"{kind} {name}: {t} names no test in {p}") |
| + for x in found: |
| + claims.setdefault((p, x), []).append((name, sub or None)) |
| + for (p, x), by in sorted(claims.items()): |
| + whole, lanes_of = {name for name, sub in by if sub is None}, {name for name, _ in by} |
| + if whole and len(lanes_of) > 1: |
| + parts = [", ".join(sorted(whole)) + " whole"] + ([", ".join(sorted(lanes_of - whole)) + " some of it"] if lanes_of - whole else []) |
| + problems.append(f"{p} {x} runs in more than one {kind}: {'; '.join(parts)}") |
| + for sub in sorted({sub for _, sub in by if sub}): |
| + lanes_of = sorted({name for name, s in by if s == sub}) |
| + if len(lanes_of) > 1: |
| + problems.append(f"{p} {x}/{sub} runs in more than one {kind}: {', '.join(lanes_of)}") |
| + return problems |
| + |
| + |
| +def check_lanes(): |
| + """make lanes-check: every test of every package runs in exactly one |
| + lane, and 20-check@N has a shard for each lane and extra shard.""" |
| + plain, tagged = test_files(TAGS), test_files(BROWSER_TAGS) |
| + tests, sources = {}, {} |
| + for p, (directory, names) in tagged.items(): |
| + _, text = read_tests(directory, names) |
| + sources[p] = text |
| + tests[p], _ = read_tests(directory, plain.get(p, ("", set()))[1]) |
| + browser = browser_tests() |
| + problems = lane_problems(LANES, set(plain), tests, sources) |
| + problems += lane_problems(BROWSER_LANES, set(browser), browser, sources, "browser lane") |
| + # A browser lane's -run would also take a plain test of the name; that |
| + # test already runs in its own lane. |
| + for name, ps, ts in BROWSER_LANES: |
| + for t in ts or []: |
| + top = t if t.startswith("^") else "^" + re.escape(t.partition("/")[0]) + "$" |
| + for x in tests.get(ps[0] if ps else "", []): |
| + if re.search(top, x): |
| + problems.append(f"browser lane {name}: {t} also takes {x}, which is not a browser test") |
| + names = all_lanes() |
| + problems += [f"two lanes are called {n}" for n in sorted({n for n in names if names.count(n) > 1})] |
| + steps = [n for n in os.listdir(os.path.join(root(), ".amadan", "ci.d")) if n.startswith("20-check@")] |
| + want = f"20-check@{len(names) + len(EXTRA_SHARDS)}" |
| + if steps != [want]: |
| + problems.append(f".amadan/ci.d has {steps}; {len(names)} lanes and {len(EXTRA_SHARDS)} extra shards need {want}") |
| + for p in problems: |
| + print("lanes: " + p) |
| + if problems: |
| + return 1 |
| + print(f"lanes: {len(LANES)} lanes and {len(BROWSER_LANES)} browser lanes run every test once; {want}") |
| + return 0 |
| + |
| + |
| def all_lanes(): |
| return [lane for lane, _, _ in LANES + BROWSER_LANES] |
| @@ -620,9 +738,10 @@ def commit(): |
| return head if re.fullmatch(r"[0-9a-f]{40}", head) else "unknown" |
| -def failed_seconds(out, test): |
| - """How long test's failed attempt took, from go test's own FAIL line.""" |
| - m = re.search(r"^\s*--- FAIL: " + re.escape(test) + r" \((\d+(?:\.\d+)?)s\)", out, re.M) |
| +def failed_seconds(out, test, result="FAIL"): |
| + """How long test's failed attempt took, from go test's own FAIL line |
| + (or, with result PASS, how long its pass took).""" |
| + m = re.search(r"^\s*--- " + result + r": " + re.escape(test) + r" \((\d+(?:\.\d+)?)s\)", out, re.M) |
| return m.group(1) + "s" if m else "unknown" |
| @@ -697,8 +816,9 @@ def run_group(package, tests, env, tags=TAGS): |
| """Run one top-level test's quarantined entries; retry failures once.""" |
| report = [] |
| base = ["-tags", tags, "-timeout", TIMEOUT] |
| + started = time.time() |
| cmd, out, passed, failed, _ = go_test(package, tests, env, base, fresh=False) |
| - report.append(f"+ {cmd}") |
| + report.append(f"+ {cmd} ({time.time() - started:.0f}s)") |
| missing = set(tests) - passed - failed |
| flaky, broken = [], sorted(missing) |
| for t in sorted(missing): |
| @@ -719,7 +839,7 @@ def run_group(package, tests, env, tags=TAGS): |
| if any(t in broken for t in failed): |
| report.append(tail(retry_out)) |
| for t in sorted(passed - failed): |
| - report.append(f"ok {package} {t}") |
| + report.append(f"ok {package} {t} {failed_seconds(out, t, 'PASS')}") |
| return report, flaky, broken |
| @@ -737,8 +857,13 @@ def run_quarantine(): |
| def tags(package, top): |
| return BROWSER_TAGS if top in browser.get(package, []) else TAGS |
| - with ThreadPoolExecutor(max_workers=max(1, len(groups))) as pool: |
| - futures = [pool.submit(run_group, p, tests, env, tags(p, top)) for (p, top), tests in sorted(groups.items())] |
| + runs = [] |
| + for (p, top), tests in sorted(groups.items()): |
| + tests = sorted(tests) |
| + size = -(-len(tests) // -(-len(tests) // QUARANTINE_RUN)) |
| + runs += [(p, top, tests[i:i + size]) for i in range(0, len(tests), size)] |
| + with ThreadPoolExecutor(max_workers=max(1, len(runs))) as pool: |
| + futures = [pool.submit(run_group, p, tests, env, tags(p, top)) for p, top, tests in runs] |
| results = [f.result() for f in futures] |
| flakes, broken = [], [] |
| for report, flaky, bad in results: |
| @@ -772,6 +897,8 @@ def main(argv): |
| for package, flags in browser_runs(name): |
| print(name + ": -tags " + BROWSER_TAGS + " " + " ".join([package] + [shlex.quote(f) for f in flags])) |
| return 0 |
| + if argv == ["check"]: |
| + return check_lanes() |
| if argv == ["browser"]: |
| for package, tests in browser_tests().items(): |
| print(package + ": " + " ".join(tests)) |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 61382f4b..bb501b1e 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -14894,5 +14894,12 @@ |
| "match": "node", |
| "count": 1, |
| "reason": "The CI box installs the pinned Pi for the real-Pi tests: Node by its digests and the npm tree from the committed lockfile (connectors spec S2)." |
| + }, |
| + { |
| + "path": "scripts/staging-thin.py", |
| + "line_sha256": "6c7ba0a3a6322df7a87dbe3cbab3a1fa036bd903f69e5aa97f2981185d46f9ae", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Staging installs the release runner's pinned Pi for the owner's runner (install-pi); a release artifact path, not a dead reference." |
| } |
| ] |
diff --git a/scripts/staging-thin.py b/scripts/staging-thin.py| index f7c8585e..ee7db7c1 100755 |
| --- a/scripts/staging-thin.py |
| +++ b/scripts/staging-thin.py |
| @@ -326,6 +326,13 @@ def install(sha, release, root, unit_name, person, cookie_path, create): |
| # The owner's runner pairs with this machine's CARLOS devbox for |
| # previews (links on the tailnet); the suite's never publishes. |
| env.update(EQUIPO_PREVIEW_HOST='devbox', EQUIPO_CARLOS_PATH=carlos) |
| + if root == ROOT: |
| + # The owner's runner has the pinned Pi (metered connections). The |
| + # release's install-pi is idempotent: it returns at once when the |
| + # tree under pi/ already matches its pins, and otherwise installs |
| + # it and checks the digests, so a restage never leaves Pi missing. |
| + run([str(release / 'equipo-runner'), 'install-pi', str(root / 'pi')]) |
| + env.update(EQUIPO_PI_ROOT=str(root / 'pi')) |
| private(root / 'service.env', ''.join(f'{k}={json.dumps(v)}\n' for k, v in sorted(env.items()))) |
| # Before enrolment or the unit starts anything: the runner holds every |
| # program in this configuration (bubblewrap, claude, codex and its code |