fix: stabilize remaining uv migration CI checks

This commit is contained in:
user 2026-04-02 20:44:07 +00:00
parent 070b3428bb
commit a1de99d3f5
No known key found for this signature in database
3 changed files with 32 additions and 27 deletions

View file

@ -25,6 +25,8 @@ RUN for i in 1 2 3; do \
linux-headers \
build-base \
bash \
coreutils \
curl \
openssl \
openssl-dev \
nodejs \
@ -34,7 +36,8 @@ RUN for i in 1 2 3; do \
ENV UV_PROJECT_ENVIRONMENT=/app/.venv \
UV_LINK_MODE=copy \
PATH="/app/.venv/bin:${PATH}" \
NVM_DIR=/root/.nvm \
PATH="/root/.nvm/versions/node/v20.20.2/bin:/app/.venv/bin:${PATH}" \
LITELLM_NON_ROOT=true \
PRISMA_BINARY_CACHE_DIR=/app/.cache/prisma-python/binaries \
PRISMA_CLI_BINARY_TARGETS="debian-openssl-3.0.x" \
@ -45,13 +48,23 @@ COPY . .
# Build Admin UI once and stage the static output for the runtime image.
RUN mkdir -p /var/lib/litellm/ui /var/lib/litellm/assets && \
mv /app/.npmrc /app/.npmrc.bak && \
npm install -g npm@11.12.1 && npm cache clean --force && \
NVM_VERSION="v0.40.4" && \
NVM_CHECKSUM="4b7412c49960c7d31e8df72da90c1fb5b8cccb419ac99537b737028d497aba4f" && \
NODE_VERSION="v20.20.2" && \
NVM_SCRIPT="/tmp/install-nvm.sh" && \
curl -fsSL "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" -o "$NVM_SCRIPT" && \
echo "${NVM_CHECKSUM} ${NVM_SCRIPT}" | sha256sum -c - && \
bash "$NVM_SCRIPT" && \
export NVM_DIR="$HOME/.nvm" && \
. "$NVM_DIR/nvm.sh" && \
nvm install "${NODE_VERSION}" && \
nvm use "${NODE_VERSION}" && \
cd /app/ui/litellm-dashboard && \
if [ -f "/app/enterprise/enterprise_ui/enterprise_colors.json" ]; then \
cp /app/enterprise/enterprise_ui/enterprise_colors.json ./ui_colors.json; \
fi && \
mv .npmrc .npmrc.bak && \
npm ci && \
npm ci --no-audit --no-fund && \
mv .npmrc.bak .npmrc && mv /app/.npmrc.bak /app/.npmrc && \
npm run build && \
cp -r /app/ui/litellm-dashboard/out/* /var/lib/litellm/ui/ && \

View file

@ -1,51 +1,40 @@
import json
import os
import sys
import pytest
from fastapi.testclient import TestClient
sys.path.insert(
0, os.path.abspath("../../../..")
) # Adds the parent directory to the system path
import json
import os
import sys
import time
import pytest
from fastapi.testclient import TestClient
import litellm
def test_check_migration_out_of_sync(mocker):
"""
Test that the check_prisma_schema_diff function
- 🚨 [IMPORTANT] Does NOT Raise an Exception when the Prisma schema is out of sync with the database.
- logs an error when the Prisma schema is out of sync with the database.
"""
# Mock the logger BEFORE importing the function
mock_logger = mocker.patch("litellm._logging.verbose_logger")
# Import the function after mocking the logger
from litellm.proxy.db.check_migration import check_prisma_schema_diff
from litellm.proxy.db import check_migration
# Mock the helper function to simulate out-of-sync state
mock_diff_helper = mocker.patch(
"litellm.proxy.db.check_migration.check_prisma_schema_diff_helper",
mocker.patch.object(
check_migration,
"verbose_logger",
autospec=True,
)
mocker.patch.object(
check_migration,
"check_prisma_schema_diff_helper",
return_value=(True, ["ALTER TABLE users ADD COLUMN new_field TEXT;"]),
)
# Run the function - it should not raise an error
try:
check_prisma_schema_diff(db_url="mock_url")
check_migration.check_prisma_schema_diff(db_url="mock_url")
except Exception as e:
pytest.fail(f"check_prisma_schema_diff raised an unexpected exception: {e}")
# Verify the logger was called with the expected message
mock_logger.exception.assert_called_once()
actual_message = mock_logger.exception.call_args[0][0]
check_migration.verbose_logger.exception.assert_called_once()
actual_message = check_migration.verbose_logger.exception.call_args[0][0]
assert "prisma schema out of sync with db" in actual_message

View file

@ -21,6 +21,7 @@ import pytest
def _run_python(script: str, env_override: dict | None = None) -> subprocess.CompletedProcess:
"""Run a Python script in a subprocess and return the result."""
import os
env = os.environ.copy()
# Remove the var so each test controls it explicitly
env.pop("LITELLM_DISABLE_LAZY_LOADING", None)
@ -32,7 +33,9 @@ def _run_python(script: str, env_override: dict | None = None) -> subprocess.Com
capture_output=True,
text=True,
env=env,
timeout=60,
# Importing litellm can cold-load tiktoken/tokenizer assets and is
# occasionally slow on CI runners; these tests validate behavior, not speed.
timeout=180,
)