Skip to content

perf(ci): gate the lint, MCP and dashboard jobs on the pull request's file list - #37559

Merged
yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_/workflow-test-triggering-8faffb
Aug 20, 2026
Merged

yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_/workflow-test-triggering-8faffb

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Lint and the MCP suite take the existing backend decision
  • Dashboard build and unit tests take a new ui decision
  • CI config counts as ui-relevant, so those workflows self-test
  • Setup steps that leaked past the gate now carry it

User Flow

Before: a contributor opens a dashboard-only pull request and waits on Python jobs that cannot see their change

  1. They push a branch touching only ui/litellm-dashboard/** and open a PR against litellm_internal_staging
  2. The backend shards go green in seconds, because fix(ci): gate backend unit tests on the pull request's own file list #37550 already gates them
  3. lint still runs for 6 to 7 minutes: it installs uv, generates a Prisma client and runs ruff and basedpyright over litellm/
  4. test still runs the MCP suite for about 4 minutes, code-quality and validate-model-prices-json add 6 more
  5. Their checks tab stays busy for roughly 7 minutes on work no dashboard file can affect

After: the same pull request settles as soon as the dashboard jobs finish

  1. They push the same branch and open the same PR
  2. lint and test report success in under a minute, having installed nothing
  3. build-ui, ui-unit-tests and frontend-lint still run in full, because the change is theirs to check
  4. The reverse also holds: a backend-only PR now skips build-ui and ui-unit-tests instead of running npm ci and a full Next build

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Both sides run the gate against three real pull requests through the live GitHub API, with the file counts the API reports for them: #37553 touches 45 files, all under ui/; #37545 touches 1 file, .gitignore; #37528 touches 2 markdown files. backend is the decision lint, test and the shards consume, ui is the one build-ui and ui-unit-tests consume

Before (a6163e0)

Dashboard-only pull request (#37553)

  1. Ask for both decisions at the merge base:
git worktree add --detach /tmp/gate-before a6163e01466303bc522b408ac5b1d9efd0e3248c
cd /tmp/gate-before
REPO=BerriAI/litellm PR_NUMBER=37553 CHANGED_FILE_COUNT=45 \
  bash .github/scripts/detect_backend_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37553 CHANGED_FILE_COUNT=45 CATEGORY=ui \
  bash .github/scripts/detect_backend_changes.sh | tail -1
  1. There is only one decision, and asking for ui returns the backend answer because the category does not exist:
detect-backend-changes: decision=skip
detect-backend-changes: decision=skip
  1. lint and test never read that decision at all, so both ran in full. On this pull request lint took 6 minutes 6 seconds and test took 4 minutes 24 seconds

  2. A skipped shard still did setup work. misc / Run tests on this pull request, 23 seconds end to end:

      1s  success   Set up job
      5s  success   Run actions/checkout
      0s  success   Detect backend-relevant changes
      1s  success   Set up Python
      5s  success   Set up uv
      7s  success   Cache uv dependencies
      0s  skipped   Install dependencies
      0s  skipped   Run tests

Backend-only pull request (#37545, .gitignore)

  1. Ask for both decisions:
cd /tmp/gate-before
REPO=BerriAI/litellm PR_NUMBER=37545 CHANGED_FILE_COUNT=1 \
  bash .github/scripts/detect_backend_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37545 CHANGED_FILE_COUNT=1 CATEGORY=ui \
  bash .github/scripts/detect_backend_changes.sh | tail -1
  1. Both say run, so the dashboard jobs had nothing to skip on:
detect-backend-changes: decision=run
detect-backend-changes: decision=run

Documentation-only pull request (#37528)

  1. Ask for both decisions:
cd /tmp/gate-before
REPO=BerriAI/litellm PR_NUMBER=37528 CHANGED_FILE_COUNT=2 \
  bash .github/scripts/detect_backend_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37528 CHANGED_FILE_COUNT=2 CATEGORY=ui \
  bash .github/scripts/detect_backend_changes.sh | tail -1
  1. Both skip, which is already correct:
detect-backend-changes: decision=skip
detect-backend-changes: decision=skip

After (fb2dab1)

Dashboard-only pull request (#37553)

  1. Ask for both decisions at this branch's tip:
REPO=BerriAI/litellm PR_NUMBER=37553 CHANGED_FILE_COUNT=45 \
  bash .github/scripts/detect_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37553 CHANGED_FILE_COUNT=45 CATEGORY=ui \
  bash .github/scripts/detect_changes.sh | tail -1
  1. The two decisions now differ, and lint and test consume the first one:
detect-changes[backend]: decision=skip
detect-changes[ui]: decision=run
  1. The dashboard jobs still run in full, which is what this pull request is for

Backend-only pull request (#37545, .gitignore)

  1. Ask for both decisions:
REPO=BerriAI/litellm PR_NUMBER=37545 CHANGED_FILE_COUNT=1 \
  bash .github/scripts/detect_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37545 CHANGED_FILE_COUNT=1 CATEGORY=ui \
  bash .github/scripts/detect_changes.sh | tail -1
  1. The dashboard build and unit tests now skip, so npm ci and the Next build stop running for a one-line gitignore change:
detect-changes[backend]: decision=run
detect-changes[ui]: decision=skip

Documentation-only pull request (#37528)

  1. Ask for both decisions:
REPO=BerriAI/litellm PR_NUMBER=37528 CHANGED_FILE_COUNT=2 \
  bash .github/scripts/detect_changes.sh | tail -1
REPO=BerriAI/litellm PR_NUMBER=37528 CHANGED_FILE_COUNT=2 CATEGORY=ui \
  bash .github/scripts/detect_changes.sh | tail -1
  1. Still both skip, so nothing regressed for markdown:
detect-changes[backend]: decision=skip
detect-changes[ui]: decision=skip

This pull request's own checks

  1. It edits .github/ and .circleci/, so both categories say run and every gated job here runs in full. That is the gate refusing to skip the change that rewrites it

Type

🧹 Refactoring
🚄 Infrastructure

Caveats (if any)

  • The gate stays in-job: on.paths would never report a required check
  • A skipped caller job publishes its own name, not the nested one
  • ui deliberately runs on any .github or .circleci change
  • code-quality and validate-model-prices-json are still ungated

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

… file list

PR #37550 taught the backend unit-test shards to read the pull request's own
file list, but four required jobs were never wired to that gate and ran in full
on every pull request regardless of what it touched. A UI-only pull request
still paid roughly 17 runner-minutes of Python work it could not have affected,
and a backend-only one still installed and built the dashboard.

Lint and the MCP suite now take the existing backend decision. The dashboard
build and unit tests take a new ui decision, which tracks ui/ rather than
reusing client: client deliberately runs whenever the backend changes, because
it gates CircleCI's end-to-end jobs that drive a real proxy, while the build and
the unit tests cannot see the backend at all. CI config counts as ui-relevant
too, so a pull request that rewrites the dashboard workflows still exercises
them instead of shipping unvalidated.

The gate stays inside the job rather than moving to on.paths or to a job-level
condition on the shard callers. A workflow filtered out by on.paths never starts
and never reports, so a required check waits forever, and a skipped caller job
publishes its own name instead of the nested "<shard> / Run tests" the ruleset
requires. Both were measured before settling on this shape.

Three setup steps in the shard base and in the documentation job also leaked
past the gate, so a skipped shard still spent about twelve seconds installing uv
and restoring its cache. They now carry the same condition, and the documentation
job stops cloning litellm-docs when it has nothing to validate.
@yuneng-berri
yuneng-berri requested a review from a team August 20, 2026 01:10
@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR generalizes the existing backend change detector into a category-aware gate and applies it to linting, MCP, reusable Python tests, and dashboard workflows.

  • Adds backend, client, and UI classification while failing open when changed files cannot be resolved.
  • Skips setup, execution, and coverage work consistently when a job is irrelevant to the pull request.
  • Adds regression coverage for UI-only, backend-only, documentation-only, CI configuration, and classification-failure cases.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified.

The renamed action has no stale callers, category decisions fail open when uncertain, skipped setup and artifact consumers are gated consistently, and independent API-type synchronization covers backend-driven dashboard schema changes.

Important Files Changed

Filename Overview
.circleci/scripts/classify_changes.sh Adds a UI-specific category while retaining backend/client behavior and treating CI configuration as relevant to self-testing workflows.
.github/actions/detect-changes/action.yml Replaces the backend-only composite action with a category-aware action that preserves the fail-open decision contract.
.github/scripts/detect_changes.sh Generalizes classification to a supplied category, defaults to backend, and retains safe fallback behavior for API or classifier failures.
.github/workflows/_test-unit-base.yml Gates setup, tests, artifact creation, and coverage upload consistently on the shared change decision.
.github/workflows/test-linting.yml Gates the expensive lint job steps on backend relevance while leaving independent ratchet and secret-scanning jobs unchanged.
.github/workflows/test-litellm-ui-build.yml Uses the UI category to avoid installing and building the dashboard for unrelated pull requests.
.github/workflows/test-litellm-ui-unit.yml Gates dashboard setup and tests for pull requests while preserving full execution for non-pull-request events through fail-open behavior.
.github/workflows/test-mcp.yml Gates MCP setup and test execution on backend relevance without changing the workflow status contract.
.github/workflows/test-unit-documentation.yml Moves change detection ahead of the external documentation checkout and consistently skips all dependent setup when irrelevant.
tests/test_litellm/test_circleci_path_filter.py Extends classifier regression coverage for UI, CI configuration, markdown precedence, and backend/UI divergence.
tests/test_litellm/test_detect_changes.py Renames and expands detector tests to cover category selection, default behavior, UI decisions, and fail-open handling.

Reviews (1): Last reviewed commit: "perf(ci): gate the lint, MCP and dashboa..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tin-berri tin-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the CI-gating refactor. The core mechanism holds up: classify_changes.sh now treats .github/** and .circleci/** as CI-relevant for both backend and ui categories (via has_ci=true; has_backend=true), so a PR that edits these workflows always exercises the jobs it changes — verified via test_ci_config_changes_reach_every_category. The ui category correctly diverges from client (which still must run on backend changes for CircleCI's e2e jobs against a real proxy) — good catch calling that out explicitly in both the caveats and test_ui_and_client_diverge_on_a_backend_only_change. Fail-open behavior on API failure/uncertain classification is preserved and tested. The proof-of-fix section is a nice touch — showing before/after decisions against 3 real PRs (#37553 dashboard-only, #37545 gitignore, #37528 docs) is more convincing than synthetic examples. Test coverage is thorough (skip/run/mixed/fail-open/self-referential all covered). All 70 CI checks green, including this PR's own lint, build-ui, and ui-unit-tests running in full since it touches .github/. Small, well-scoped, no auth/billing/security surface.

@yuneng-berri
yuneng-berri enabled auto-merge (squash) August 20, 2026 01:32
@yuneng-berri
yuneng-berri merged commit 7b6e16c into litellm_internal_staging Aug 20, 2026
66 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_/workflow-test-triggering-8faffb branch August 20, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants