Skip to content

ci(unit): shallow checkout for db-and-spend shard - #49959

Closed
mateo-berri wants to merge 2 commits into
mainfrom
litellm_ci_db_and_spend_shallow_checkout
Closed

mateo-berri wants to merge 2 commits into
mainfrom
litellm_ci_db_and_spend_shallow_checkout

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

<make-me-human-readable>
The database and spend unit tests kept failing before running anything, because their checkout tried to download every branch and tag of the repo and hit the 10 minute limit. This makes that checkout a single commit like every other shard, then fetches only the default branch's commit history right before the schema check that needs it
</make-me-human-readable>

Details

TLDR

Problem this solves:

  • db-and-spend times out in actions/checkout on PRs and main
  • fetch-depth: 0 pulls about 4.3k branches and 1.6k tags

How it solves it:

  • Check out db-and-spend with fetch-depth: 1 and a 3 minute limit
  • Treeless fetch of the default branch plus HEAD ancestry before the schema check
  • git show lazily downloads the one schema.prisma blob it needs

User Flow

Before: an engineer opens a PR and unit passed goes red with no test run

  1. They push a PR to BerriAI/litellm
  2. db-and-spend sits in "Fetching the repository" for 10 minutes and times out
  3. unit passed fails, so the PR can't merge until someone reruns it

After: the same PR gets a real db-and-spend result

  1. They push a PR to BerriAI/litellm
  2. db-and-spend checks out one commit in seconds, then fetches main's history for the schema check
  3. The shard runs its tests and unit passed reflects the real result

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<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
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

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

E2E exception at e58398a. The diff only changes the checkout and adds one git fetch inside the existing schema-check step in .github/workflows/test-unit.yml, so a fresh-repo simulation of the exact git commands plus this PR's own CI run of db-and-spend is the proof

Recent failures this fixes, both stuck in "Fetching the repository" until the 10 minute timeout: PR job https://github.com/BerriAI/litellm/actions/runs/41715207126/job/126231091432 and main job https://github.com/BerriAI/litellm/actions/runs/41704173852/job/126156530705

Simulation in a fresh git init against public https://github.com/BerriAI/litellm

  1. git fetch --no-tags --depth=1 origin refs/pull/49919/merge finished in 13.51s
  2. git fetch --no-tags --filter=tree:0 --unshallow origin '+refs/heads/main:refs/remotes/origin/main' "$(git rev-parse HEAD)" finished in 9.15s
  3. python scripts/check_schema_compatibility.py --base-ref origin/main printed Schema compatibility passed against merge base e1c03c54233ba92412ea481e06d619604b9eeb5d in 1.24s
  4. Old scope (all branches and tags plus the merge sha) in another fresh repo was still running at 300s and was killed

On this PR's CI, db-and-spend checkout took 11s, the fetch took 3.24s, the schema check passed and the shard ran 36 passed, 12 skipped (https://github.com/BerriAI/litellm/actions/runs/41732726507/job/126255027064)

Every test that reads test-unit.yml passed at this sha, the startup safety check held, and the zizmor check passed (https://github.com/BerriAI/litellm/actions/runs/41732726855/job/126253959951)

Workflow test commands and output
$ uv run --no-sync pytest tests/unit/test_unit_shard_per_test_timeout.py tests/unit/test_unit_shard_missing_paths.py tests/unit/test_assert_ci_coverage.py tests/unit/test_detect_changes.py tests/unit/test_assert_workflow_dir_hygiene.py tests/unit/test_lint_workflow_diff_gates.py tests/code_coverage_tests/test_unit_passed_gate.py tests/code_coverage_tests/test_workflow_job_name_collisions.py -q -p no:cacheprovider
223 passed in 177.07s (0:02:57)
$ uv run --no-sync pytest tests/unit/test_circleci_path_filter.py tests/unit/test_select_ui_test_scope.py -q -p no:cacheprovider
89 passed in 27.85s
$ uv run --no-sync python tests/code_coverage_tests/check_workflow_startup_safety.py
Workflow startup invariants hold (setup ceiling 35m)
$ uv run --no-sync python tests/code_coverage_tests/check_workflow_job_name_collisions.py
Check-run names are unique across 40 workflows

Type

🚄 Infrastructure

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

Link to Devin session: https://app.devin.ai/sessions/01c77b8f7f444a4f8092ba1b865424cf
Open in Devin Desktop: https://app.devin.ai/desktop/session/01c77b8f7f444a4f8092ba1b865424cf?variant=devin
Requested by: @mateo-berri

  • e58398a passes /live-pr-risk (E2E exempt)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri
mateo-berri requested a review from a team November 3, 2026 22:21
@devin-ai-integration

devin-ai-integration Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

Closing in favor of #50120, which is merged and gives db-and-spend the same one-commit checkout plus a merge base fetch and a workflow test

@mateo-berri mateo-berri closed this Nov 4, 2026
@mateo-berri
mateo-berri deleted the litellm_ci_db_and_spend_shallow_checkout branch November 4, 2026 22:57
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.

1 participant