mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* ci: start fewer jobs per pull request A typical backend pull request started about 104 runners, and many of them only checked out the repo to find their files had not changed. The unit plan job now classifies the change once and skips ui-unit, dashboard-build, redis-compat, python-310 and helm at the job level when their inputs did not change, and the whole backend set on docs-only and UI-only pull requests. unit passed still accepts a skip only for jobs the plan listed. The lint plan does the same for the ui lint job. Smoke runs its six core interpreters and both all-extras environments in one job, installing the venvs in parallel and then running the existing checks in parallel inside the loopback namespace. dashboard-build moves into the unit workflow so the plan can gate it on the dashboard sources and the Dockerfile, its only inputs. ci-coverage, semgrep and the secret scans move into code-quality, the three OpenAI SDK versions run one after another in one job, and the docs job's checks run in lint-runtime. lint-runtime now runs on release-branch pull requests too, where it skips import safety, the OpenAPI gate and the code-quality checks and runs only the docs checks the docs job ran there. * ci: give the smoke job its own uv cache and check CI coverage before the docs checkout The combined smoke job restored the old py3.15 job's uv cache, an exact key hit that main would never overwrite, so Python 3.14 built grpcio-tools from source on every run (4m41s). It now uses its own cache suffix, and each interpreter starts its checks as soon as its own install finishes. The coverage assertions in code-quality saw the litellm-docs checkout's Dockerfile as an unbuilt image, so they now run before that checkout. * ci(smoke): keep 3.14 and 3.15 on their own cached runners Those two interpreters build grpcio-tools and other packages from source when their uv cache misses. Inside the combined job, with an empty cache and six other installs on four CPUs, 3.14 took 13.9 minutes and 3.15 ran past the 20-minute timeout. They now run as py3.14 and py3.15 again, restoring the same per-version caches as before, and core-checks keeps 3.10 to 3.13 and both all-extras environments. * ci(ui): run the dashboard unit tests on 3 shards instead of 6 * ci(ui): run the dashboard unit tests on 4 shards so the full suite stays under 10 minutes
655 lines
28 KiB
YAML
655 lines
28 KiB
YAML
name: lint
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- "litellm_**"
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
plan:
|
|
name: lint plan
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
outputs:
|
|
mode: ${{ steps.plan.outputs.mode }}
|
|
skipped: ${{ steps.plan.outputs.skipped }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 3
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
sparse-checkout: .github
|
|
|
|
- name: Detect dashboard source changes
|
|
id: ui
|
|
timeout-minutes: 2
|
|
uses: ./.github/actions/detect-changes
|
|
with:
|
|
category: ui
|
|
|
|
- name: Run the diff gates on pull requests and the tree-wide checks on main and labelled pull requests
|
|
id: plan
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
UI: ${{ steps.ui.outputs.decision }}
|
|
run: |
|
|
if [ -z "${PR_NUMBER}" ]; then
|
|
mode=push
|
|
skipped='["python","typecheck","ui"]'
|
|
else
|
|
mode=core
|
|
skipped='["e2e-harness","ui-api-types"]'
|
|
labels="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels" --paginate --jq '.[].name')" || mode=full
|
|
! grep -qx 'run-all-unit-shards' <<< "${labels:-}" || mode=full
|
|
[ "${mode}" = core ] || skipped='[]'
|
|
[ "${UI}" != skip ] || skipped="$(jq -c '. + ["ui"]' <<< "${skipped}")"
|
|
fi
|
|
printf 'mode=%s\nskipped=%s\n' "${mode}" "${skipped}" | tee -a "$GITHUB_OUTPUT"
|
|
python:
|
|
name: python
|
|
needs: plan
|
|
if: ${{ needs.plan.outputs.mode != 'push' }}
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
actions: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- &checkout-head
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 1
|
|
clean: true
|
|
persist-credentials: false
|
|
|
|
- &detect-changes
|
|
name: Detect relevant changes
|
|
id: changes
|
|
uses: ./.github/actions/detect-changes
|
|
|
|
- &fetch-gate-base
|
|
name: Fetch gate base (merge-base with target branch)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
EVENT_BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
retry() { "$@" || { sleep 15; "$@"; } || { sleep 30; "$@"; }; }
|
|
BASE_REF=$(gh api "repos/${GITHUB_REPOSITORY}/branches/${EVENT_BASE_REF}" --jq .name) || BASE_REF=$(retry gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq .base.ref)
|
|
MERGE_BASE=$(retry gh api "repos/${GITHUB_REPOSITORY}/compare/${BASE_REF}...${HEAD_SHA}?per_page=1" --jq '.merge_base_commit.sha')
|
|
test -n "$MERGE_BASE"
|
|
retry git fetch --no-tags --depth=1 origin "$MERGE_BASE"
|
|
echo "GATE_BASE_SHA=$MERGE_BASE" >> "$GITHUB_ENV"
|
|
|
|
- &head-tool-paths
|
|
name: Find the lint tool paths the PR head carries
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
if [ -d litellm/scripts ]; then echo "SCRIPTS_DIR=litellm/scripts" >> "$GITHUB_ENV"; else echo "SCRIPTS_DIR=scripts" >> "$GITHUB_ENV"; fi
|
|
if [ -f .github/linters/ruff-tests.toml ]; then echo "RUFF_TESTS_CONFIG=.github/linters/ruff-tests.toml" >> "$GITHUB_ENV"; else echo "RUFF_TESTS_CONFIG=ruff-tests.toml" >> "$GITHUB_ENV"; fi
|
|
|
|
- &setup-python
|
|
name: Set up Python
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- &setup-uv
|
|
name: Set up uv
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
uses: ./.github/actions/setup-uv-with-retries
|
|
with:
|
|
version: "0.10.9"
|
|
|
|
- &cache-uv
|
|
name: Cache uv dependencies
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: |
|
|
~/.cache/uv
|
|
.venv
|
|
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-uv-
|
|
|
|
- name: Clean Python cache
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
find . -type d -name "__pycache__" -exec rm -rf {} + || true
|
|
find . -name "*.pyc" -delete || true
|
|
|
|
- name: Check uv.lock is up to date
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
uv lock --check || (echo "❌ uv.lock is out of sync with pyproject.toml. Run 'uv lock' locally and commit the result." && exit 1)
|
|
|
|
- name: Install the lint tools
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
uv sync --frozen --only-group dev --no-install-project
|
|
|
|
- name: Check ruff format
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
git diff --name-only --diff-filter=ACMR "$GATE_BASE_SHA" HEAD -- ':(glob)litellm/**/*.py' | grep -Ev '^litellm/(enterprise|ui|vscode-extension|rust|proxy-extras|packaging|cli|scripts|runtime)/' > "$RUNNER_TEMP/ruff_format_files.txt" || true
|
|
if [ ! -s "$RUNNER_TEMP/ruff_format_files.txt" ]; then
|
|
echo "No changed litellm Python files to check with ruff format."
|
|
exit 0
|
|
fi
|
|
xargs uv run --no-sync ruff format --check --exclude '/enterprise/' < "$RUNNER_TEMP/ruff_format_files.txt"
|
|
|
|
- name: Debug - Check file state
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
echo "Current branch:"
|
|
git branch --show-current
|
|
echo "Last 3 commits:"
|
|
git log --oneline -3
|
|
echo "File content around line 43:"
|
|
head -50 litellm/litellm_core_utils/custom_logger_registry.py | tail -10
|
|
|
|
- name: Check MCP operation boundary
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: uv run --no-sync python "$SCRIPTS_DIR/check_mcp_operation_boundary.py"
|
|
|
|
- name: Run Ruff linting
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
cd litellm
|
|
uv run --no-sync ruff check .
|
|
cd ..
|
|
|
|
- name: Run Ruff linting (test tree)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
uv run --no-sync ruff check --config "$RUFF_TESTS_CONFIG" tests
|
|
|
|
- name: Check strict ruff rules (delta vs merge-base counts)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
uv run --no-sync python "$SCRIPTS_DIR/ruff_strict_gate.py" --base "$GATE_BASE_SHA"
|
|
|
|
- name: Check type discipline (mutable collections / casts / type guards / kwargs / unexplained suppressions, delta vs merge-base counts)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
uv run --no-sync python "$SCRIPTS_DIR/type_discipline_gate.py" --base "$GATE_BASE_SHA"
|
|
|
|
- name: Check test quality (zero-assert / mock-echo tests, sys.path.insert, raw env writes, litellm global mutation, credential-gated skips, conftest snapshot inventory, delta vs merge-base counts)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
uv run --no-sync python "$SCRIPTS_DIR/test_quality_gate.py" --base "$GATE_BASE_SHA"
|
|
|
|
- name: Check for circular imports
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
cd litellm
|
|
uv run --no-sync python ../tests/documentation_tests/test_circular_imports.py
|
|
cd ..
|
|
|
|
- name: check_migrations_no_data_rewrites
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: uv run --no-sync python ./tests/code_coverage_tests/check_migrations_no_data_rewrites.py
|
|
|
|
- name: check_migrations_lock_timeout
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: uv run --no-sync python ./tests/code_coverage_tests/check_migrations_lock_timeout.py
|
|
|
|
typecheck:
|
|
name: typecheck
|
|
needs: plan
|
|
if: ${{ needs.plan.outputs.mode != 'push' }}
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
actions: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- *checkout-head
|
|
- *detect-changes
|
|
- *fetch-gate-base
|
|
- *head-tool-paths
|
|
- *setup-python
|
|
- *setup-uv
|
|
- *cache-uv
|
|
- name: Cache Prisma binaries
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
uses: ./.github/actions/cache-prisma-binaries
|
|
|
|
- name: Check basedpyright (delta vs merge-base counts)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
python "$SCRIPTS_DIR/type_check_gate.py" --base "$GATE_BASE_SHA"
|
|
|
|
- name: Check tests/e2e basedpyright (zero errors)
|
|
if: steps.changes.outputs.decision != 'skip'
|
|
run: |
|
|
if git diff --name-only --diff-filter=ACMRD "$GATE_BASE_SHA" HEAD -- ':(glob)tests/e2e/**/*.py' ':(glob)tests/e2e_harness/**/*.py' ':(glob)litellm/**/*.py' pyproject.toml uv.lock | grep -q .; then
|
|
uv sync --frozen --no-install-project --group proxy-dev --group e2e-dev --extra proxy
|
|
uv run --no-sync basedpyright tests/e2e tests/e2e_harness
|
|
else
|
|
echo "No changed tests/e2e or litellm Python, or dependency files; skipping."
|
|
fi
|
|
|
|
e2e-harness:
|
|
name: e2e-harness
|
|
needs: plan
|
|
if: ${{ needs.plan.outputs.mode != 'core' }}
|
|
permissions:
|
|
contents: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
services:
|
|
redis:
|
|
image: redis@sha256:e2debfb7956fa12c7ddc79d7e645c8cf26b30c99a6e9161ea9bf4171e1668a5f
|
|
ports:
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
|
|
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- uses: ./.github/actions/setup-uv-with-retries
|
|
with:
|
|
version: "0.10.9"
|
|
|
|
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: |
|
|
~/.cache/uv
|
|
.venv
|
|
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-uv-
|
|
|
|
- uses: ./.github/actions/cache-cargo-build
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --frozen --group proxy-dev --group e2e-dev
|
|
|
|
- name: Run the e2e harness tests
|
|
env:
|
|
LITELLM_MASTER_KEY: sk-e2e-harness-tests-reach-no-proxy
|
|
E2E_CACHE_TEST_REDIS_URL: redis://127.0.0.1:6379/0
|
|
run: |
|
|
retry() { "$@" || { sleep 15; "$@"; } || { sleep 30; "$@"; }; }
|
|
CLAUDE_VERSION="$(retry uv run --no-sync python tests/e2e/cli_harness/npm_version_resolver.py @anthropic-ai/claude-code)"
|
|
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 tests/e2e_harness
|
|
uv run --no-sync pytest --tb=short -q --noconftest -o addopts= -o "pythonpath=tests/e2e tests/e2e_harness" -p no:rerunfailures \
|
|
tests/code_coverage_tests/test_provider_replay_harness.py \
|
|
tests/code_coverage_tests/test_provider_cache.py
|
|
|
|
ui:
|
|
name: ui
|
|
needs: plan
|
|
if: ${{ needs.plan.outputs.mode != 'push' && !contains(fromJSON(needs.plan.outputs.skipped || '[]'), 'ui') }}
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 8
|
|
defaults:
|
|
run:
|
|
working-directory: litellm/ui/litellm-dashboard
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
|
|
- name: Collect changed files
|
|
id: changed
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
EVENT_BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
base_ref=$(gh api "repos/${GITHUB_REPOSITORY}/branches/${EVENT_BASE_REF}" --jq .name) || base_ref=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq .base.ref)
|
|
merge_base=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${base_ref}...${HEAD_SHA}?per_page=1" --jq '.merge_base_commit.sha')
|
|
test -n "$merge_base"
|
|
git fetch --no-tags --depth=1 origin "$merge_base" "$HEAD_SHA"
|
|
: > "$RUNNER_TEMP/prettier_files.txt"
|
|
: > "$RUNNER_TEMP/eslint_files.txt"
|
|
while IFS= read -r f; do
|
|
[ -f "$f" ] || continue
|
|
case "$f" in
|
|
*.js | *.jsx | *.ts | *.tsx | *.mjs | *.cjs)
|
|
printf '%s\n' "$f" >> "$RUNNER_TEMP/prettier_files.txt"
|
|
printf '%s\n' "$f" >> "$RUNNER_TEMP/eslint_files.txt" ;;
|
|
*.json | *.css | *.scss | *.md | *.mdx | *.yml | *.yaml | *.html)
|
|
printf '%s\n' "$f" >> "$RUNNER_TEMP/prettier_files.txt" ;;
|
|
esac
|
|
done < <(git diff --name-only --diff-filter=ACMR --relative "$merge_base" "$HEAD_SHA" -- .)
|
|
if [ -s "$RUNNER_TEMP/prettier_files.txt" ] || [ -s "$RUNNER_TEMP/eslint_files.txt" ]; then
|
|
echo "has_files=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "has_files=false" >> "$GITHUB_OUTPUT"
|
|
echo "No lintable UI files changed in this PR; nothing to check."
|
|
fi
|
|
|
|
- name: Setup Node.js
|
|
if: steps.changed.outputs.has_files == 'true'
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version-file: litellm/ui/litellm-dashboard/.nvmrc
|
|
cache: "npm"
|
|
cache-dependency-path: litellm/ui/litellm-dashboard/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
if: steps.changed.outputs.has_files == 'true'
|
|
run: npm ci
|
|
|
|
- name: Lint changed files (prettier + eslint)
|
|
if: steps.changed.outputs.has_files == 'true'
|
|
run: |
|
|
prettier_files=()
|
|
eslint_files=()
|
|
while IFS= read -r f; do prettier_files+=("$f"); done < "$RUNNER_TEMP/prettier_files.txt"
|
|
while IFS= read -r f; do eslint_files+=("$f"); done < "$RUNNER_TEMP/eslint_files.txt"
|
|
status=0
|
|
if [ ${#prettier_files[@]} -gt 0 ]; then
|
|
echo "::group::Prettier (${#prettier_files[@]} files)"
|
|
node_modules/.bin/prettier --check "${prettier_files[@]}" || { status=1; echo "::error::Unformatted files. Fix with: npm run format"; }
|
|
echo "::endgroup::"
|
|
fi
|
|
if [ ${#eslint_files[@]} -gt 0 ]; then
|
|
echo "::group::ESLint (${#eslint_files[@]} files)"
|
|
node_modules/.bin/eslint --no-warn-ignored --pass-on-unpruned-suppressions "${eslint_files[@]}" || status=1
|
|
echo "::endgroup::"
|
|
fi
|
|
exit $status
|
|
|
|
- name: Check lint budgets
|
|
if: ${{ !cancelled() && steps.changed.outputs.has_files == 'true' }}
|
|
run: |
|
|
npx eslint . -f json -o "$RUNNER_TEMP/lint-report.json" || true
|
|
node scripts/check-lint-budgets.mjs "$RUNNER_TEMP/lint-report.json" eslint-budgets.json
|
|
|
|
- name: Check for dead code (knip)
|
|
if: ${{ !cancelled() && steps.changed.outputs.has_files == 'true' }}
|
|
run: npm run knip:ci
|
|
ui-api-types:
|
|
name: ui-api-types
|
|
needs: plan
|
|
if: ${{ needs.plan.outputs.mode != 'core' }}
|
|
permissions:
|
|
contents: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 2
|
|
|
|
- name: Detect changes that can affect the generated types
|
|
id: changes
|
|
run: |
|
|
set -euo pipefail
|
|
if ! base="$(git rev-parse --verify --quiet HEAD^2 >/dev/null && git rev-parse HEAD^1)"; then
|
|
echo "Not a pull request merge commit, running the full check."
|
|
echo "relevant=true" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
files="$(git diff --name-only "$base" HEAD)"
|
|
if grep -Ev '^litellm/(ui|vscode-extension|rust|proxy-extras|packaging|cli|scripts|runtime)/' <<< "$files" | grep -E '^(litellm/|enterprise/|(pyproject\.toml|uv\.lock)$|\.github/workflows/test-linting\.yml$)' >/dev/null || grep -Eq '^litellm/ui/litellm-dashboard/(src/lib/http/schema\.d\.ts|scripts/gen-api-types\.mjs|package(-lock)?\.json)$' <<< "$files"; then
|
|
echo "relevant=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "No litellm, enterprise, dependency or generator changes in this pull request, nothing to verify."
|
|
echo "relevant=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Set up Python
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Set up uv
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: ./.github/actions/setup-uv-with-retries
|
|
with:
|
|
version: "0.10.9"
|
|
|
|
- name: Cache uv dependencies
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: |
|
|
~/.cache/uv
|
|
.venv
|
|
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-uv-
|
|
|
|
- name: Cache the Rust build
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: ./.github/actions/cache-cargo-build
|
|
|
|
- name: Install backend dependencies
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
run: .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router
|
|
|
|
- name: Cache Prisma binaries
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: ./.github/actions/cache-prisma-binaries
|
|
|
|
- name: Generate Prisma client
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
run: uv run --no-sync prisma generate --schema litellm/proxy/schema.prisma
|
|
|
|
- name: Regenerate the lazy OpenAPI snapshot
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
run: uv run --no-sync python -m litellm.proxy._lazy_openapi_snapshot
|
|
|
|
- name: Fail if the lazy OpenAPI snapshot is stale
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
run: |
|
|
if ! git diff --exit-code -- litellm/proxy/_lazy_openapi_snapshot.json; then
|
|
echo "::error file=litellm/proxy/_lazy_openapi_snapshot.json::The lazy OpenAPI snapshot is out of sync with the lazily loaded routes."
|
|
echo ""
|
|
echo "A lazily loaded route or model changed without regenerating the snapshot that /openapi.json serves for unloaded features."
|
|
echo "To fix, run from the repo root:"
|
|
echo " uv run python -m litellm.proxy._lazy_openapi_snapshot"
|
|
echo "then run npm run gen:api from litellm/ui/litellm-dashboard and commit both files."
|
|
exit 1
|
|
fi
|
|
echo "_lazy_openapi_snapshot.json is in sync with the lazily loaded routes."
|
|
|
|
- name: Set up Node.js
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version-file: litellm/ui/litellm-dashboard/.nvmrc
|
|
cache: "npm"
|
|
cache-dependency-path: litellm/ui/litellm-dashboard/package-lock.json
|
|
|
|
- name: Install dashboard dependencies
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
working-directory: litellm/ui/litellm-dashboard
|
|
run: npm ci
|
|
|
|
- name: Regenerate types from the live spec
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
working-directory: litellm/ui/litellm-dashboard
|
|
env:
|
|
LITELLM_PYTHON: "uv run --no-sync python"
|
|
run: npm run gen:api
|
|
|
|
- name: Fail if types are stale
|
|
if: steps.changes.outputs.relevant == 'true'
|
|
run: |
|
|
if ! git diff --exit-code -- litellm/ui/litellm-dashboard/src/lib/http/schema.d.ts; then
|
|
echo "::error file=litellm/ui/litellm-dashboard/src/lib/http/schema.d.ts::Generated API types are out of sync with the proxy OpenAPI spec."
|
|
echo ""
|
|
echo "A backend route or model changed without regenerating the dashboard types."
|
|
echo "To fix, run from litellm/ui/litellm-dashboard:"
|
|
echo " npm run gen:api"
|
|
echo "then commit the updated src/lib/http/schema.d.ts."
|
|
exit 1
|
|
fi
|
|
echo "schema.d.ts is in sync with the proxy OpenAPI spec."
|
|
code-quality:
|
|
name: code-quality
|
|
permissions:
|
|
contents: read
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Set up uv
|
|
uses: ./.github/actions/setup-uv-with-retries
|
|
with:
|
|
version: "0.10.9"
|
|
|
|
- name: Cache uv dependencies
|
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: |
|
|
~/.cache/uv
|
|
.venv
|
|
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-uv-
|
|
|
|
- name: Install the lint tools
|
|
run: uv sync --frozen --only-group dev --no-install-project
|
|
|
|
- name: Check that CI runs every test file and Dockerfile, before the docs checkout adds files
|
|
run: |
|
|
uv run --no-sync python .github/scripts/assert_ci_coverage.py
|
|
uv run --no-sync python .github/scripts/assert_ci_coverage.py --slices
|
|
uv run --no-sync python .github/scripts/assert_workflow_dir_hygiene.py
|
|
|
|
- name: Checkout litellm-docs into docs/my-website (for documentation_tests)
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
repository: BerriAI/litellm-docs
|
|
path: docs/my-website
|
|
persist-credentials: false
|
|
|
|
- name: Run the code-quality checks that do not import litellm
|
|
run: |
|
|
uv run --no-sync python .github/scripts/ci/run_parallel_checks.py --jobs 4 <<'EOF'
|
|
python ./tests/code_coverage_tests/check_licenses.py
|
|
python ./tests/code_coverage_tests/check_provider_folders_documented.py
|
|
python litellm/scripts/generate_provider_endpoints_support.py --check
|
|
python ./tests/code_coverage_tests/check_prisma_binary_cache.py
|
|
python ./tests/code_coverage_tests/check_workflow_startup_safety.py
|
|
python ./tests/code_coverage_tests/check_workflow_job_name_collisions.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_workflow_job_name_collisions.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_unit_passed_gate.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_scan_bundled_crypto.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_e2e_idp_stack.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_merge_smoke.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_run_parallel_checks.py
|
|
python ./tests/code_coverage_tests/router_code_coverage.py
|
|
python ./tests/code_coverage_tests/router_surface_check.py
|
|
python ./tests/code_coverage_tests/test_chat_completion_imports.py
|
|
python ./tests/code_coverage_tests/info_log_check.py
|
|
python ./tests/code_coverage_tests/check_guardrail_apply_decorator.py
|
|
python ./tests/code_coverage_tests/test_ban_set_verbose.py
|
|
python ./tests/code_coverage_tests/code_qa_check_tests.py
|
|
python ./tests/code_coverage_tests/check_get_model_cost_key_performance.py
|
|
python ./tests/code_coverage_tests/callback_manager_test.py
|
|
python ./tests/code_coverage_tests/recursive_detector.py
|
|
python ./tests/code_coverage_tests/test_router_strategy_async.py
|
|
python ./tests/code_coverage_tests/litellm_logging_code_coverage.py
|
|
python ./tests/code_coverage_tests/ensure_async_clients_test.py
|
|
python ./tests/code_coverage_tests/prevent_key_leaks_in_exceptions.py
|
|
python ./tests/code_coverage_tests/check_unsafe_enterprise_import.py
|
|
python ./tests/code_coverage_tests/check_telemetry_imports.py
|
|
python ./tests/code_coverage_tests/ban_copy_deepcopy_kwargs.py
|
|
python ./tests/code_coverage_tests/check_fastuuid_usage.py
|
|
python ./tests/code_coverage_tests/check_py310_typing_imports.py
|
|
python ./tests/code_coverage_tests/check_e2e_no_raw_requests.py
|
|
python ./tests/code_coverage_tests/check_router_constructor_stub.py
|
|
python ./tests/code_coverage_tests/check_no_none_string_error_fields.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_check_no_none_string_error_fields.py
|
|
python ./tests/code_coverage_tests/check_no_publicly_known_master_key.py
|
|
pytest -q --noconftest -p no:cacheprovider -c /dev/null tests/code_coverage_tests/test_check_no_publicly_known_master_key.py
|
|
python ./tests/code_coverage_tests/check_unbounded_in_lists.py
|
|
python ./tests/code_coverage_tests/memory_test.py
|
|
python ./tests/documentation_tests/test_env_keys.py
|
|
uv tool run --from 'semgrep==1.157.0' semgrep scan --config .github/semgrep/rules --exclude docs/my-website . --error
|
|
uv run --no-project --with 'pytest==9.0.2' pytest tests/code_coverage_tests/test_no_hardcoded_secrets.py -v
|
|
EOF
|
|
|
|
- name: Run ggshield secret scan
|
|
env:
|
|
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
|
|
run: |
|
|
if [ -n "$GITGUARDIAN_API_KEY" ]; then
|
|
retry() { "$@" || { sleep 15; "$@"; } || { sleep 30; "$@"; }; }
|
|
retry git fetch --no-tags --unshallow origin
|
|
uv tool run --from 'ggshield==1.48.0' ggshield --config-path .github/gitguardian.yaml secret scan repo .
|
|
else
|
|
echo "GITGUARDIAN_API_KEY not set, skipping ggshield scan"
|
|
fi
|
|
lint-passed:
|
|
name: lint passed
|
|
needs: [plan, python, typecheck, e2e-harness, ui, ui-api-types, code-quality]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 2
|
|
permissions: {}
|
|
steps:
|
|
- name: Require every lint job to succeed
|
|
env:
|
|
NEEDS: ${{ toJSON(needs) }}
|
|
run: |
|
|
jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<< "$NEEDS"
|
|
jq -e '(.plan.outputs.skipped // "[]" | fromjson) as $skipped
|
|
| all(to_entries[]; .value.result == "success" or (.value.result == "skipped" and (.key | IN($skipped[]))))' <<< "$NEEDS" > /dev/null
|