diff --git a/.github/scripts/intel_host_tests.py b/.github/scripts/intel_host_tests.py index b95030bb4a..dfe1e64eaf 100644 --- a/.github/scripts/intel_host_tests.py +++ b/.github/scripts/intel_host_tests.py @@ -322,7 +322,9 @@ def source_identity(root): def run_identity(): result = {name: os.environ.get(name, "") for name in ("GITHUB_REPOSITORY", "GITHUB_RUN_ID", "GITHUB_RUN_ATTEMPT")} require(all(result.values()), "GitHub repository, run ID and attempt are required") - require(result["GITHUB_REPOSITORY"] == "UOR-Foundation/LexLean", "foreign repository") + # GitHub names a repository case-insensitively, and the repository is now + # spelled `UOR-Foundation/lexlean`; any other repository stays foreign. + require(result["GITHUB_REPOSITORY"].lower() == "uor-foundation/lexlean", "foreign repository") require(all(result[n].isdigit() for n in ("GITHUB_RUN_ID", "GITHUB_RUN_ATTEMPT")), "invalid run ID/attempt") return result diff --git a/.github/scripts/test_intel_host_tests.py b/.github/scripts/test_intel_host_tests.py index 89c45ec720..01bd4ca670 100644 --- a/.github/scripts/test_intel_host_tests.py +++ b/.github/scripts/test_intel_host_tests.py @@ -153,6 +153,16 @@ def test_committed_lane_plan_is_complete_and_preserves_existing_parts(self): self.assertGreater(len(lanes["lanes"]), 0) self.assertEqual(set(lanes["producer"]), set(bdd["targets"])) + def test_run_identity_names_this_repository_in_any_case(self): + run = {"GITHUB_RUN_ID": "100", "GITHUB_RUN_ATTEMPT": "1"} + for name in ("UOR-Foundation/LexLean", "UOR-Foundation/lexlean"): + with patch.dict(os.environ, dict(run, GITHUB_REPOSITORY=name)): + self.assertEqual(factory.run_identity()["GITHUB_REPOSITORY"], name) + for name in ("someone/lexlean", "UOR-Foundation/lexlean-fork"): + with patch.dict(os.environ, dict(run, GITHUB_REPOSITORY=name)): + with self.assertRaisesRegex(factory.Invalid, "foreign repository"): + factory.run_identity() + def test_plan_missing_duplicate_foreign_and_added_part_are_refused(self): fixture = Fixture(self.directory) for change in (lambda p: p["lanes"]["lower"].clear(), lambda p: p["lanes"]["print"].append("a"), lambda p: p["lanes"]["moves"].append("unknown")): diff --git a/.gitignore b/.gitignore index a69bae0677..d695252741 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,10 @@ compiler/.lexlean/ # and make `cargo package` read a dirty working directory. /release/ +# Python bytecode the CI helper scripts' unit tests leave beside them. +__pycache__/ +*.pyc + # Editor and OS noise. .DS_Store *.swp