Documentation
¶
Overview ¶
Command ci-shard prints the packages one shard of the macOS suite tests, one import path per line, heaviest first (iss-2610181757540736):
pkgs=$(go run ./cmd/ci-shard -shard 2 -of 3) go test -race -timeout 40m $pkgs
The suite keeps its runner's three test slots full, so its time is its total work on that runner, and hosted macOS runners vary about twofold: the same pass took 32 minutes on one and more than 77 on another. Only running it on several runners shortens what one runner has to do.
The module is read, never listed by hand: the assignment is computed from `go list` in every shard, under the build the shard tests with, so a package added later is tested without anyone naming it, and a package cannot fall between two hand-kept lists. Each package takes the lightest shard so far, heaviest package first, ties broken by import path, which makes it deterministic for one tree: every shard computes it on its own runner and they all reach the same answer. TestShardsPartitionTheModule holds the union to the module's packages and the shards to disjoint, and lint's TestMacOSSuiteShardsCoverTheModule holds what the workflow's own matrix asks for to the same.
The weights only balance the shards, so a stale one costs minutes, never coverage; a package the table does not name takes defaultWeight.
It is developer tooling, never part of a release. It prints the shard on standard output and one line on standard error saying what it chose. Anything that would leave a shard with nothing to test (a number out of range, more shards than packages, a go list that failed or named nothing) prints nothing on standard output and exits 2, so the step fails there rather than running go test with no packages, which tests the working directory and reports success.