Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ def runtime(path):
return path.startswith("crates/xcl/src/") and "/tests" not in path and not path.endswith("tests.rs")


# built into xcl.exe from outside crates/xcl/src: the data it compiles in (stubdb.toml, by
# include_str!), its build script, and the manifests and lock file that pick its dependencies
# and the release profile
RUNTIME_BUILD = ("crates/xcl/build.rs", "crates/xcl/Cargo.toml", "Cargo.toml", "Cargo.lock")


def builds_runtime(path):
return path.startswith("crates/xcl/data/") or path in RUNTIME_BUILD


def check(body, head, files, is_main_ancestor, *, test_only=False):
"""The problems (empty: mergeable as far as this check goes). `files`: (path, status, binary,
size) with `size` a function giving the file's bytes; `is_main_ancestor(sha)`: whether the
Expand Down Expand Up @@ -74,7 +84,7 @@ def check(body, head, files, is_main_ancestor, *, test_only=False):
elif binary and not in_test_data:
problems.append(f"`{path}` is a binary file outside tests/data/ or over 1 MB")

if not test_only and any(runtime(p) for p, *_ in files):
if not test_only and any(runtime(p) or builds_runtime(p) for p, *_ in files):
blocks = smoke_blocks(body)
mine = [b for b in blocks if len(b.get("commit", "")) >= 7 and head.startswith(b["commit"].split()[0])]
clean = [b for b in mine if "uncommitted" not in b.get("commit", "")]
Expand Down
12 changes: 12 additions & 0 deletions scripts/test_pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def test_approval_keeps_description_and_asset_checks(self):
for reason in ("Not tested", "AI use", "content.rpf", "attachment.txt"):
self.assertTrue(any(reason in problem for problem in problems), problems)

def test_runtime_build_inputs_require_smoke_until_approved(self):
for path in ("crates/xcl/data/stubdb.toml", "crates/xcl/build.rs", "crates/xcl/Cargo.toml",
"Cargo.toml", "Cargo.lock"):
with self.subTest(path=path):
problems = check(BODY, HEAD, [changed(path)], lambda _: False)
self.assertEqual(2, len(problems))
self.assertTrue(all("Regression run" in problem for problem in problems))
self.assertEqual([], check(BODY, HEAD, [changed(path)], lambda _: False, test_only=True))
for path in ("tests/testtitle/Cargo.toml", "tests/testgamedll/build.rs", "crates/xcl/tests/data/x.toml"):
with self.subTest(path=path):
self.assertEqual([], check(BODY, HEAD, [changed(path)], lambda _: False))

def test_test_paths_do_not_need_approval(self):
files = [changed("crates/xcl/tests/integration.rs"), changed("crates/xcl/src/gpu/recomp/tests.rs")]
self.assertEqual([], check(BODY, HEAD, files, lambda _: False))
Expand Down
Loading