diff --git a/scripts/ci/build_input_fingerprint.py b/scripts/ci/build_input_fingerprint.py deleted file mode 100755 index 010a0746a5c7..000000000000 --- a/scripts/ci/build_input_fingerprint.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 -"""Hash everything compile admission can read, so equal hashes mean an equal build. - -The hash covers the git tree entries (mode, object id, path) of every tracked -path except those known not to reach the Xcode build, plus any extra strings the -caller pins (the selected Xcode). Two commits with the same fingerprint compile -the same sources with the same toolchain, whatever else differs between them. -""" - -from __future__ import annotations - -import argparse -import hashlib -import subprocess -import sys -from pathlib import Path - -sys.path.insert(0, str(Path(__file__).resolve().parent)) - -from detect_ci_change_areas import is_macos_change # noqa: E402 - -CI_WORKFLOW = ".github/workflows/ci.yml" - - -def reaches_the_build(path: str) -> bool: - """False only for paths the router already calls macOS-neutral, and for CI - plumbing the Xcode build never opens: guard tests, other workflows, Markdown.""" - if path == CI_WORKFLOW: - return True - if path.startswith((".github/", "tests/", "tests_v2/")) or path.endswith(".md"): - return False - return is_macos_change(path) - - -def fingerprint(tree_lines: list[str], extra: list[str]) -> str: - digest = hashlib.sha256() - for line in sorted(tree_lines): - # " \t" - path = line.split("\t", 1)[1] - if reaches_the_build(path): - digest.update(line.encode("utf-8") + b"\n") - for value in extra: - digest.update(b"extra:" + value.encode("utf-8") + b"\n") - return digest.hexdigest() - - -def main(argv: list[str]) -> int: - parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) - parser.add_argument("--revision", default="HEAD") - parser.add_argument("--extra", action="append", default=[]) - args = parser.parse_args(argv) - lines = subprocess.check_output( - ["git", "-c", "core.quotepath=off", "ls-tree", "-r", args.revision], text=True - ).splitlines() - print(fingerprint(lines, args.extra)) - return 0 - - -if __name__ == "__main__": - sys.exit(main(sys.argv[1:])) diff --git a/tests/test_ci_change_areas.py b/tests/test_ci_change_areas.py index b0c724df3f5c..d56ed3fd39ad 100644 --- a/tests/test_ci_change_areas.py +++ b/tests/test_ci_change_areas.py @@ -1360,25 +1360,6 @@ def gate(**kwargs) -> int: ).returncode == 1 -def test_build_input_fingerprint_ignores_only_what_the_build_cannot_read() -> None: - sys.path.insert(0, str(ROOT / "scripts/ci")) - from build_input_fingerprint import fingerprint, reaches_the_build - - def tree(**files: str) -> list[str]: - return [f"100644 blob {object_id}\t{path}" for path, object_id in files.items()] - - base = tree(**{"Sources/App.swift": "a1", "tests/test_x.py": "b1", "docs/x.md": "c1", ".github/workflows/nightly.yml": "d1"}) - same_build = tree(**{"Sources/App.swift": "a1", "tests/test_x.py": "b2", "docs/x.md": "c2", ".github/workflows/nightly.yml": "d2", "web/app/page.tsx": "e1"}) - assert fingerprint(base, ["xcode=1"]) == fingerprint(same_build, ["xcode=1"]) - assert fingerprint(base, ["xcode=1"]) != fingerprint(base, ["xcode=2"]) - for path in ("Sources/App.swift", "Packages/macOS/CmuxCore/Package.swift", "cmuxTests/T.swift", "cmux.xcodeproj/project.pbxproj", - "scripts/build-ghostty-cli-helper.sh", "ghostty", ".github/workflows/ci.yml", ".xcode-version", "unknown/new-dir/file"): - assert reaches_the_build(path), path - assert fingerprint(base, []) != fingerprint(base + tree(**{path: "z9"}), []), path - for path in ("tests/test_ci_change_areas.py", ".github/workflows/nightly.yml", "docs/a.md", "web/app/page.tsx", "README.md", "CLAUDE.md"): - assert not reaches_the_build(path), path - - def admission_api(runs: list[dict], artifacts: dict[int, list[str]], jobs: dict[int, list[dict]], branch: str = "feature"): """Fake GitHub API: `artifacts` lists the artifact names each run holds.""" from urllib.parse import parse_qs, urlsplit