Merge origin/main into refactor/horizon-command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-26 22:06:35 +01:00
106 changed files with 4682 additions and 583 deletions
+81 -3
View File
@@ -290,9 +290,6 @@ class OracleReuseTests(unittest.TestCase):
self.assertEqual(self.output.read_text(), "b")
if __name__ == "__main__":
unittest.main()
class LargeOutputTests(unittest.TestCase):
def test_a_pass_clears_only_its_own_directory(self):
@@ -323,3 +320,84 @@ class LargeOutputTests(unittest.TestCase):
listing.write_text(f"{own / 'server.txt'}\n{own / 'client.txt'}\n")
parity.clear_large_outputs("state_provider#2", trace)
self.assertEqual(sorted(path.name for path in own.iterdir()), ["report.json", "server.txt"])
class FakeExecutor:
"""Runs nothing: each start of a harness takes the next status from its script, a list."""
name, dead, max_peak = "fake", False, None
def __init__(self):
self.started, self.finished = [], []
def free(self):
return 1
def accepts(self, name):
return True
def fits(self, expected, only_here=True):
return True
def start(self, label, script, reuse, expected, shard=None):
self.started.append((label, reuse))
self.finished.append((label, {"status": script.pop(0), "seconds": 1.0, "dependencies": []}))
return True
def poll(self):
finished, self.finished = self.finished, []
return finished
class KnownFlakyTests(unittest.TestCase):
def run_harnesses(self, scripts, flaky, rounds=None):
executor = FakeExecutor()
state = {"harnesses": {name: {"status": "pass", "oracle_reuse": True} for name in scripts}}
with tempfile.TemporaryDirectory() as tmp, mock.patch.multiple(parity, STATE_DIR=Path(tmp), SHARED=Path(tmp)), \
mock.patch.object(parity, "save_state"), mock.patch.object(parity, "time") as clock:
clock.monotonic.return_value = 0.0
results, _ = parity.run(scripts, state, None, "env", [executor], True, rounds, flaky)
return results, executor.started
def test_a_known_flaky_failure_runs_once_more_from_scratch_and_says_so(self):
results, started = self.run_harnesses({"dedicated_server": ["fail", "pass"]}, {"dedicated_server": "timer"})
self.assertEqual(results["dedicated_server"]["status"], "pass")
self.assertEqual(results["dedicated_server"]["retried"], "known flaky")
# The first run reused oracle results; a known flaky harness doesn't lose that by flaking.
self.assertTrue(results["dedicated_server"]["oracle_reuse"])
self.assertEqual(started, [("dedicated_server", True), ("dedicated_server", False)])
def test_only_once(self):
results, started = self.run_harnesses({"dedicated_server": ["fail", "fail"]}, {"dedicated_server": "timer"})
self.assertEqual(results["dedicated_server"]["status"], "fail")
self.assertEqual(len(started), 2)
def test_other_harnesses_keep_only_the_reused_oracle_retry(self):
results, started = self.run_harnesses({"food": ["fail", "pass"]}, {"dedicated_server": "timer"})
self.assertEqual((results["food"]["status"], results["food"]["retried"]), ("pass", "reused oracle results"))
self.assertEqual(started, [("food", True), ("food", False)])
self.assertFalse(results["food"]["oracle_reuse"])
def test_repeated_runs_get_no_retry(self):
results, started = self.run_harnesses({"dedicated_server": ["pass", "fail"]}, {"dedicated_server": "timer"},
rounds={"dedicated_server": 2})
self.assertEqual((results["dedicated_server"]["status"], len(started)), ("fail", 2))
def test_retries_reach_the_job_summary(self):
with tempfile.TemporaryDirectory() as tmp:
summary = Path(tmp) / "summary.md"
with mock.patch.dict(os.environ, {"GITHUB_STEP_SUMMARY": str(summary)}), \
mock.patch("builtins.print"):
parity.report_retries({"dedicated_server": {"status": "pass", "retried": "known flaky"},
"food": {"status": "pass"}}, {"dedicated_server": "timer"})
text = summary.read_text()
self.assertIn("RETRIED dedicated_server: failed, then passed on its one retry (known flaky: timer", text)
self.assertNotIn("food", text)
def test_the_known_flaky_list_has_a_reason_per_harness(self):
flaky = parity.known_flaky(parity.host_config())
self.assertTrue(all(isinstance(reason, str) and len(reason) > 20 for reason in flaky.values()))
self.assertTrue(set(flaky) <= {parity.base_name(name) for name in parity.harnesses()})
if __name__ == "__main__":
unittest.main()
+29 -12
View File
@@ -9,7 +9,8 @@ PACKAGES = {"horizon-core": "crates/horizon-core", "horizon-client": "crates/hor
"horizon-theme": "crates/horizon-theme", "xtask": "xtask"}
LIBRARIES = set(PACKAGES) - {"xtask"}
DEPENDENCIES = {"horizon-client": {"horizon-core"}}
MODS = " --features horizon-mods/runtime,horizon-mods/pack,horizon-client/mods"
MODS = " --features horizon-client/mods,horizon-mods/pack"
CLIPPY = pr_ready.CI_CLIPPY + " && " + pr_ready.CI_CLIPPY_SERVER
def args(host="local", quick=False):
@@ -35,6 +36,9 @@ class PrReadyTests(unittest.TestCase):
self.assertFalse(pr_ready.workspace_rust("crates/horizon-client/README.md"))
self.assertFalse(pr_ready.workspace_rust("launcher/src/main.rs"))
self.assertTrue(pr_ready.launcher_rust("launcher/src/main.rs"))
# CI's launcher job also runs for the root workspace's manifests and for its own check.
self.assertTrue(pr_ready.launcher_rust("Cargo.lock"))
self.assertTrue(pr_ready.launcher_rust("tools/ci/rust_changes.py"))
self.assertTrue(pr_ready.launcher_rust("crates/horizon-prepare/src/lib.rs"))
self.assertTrue(pr_ready.launcher_rust("crates/horizon-theme/src/lib.rs"))
self.assertTrue(pr_ready.launcher_rust("crates/horizon-telemetry/src/lib.rs"))
@@ -46,10 +50,9 @@ class PrReadyTests(unittest.TestCase):
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
steps = pr_ready.plan(args(quick=True), "origin/main", {"crates/horizon-client/src/game.rs"}, PACKAGES, LIBRARIES, DEPENDENCIES)
by_name = {step.name: step for step in steps}
self.assertEqual(by_name["clippy"].command,
"cargo clippy -p horizon-client --all-targets --locked -- -D warnings")
self.assertEqual(by_name["clippy"].command, CLIPPY)
self.assertEqual(by_name["tests: horizon-client"].command,
"cargo test --locked -p horizon-client --tests")
"cargo test --locked -p horizon-client --features horizon-client/mods --tests")
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p horizon-client --doc")
self.assertIsNone(by_name["doc tests"].status)
@@ -58,12 +61,24 @@ class PrReadyTests(unittest.TestCase):
with self.subTest(path=path), mock.patch.object(pr_ready, "affected_here", return_value=[]):
steps = pr_ready.plan(args(quick=True), "origin/main", {path}, PACKAGES, LIBRARIES, DEPENDENCIES)
by_name = {step.name: step for step in steps}
self.assertEqual(by_name["clippy"].command,
"cargo clippy --workspace" + MODS + " --all-targets --locked -- -D warnings")
self.assertEqual(by_name["clippy"].command, CLIPPY)
self.assertEqual(by_name["tests: workspace"].command,
"cargo test --locked --workspace" + MODS + " --tests")
self.assertEqual(by_name["doc tests"].command, "cargo test --locked --workspace --doc")
def test_tests_get_the_features_ci_s_workspace_run_gives_them(self):
self.assertEqual(pr_ready.mod_features(["horizon-world"]), "")
self.assertEqual(pr_ready.mod_features(["horizon-client"]), " --features horizon-client/mods")
self.assertEqual(pr_ready.mod_features(["horizon-mods"]),
" --features horizon-mods/runtime,horizon-mods/pack,horizon-mods/index")
self.assertEqual(pr_ready.mod_features(None), MODS)
def test_python_tests_always_run(self):
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
steps = pr_ready.plan(args(quick=True), "origin/main", {"crates/horizon-core/src/lib.rs"},
PACKAGES, LIBRARIES, DEPENDENCIES)
self.assertIsNone({step.name: step for step in steps}["Python tests"].status)
def test_non_rust_changes_skip_workspace_checks(self):
for path in ("README.md", "tools/pr_ready.py", "launcher/src/main.rs"):
with self.subTest(path=path), mock.patch.object(pr_ready, "affected_here", return_value=[]):
@@ -77,7 +92,7 @@ class PrReadyTests(unittest.TestCase):
steps = pr_ready.plan(args(), "origin/main",
{"crates/horizon-core/src/lib.rs", "crates/horizon-client/examples/probe.rs"}, PACKAGES, LIBRARIES, DEPENDENCIES)
for step in steps:
if step.name in ("clippy", "tests: horizon-client, horizon-core", "doc tests"):
if step.name in ("tests: horizon-client, horizon-core", "doc tests"):
self.assertIn("-p horizon-client -p horizon-core", step.command)
self.assertIsNone(step.status)
@@ -94,15 +109,17 @@ class PrReadyTests(unittest.TestCase):
by_name = {step.name: step for step in steps}
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p horizon-core --doc")
def test_clippy_checks_transitive_consumers_but_tests_only_touched_crates(self):
packages = {name: f"crates/{name}" for name in ("core", "world", "client", "unrelated")}
dependencies = {"world": {"core"}, "client": {"world"}, "unrelated": set()}
def test_clippy_is_ci_s_and_the_server_build_when_the_game_is_affected(self):
packages = {name: f"crates/{name}" for name in ("core", "world", "horizon-client", "unrelated")}
dependencies = {"world": {"core"}, "horizon-client": {"world"}, "unrelated": set()}
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
steps = pr_ready.plan(args(), "origin/main", {"crates/core/src/lib.rs"},
packages, set(packages), dependencies)
unrelated = pr_ready.plan(args(), "origin/main", {"crates/unrelated/src/lib.rs"},
packages, set(packages), dependencies)
self.assertEqual({step.name: step for step in unrelated}["clippy"].command, pr_ready.CI_CLIPPY)
by_name = {step.name: step for step in steps}
self.assertEqual(by_name["clippy"].command,
"cargo clippy -p client -p core -p world --all-targets --locked -- -D warnings")
self.assertEqual(by_name["clippy"].command, CLIPPY)
self.assertEqual(by_name["tests: core"].command, "cargo test --locked -p core --tests")
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p core --doc")