Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(ci): bound setup steps so pytest always gets its full budget

mateo-berriefd98bb1b40b
diff --git a/.github/workflows/_test-unit-base.yml b/.github/workflows/_test-unit-base.yml
index 1de1faefd49..e91eb2240d3 100644
--- a/.github/workflows/_test-unit-base.yml
+++ b/.github/workflows/_test-unit-base.yml
@@ -26,10 +26,14 @@ on:
type: number
default: 20
setup-timeout-minutes:
- description: "Timeout allowance for everything before the test step"
+ description: >-
+ Timeout allowance for everything before the test step. Must stay >= the
+ sum of the per-step timeouts on the setup steps below, which is what
+ makes the test budget above a floor rather than a hope: setup cannot
+ overrun into it without failing its own step first.
required: false
type: number
- default: 12
+ default: 30
max-failures:
description: "Stop after this many failures"
required: false
@@ -58,24 +62,29 @@ jobs:
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
+ timeout-minutes: 3
with:
persist-credentials: false
- name: Detect backend-relevant changes
id: changes
+ timeout-minutes: 2
uses: ./.github/actions/detect-backend-changes
- name: Set up Python
+ timeout-minutes: 3
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- name: Set up uv
+ timeout-minutes: 3
uses: ./.github/actions/setup-uv-with-retries
with:
version: "0.10.9"
- name: Cache uv dependencies
+ timeout-minutes: 5
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
@@ -87,15 +96,18 @@ jobs:
- name: Install dependencies
if: steps.changes.outputs.decision != 'skip'
+ timeout-minutes: 8
run: |
.github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra saml
- name: Cache Prisma binaries
if: steps.changes.outputs.decision != 'skip'
+ timeout-minutes: 3
uses: ./.github/actions/cache-prisma-binaries
- name: Generate Prisma client
if: steps.changes.outputs.decision != 'skip'
+ timeout-minutes: 3
run: |
uv run --no-sync prisma generate --schema litellm/proxy/schema.prisma
diff --git a/tests/code_coverage_tests/check_prisma_binary_cache.py b/tests/code_coverage_tests/check_prisma_binary_cache.py
index 2544ec9708f..501688385ff 100644
--- a/tests/code_coverage_tests/check_prisma_binary_cache.py
+++ b/tests/code_coverage_tests/check_prisma_binary_cache.py
@@ -20,11 +20,12 @@ Three invariants keep that download off the critical path:
import re
import sys
-from collections.abc import Iterator
+from collections.abc import Iterator, Mapping
from pathlib import Path
from typing import Final
import yaml
+from pydantic import BaseModel, Field, ValidationError
REPO_ROOT: Final = Path(__file__).resolve().parent.parent.parent
WORKFLOWS_DIR: Final = REPO_ROOT / ".github" / "workflows"
@@ -50,25 +51,38 @@ def resolve_prisma_version(lock_text: str) -> str | None:
return match.group("version") if match else None
-def iter_jobs(workflow: object) -> Iterator[tuple[str, dict]]:
- jobs: Final = workflow.get("jobs") if isinstance(workflow, dict) else None
- if not isinstance(jobs, dict):
- return
- yield from ((name, job) for name, job in jobs.items() if isinstance(job, dict))
+class WorkflowStep(BaseModel):
+ """The two step fields this guard reads; every other key is ignored."""
+
+ run: str | None = None
+ uses: str | None = None
+
+ def generates_prisma_client(self) -> bool:
+ return self.run is not None and any(m in self.run for m in PRISMA_GENERATE_MARKERS)
+
+ def restores_cache(self) -> bool:
+ return self.uses == CACHE_ACTION
-def job_steps(job: dict) -> tuple[dict, ...]:
- steps: Final = job.get("steps")
- return tuple(s for s in steps if isinstance(s, dict)) if isinstance(steps, list) else ()
+class WorkflowJob(BaseModel):
+ # Absent for jobs that delegate to a reusable workflow via a job-level `uses`.
+ steps: tuple[WorkflowStep, ...] = ()
-def step_generates_prisma_client(step: dict) -> bool:
- run: Final = step.get("run")
- return isinstance(run, str) and any(m in run for m in PRISMA_GENERATE_MARKERS)
+class Workflow(BaseModel):
+ jobs: Mapping[str, WorkflowJob] = Field(default_factory=dict)
-def step_restores_cache(step: dict) -> bool:
- return step.get("uses") == CACHE_ACTION
+def parse_workflow(text: str) -> Workflow | str:
+ """Validate untyped YAML at the boundary so the checks below stay typed.
+
+ Returns the parsed workflow, or a description of why it could not be read.
+ """
+ parsed: Final = yaml.safe_load(text)
+ try:
+ return Workflow.model_validate(parsed if isinstance(parsed, dict) else {})
+ except ValidationError as exc:
+ return f"does not parse as a workflow: {exc.error_count()} schema error(s)"
def lock_errors(lock_text: str) -> Iterator[str]:
@@ -87,10 +101,14 @@ def workflow_errors(rel: Path, text: str) -> Iterator[str]:
f"land in the version-keyed default path the {CACHE_ACTION} action restores."
)
- for job_name, job in iter_jobs(yaml.safe_load(text)):
- steps: Final = job_steps(job)
- if any(map(step_generates_prisma_client, steps)) and not any(
- map(step_restores_cache, steps)
+ workflow: Final = parse_workflow(text)
+ if isinstance(workflow, str):
+ yield f"{rel}: {workflow}"
+ return
+
+ for job_name, job in workflow.jobs.items():
+ if any(s.generates_prisma_client() for s in job.steps) and not any(
+ s.restores_cache() for s in job.steps
):
yield (
f"{rel}: job `{job_name}` generates the Prisma client without a "