mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
test: check make check and CI pick the same files for the API-type sync
This commit is contained in:
parent
3cbb932010
commit
af3e8a01f3
3 changed files with 23 additions and 3 deletions
|
|
@ -18,8 +18,7 @@
|
|||
# -> ruff over ruff-tests.toml + `make lint-test-quality` (test-linting.yml's
|
||||
# test-tree ruff and test-quality gate steps)
|
||||
# - dashboard -> prettier + eslint + lint budgets (test-linting.yml's ui job)
|
||||
# - litellm/, enterprise/, pyproject.toml, uv.lock, the generator and its lockfiles
|
||||
# -> regenerate the lazy OpenAPI snapshot and dashboard API types, fail on drift
|
||||
# - spec_pattern -> regenerate the lazy OpenAPI snapshot and dashboard API types, fail on drift
|
||||
# (test-linting.yml's ui-api-types job)
|
||||
#
|
||||
# Each block is skipped when no matching files are in scope, so unrelated commits
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ UI_API_TYPES_DETECT: Final[str] = next(
|
|||
for step in yaml.safe_load(WORKFLOW.read_text())["jobs"]["ui-api-types"]["steps"]
|
||||
if step.get("id") == "changes"
|
||||
)
|
||||
PRE_COMMIT_LINT: Final = WORKFLOW.parents[2] / "scripts" / "pre_commit_lint.sh"
|
||||
|
||||
|
||||
def _ui_api_types_relevant(tmp_path: Path, changed: str) -> bool:
|
||||
|
|
@ -168,3 +169,23 @@ def test_ui_api_types_check_runs_on_a_pull_request_touching_any_spec_input(tmp_p
|
|||
)
|
||||
def test_ui_api_types_check_skips_a_pull_request_that_cannot_change_the_spec(tmp_path: Path, changed: str) -> None:
|
||||
assert not _ui_api_types_relevant(tmp_path, changed)
|
||||
|
||||
|
||||
def _first_single_quoted_capture(pattern: str, text: str) -> str:
|
||||
match: Final = re.search(pattern, text, re.MULTILINE)
|
||||
assert match is not None, pattern
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def _tracked_paths_matching(extended_regex: str) -> frozenset[str]:
|
||||
tracked: Final = _git(WORKFLOW.parents[2], "ls-files")
|
||||
selected: Final = subprocess.run(["grep", "-E", extended_regex], input=tracked, capture_output=True, text=True)
|
||||
return frozenset(selected.stdout.splitlines())
|
||||
|
||||
|
||||
def test_make_check_runs_the_api_type_sync_on_the_same_tracked_files_as_ci() -> None:
|
||||
ci_trigger: Final = _first_single_quoted_capture(r"grep -Eq '([^']+)'", UI_API_TYPES_DETECT)
|
||||
make_check_trigger: Final = _first_single_quoted_capture(r"^spec_pattern='([^']+)'$", PRE_COMMIT_LINT.read_text())
|
||||
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"}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Never put LiteLLM tokens or API keys in `localStorage`. `localStorage` survives
|
|||
|
||||
When you fix lint violations that are grandfathered in `eslint-suppressions.json`, run `eslint . --prune-suppressions` and commit the updated baseline so the gate ratchets down instead of leaving a stale suppression
|
||||
|
||||
`src/lib/http/schema.d.ts` is generated from the proxy's OpenAPI spec. Never hand-edit it. After changing any backend route or request or response model, run `npm run gen:api` and commit the result, since the spec includes every route, not only the ones the dashboard calls (CI `lint / ui-api-types` enforces this)
|
||||
`src/lib/http/schema.d.ts` is generated from the proxy's OpenAPI spec. Never hand-edit it. After changing any backend route or request or response model, or bumping a dependency, run `npm run gen:api` and commit the result, since the spec includes every route, not only the ones the dashboard calls (CI `lint / ui-api-types` enforces this)
|
||||
|
||||
Tests come in three tiers, named by the standard definitions. `Foo.test.tsx` is a unit test: one module, collaborators replaced by doubles, no multi-component tree, and it should run in milliseconds. `Foo.integration.test.tsx` renders a real component tree with real children and only stubs the network boundary. It costs seconds per case, so it earns its place by proving wiring that a unit test cannot reach. Browser-level tests live in `tests/e2e/ui/` as Playwright specs against a live proxy
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue