mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
* fix(ci): make every remaining CI checkout shallow PR #35982 only covered the lint and budget-ratchet jobs, so secret-scan kept spending minutes fetching every branch inside its 5 minute timeout and PRs kept getting cancelled. The UI lint and UI unit jobs carried the same fetch-depth 0 checkout secret-scan now checks out at depth 1, runs the hardcoded-secret pytest without building the project environment, and lets the ggshield step deepen history itself when a key is configured. UI lint resolves the merge base through the API instead of local history. UI unit tests compute the changed files the same way and feed them to vitest related, because vitest --changed does a three-dot diff that silently selects zero tests on a shallow clone The daily branch creation workflows also did full checkouts, then failed every run since persist-credentials: false left git push with no credentials. They now create the ref through the GitHub API without a checkout at all * fix(ci): feed deleted UI files into vitest related selection vitest --changed fed git's full change list to the related filter, deletions included, so a deletion-only dashboard PR still selected the tests importing the removed files. Keep that behavior by dropping the diff filter and existence guard; vitest resolves nonexistent paths fine and --passWithNoTests covers the nothing-related case
70 lines
2.3 KiB
YAML
70 lines
2.3 KiB
YAML
name: UI Unit Tests
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- litellm_internal_staging
|
|
- litellm_oss_staging
|
|
- "litellm_**"
|
|
push:
|
|
branches:
|
|
- litellm_internal_staging
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
ui-unit-tests:
|
|
runs-on: ubuntu-latest-16-cores
|
|
timeout-minutes: 20
|
|
defaults:
|
|
run:
|
|
working-directory: ui/litellm-dashboard
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version-file: ui/litellm-dashboard/.nvmrc
|
|
cache: "npm"
|
|
cache-dependency-path: ui/litellm-dashboard/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run UI unit tests (Vitest)
|
|
env:
|
|
CI: "true"
|
|
GH_TOKEN: ${{ github.token }}
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
if [ -n "$BASE_SHA" ]; then
|
|
merge_base=$(gh api "repos/${{ github.repository }}/compare/${BASE_SHA}...${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"
|
|
changed_files=()
|
|
while IFS= read -r f; do
|
|
changed_files+=("$f")
|
|
done < <(git diff --name-only --relative "$merge_base" "$HEAD_SHA" -- .)
|
|
if [ ${#changed_files[@]} -eq 0 ]; then
|
|
echo "No UI files changed in this PR; skipping unit tests."
|
|
exit 0
|
|
fi
|
|
echo "Pull request: running tests related to ${#changed_files[@]} changed UI files"
|
|
npm run test -- related "${changed_files[@]}" --run --passWithNoTests \
|
|
--pool forks --poolOptions.forks.maxForks=14
|
|
else
|
|
echo "Push to $GITHUB_REF_NAME: running the full suite"
|
|
npm run test -- --run --pool forks --poolOptions.forks.maxForks=14
|
|
fi
|