diff --git a/tests/unit/test_lint_workflow_diff_gates.py b/tests/unit/test_lint_workflow_diff_gates.py index 4063a0eddcf..5d3c0d80aa6 100644 --- a/tests/unit/test_lint_workflow_diff_gates.py +++ b/tests/unit/test_lint_workflow_diff_gates.py @@ -1,5 +1,6 @@ from __future__ import annotations +import fnmatch import re import shlex import subprocess @@ -109,6 +110,7 @@ UI_API_TYPES_DETECT: Final[str] = next( if step.get("id") == "changes" ) PRE_COMMIT_LINT: Final = WORKFLOW.parents[2] / "scripts" / "pre_commit_lint.sh" +TERRAFORM_PROVIDER_WORKFLOW: Final = WORKFLOW.with_name("test-terraform-provider.yml") def _ui_api_types_relevant(tmp_path: Path, changed: str) -> bool: @@ -189,3 +191,12 @@ def test_make_check_runs_the_api_type_sync_on_the_same_tracked_files_as_ci() -> ci_selected: Final = _tracked_paths_matching(ci_trigger) assert "pyproject.toml" in ci_selected assert _tracked_paths_matching(make_check_trigger) == ci_selected - {".github/workflows/test-linting.yml"} + + +def test_a_pull_request_changing_any_route_file_runs_the_terraform_provider_endpoint_audit() -> None: + triggers: Final = yaml.safe_load(TERRAFORM_PROVIDER_WORKFLOW.read_text())[True]["pull_request"]["paths"] + route_files: Final = _git( + WORKFLOW.parents[2], "grep", "-l", "-E", r"APIRouter\(", "--", "*.py", ":(exclude)tests/**" + ).splitlines() + assert route_files + assert [name for name in route_files if not any(fnmatch.fnmatch(name, pattern) for pattern in triggers)] == [] diff --git a/tests/unit/test_terraform_provider_workflow.py b/tests/unit/test_terraform_provider_workflow.py deleted file mode 100644 index c5278efd55d..00000000000 --- a/tests/unit/test_terraform_provider_workflow.py +++ /dev/null @@ -1,32 +0,0 @@ -from __future__ import annotations - -import fnmatch -import subprocess -from pathlib import Path -from typing import Final - -import yaml - -REPO: Final = Path(__file__).resolve().parents[2] -WORKFLOW: Final = REPO / ".github" / "workflows" / "test-terraform-provider.yml" - - -def _route_files_outside_tests() -> tuple[str, ...]: - listed: Final = subprocess.run( - ["git", "grep", "-l", "-E", r"APIRouter\(", "--", "*.py", ":(exclude)tests/**"], - cwd=REPO, - check=True, - capture_output=True, - text=True, - ) - return tuple(listed.stdout.splitlines()) - - -def test_a_pull_request_changing_any_route_file_runs_the_provider_endpoint_audit() -> None: - pull_request_paths: Final = yaml.safe_load(WORKFLOW.read_text())[True]["pull_request"]["paths"] - route_files: Final = _route_files_outside_tests() - assert route_files - unmatched: Final = tuple( - name for name in route_files if not any(fnmatch.fnmatch(name, pattern) for pattern in pull_request_paths) - ) - assert unmatched == ()