mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
ci: run the claude_code harness unit-test trees in the lint job (#43077)
* ci: run the claude_code harness unit-test trees in the lint job * ci: gate the harness step on Python files plus its installer and workflow * ci: fire the harness step on dependency manifest changes too * test: cover the harness gate's installer, manifest, and workflow triggers --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
This commit is contained in:
parent
c183d810f3
commit
e025504d26
2 changed files with 38 additions and 2 deletions
12
.github/workflows/test-linting.yml
vendored
12
.github/workflows/test-linting.yml
vendored
|
|
@ -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: |
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue