diff --git a/.github/workflows/test-linting.yml b/.github/workflows/test-linting.yml index c77d4b2ee96..9de9662ec6c 100644 --- a/.github/workflows/test-linting.yml +++ b/.github/workflows/test-linting.yml @@ -180,6 +180,18 @@ jobs: echo "No changed tests/e2e Python files; skipping." fi + - name: Run the claude_code harness unit tests + if: steps.changes.outputs.decision != 'skip' + run: | + if ! git diff --name-only --diff-filter=ACMRD "$GATE_BASE_SHA" HEAD -- ':(glob)tests/e2e/claude_code/**/*.py' ':(glob)tests/e2e/*.py' tests/e2e/claude_code/cron_vm/install_claude_code.sh pyproject.toml uv.lock .github/workflows/test-linting.yml | grep -q .; then + echo "No changed claude_code harness files; skipping." + exit 0 + fi + retry() { "$@" || { sleep 15; "$@"; } || { sleep 30; "$@"; }; } + CLAUDE_VERSION="$(retry uv run --no-sync python tests/e2e/claude_code/pr_gate_version_resolver.py)" + tests/e2e/claude_code/cron_vm/install_claude_code.sh "$CLAUDE_VERSION" "$RUNNER_TEMP/claude-cli" + PATH="$RUNNER_TEMP/claude-cli:$PATH" uv run --no-sync pytest -q --noconftest -o addopts= -o pythonpath=tests/e2e -p no:rerunfailures tests/e2e/claude_code/_*_unit_tests + - name: Check for circular imports if: steps.changes.outputs.decision != 'skip' run: | diff --git a/tests/test_litellm/test_lint_workflow_diff_gates.py b/tests/test_litellm/test_lint_workflow_diff_gates.py index 62e67cdaaab..23cb8aa1a0b 100644 --- a/tests/test_litellm/test_lint_workflow_diff_gates.py +++ b/tests/test_litellm/test_lint_workflow_diff_gates.py @@ -21,6 +21,10 @@ def _scoped_root(pathspec: str) -> str: return re.sub(r"^:\([^)]*\)", "", pathspec).split("*", 1)[0] +def _gate_rooted_at(root: str) -> tuple[str, ...]: + return next(gate for gate in GATES if _scoped_root(gate[0]) == root) + + def _changed_files_selected_by(tmp_path: Path, pathspecs: tuple[str, ...], files: tuple[str, ...]) -> frozenset[str]: _git(tmp_path, "init", "-q", "-b", "main") _git(tmp_path, "config", "user.email", "t@t") @@ -37,8 +41,10 @@ def _changed_files_selected_by(tmp_path: Path, pathspecs: tuple[str, ...], files ) -def test_workflow_still_carries_the_ruff_format_and_e2e_basedpyright_diff_gates() -> None: - assert frozenset(_scoped_root(gate[0]) for gate in GATES) == frozenset({"litellm/", "tests/e2e/"}) +def test_workflow_still_carries_the_ruff_format_e2e_basedpyright_and_claude_code_harness_diff_gates() -> None: + assert frozenset(_scoped_root(gate[0]) for gate in GATES) == frozenset( + {"litellm/", "tests/e2e/", "tests/e2e/claude_code/"} + ) @pytest.mark.parametrize("pathspecs", GATES, ids=" ".join) @@ -52,3 +58,21 @@ def test_diff_gate_selects_top_level_and_nested_python_files_only(tmp_path: Path (top_level, nested, f"{root}notes.md", "elsewhere/top_level_module.py", "elsewhere/pkg/nested_module.py"), ) assert selected == frozenset({top_level, nested}) + + +@pytest.mark.parametrize( + "trigger", + ( + "tests/e2e/claude_code/cron_vm/install_claude_code.sh", + "pyproject.toml", + "uv.lock", + ".github/workflows/test-linting.yml", + ), +) +def test_claude_code_gate_also_fires_on_its_installer_dependency_manifests_and_workflow( + tmp_path: Path, trigger: str +) -> None: + selected = _changed_files_selected_by( + tmp_path, _gate_rooted_at("tests/e2e/claude_code/"), (trigger, "elsewhere/pyproject.toml", "tests/e2e/notes.md") + ) + assert selected == frozenset({trigger})