Files
horizon-airdef/tests/test_ci_rust_changes.py
T
Ludovic Marie 4fe648b674 Move the website to its own repository (ludovic111/horizon-site)
playhorizon.dev now deploys from the private ludovic111/horizon-site, which holds website/'s history. The files
its build still reads from here move out of website/:

- the design tokens to crates/horizon-theme/tokens.css (xtask tokens writes them, tokens_css_is_up_to_date checks them);
- the roadmap's JSON to roadmap/roadmap.json (tools/roadmap.py build);
- the benchmark fixtures to crates/horizon-telemetry-server/tests/fixtures/benchmarks/ (the site keeps a copy);
- the web icons to docs/media/brand/web/ (xtask icons).

pr_ready loses its website area and the tokens special case; rust_changes, the roadmap's links and every doc
that pointed into website/ follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 16:43:32 +01:00

54 lines
2.1 KiB
Python

import os
from pathlib import Path
import subprocess
import tempfile
import unittest
from tools.ci.rust_changes import changed_paths, needs_rust
class RustChangesTests(unittest.TestCase):
def test_only_content_changes_skip_rust(self):
self.assertFalse(needs_rust([]))
self.assertFalse(needs_rust([
"docs/setup.md", "docs/media/banner.html", "README.md",
]))
for path in [
"crates/horizon-client/src/game.rs", "xtask/src/main.rs", "Cargo.lock",
".cargo/config.toml", ".github/workflows/ci.yml", "tools/ci/rust_changes.py",
"research-lock.json", "crates/horizon-theme/tokens.css", "unknown-file",
]:
with self.subTest(path=path):
self.assertTrue(needs_rust(["README.md", path]))
def test_moving_source_into_docs_still_requires_rust(self):
with tempfile.TemporaryDirectory() as directory:
def git(*args):
return subprocess.check_output(["git", "-C", directory, *args])
git("init", "--quiet")
source = Path(directory, "source.rs")
source.write_text("fn main() {}\n")
git("add", ".")
git("-c", "user.name=CI test", "-c", "user.email=ci@example.invalid",
"-c", "commit.gpgsign=false", "commit", "--quiet", "-m", "base")
base = git("rev-parse", "HEAD").decode().strip()
Path(directory, "docs").mkdir()
source.rename(Path(directory, "docs/example.rs"))
git("add", "-A")
git("-c", "user.name=CI test", "-c", "user.email=ci@example.invalid",
"-c", "commit.gpgsign=false", "commit", "--quiet", "-m", "move")
# Exercise the same diff command as CI in the temporary repository.
previous = Path.cwd()
try:
os.chdir(directory)
paths = changed_paths(base, "HEAD")
finally:
os.chdir(previous)
self.assertIn("source.rs", paths)
self.assertTrue(needs_rust(paths))
if __name__ == "__main__":
unittest.main()