Repository navigation
ci(unit): stop the full history clone on the db-and-spend shard, fetch the schema merge base by sha - #50120
Conversation
…ck instead of cloning full history
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
bugbot run |
[Low impact] The changes affect one unit-test shard's checkout and schema-check steps. The two outstanding repository test requirements must be addressed before merging FindingsSummaryThe PR replaces the full-history checkout on
Reviews (3) · Last reviewed commit: "ci(unit): keep the setup ceiling at 35 m..." · Reviewed by Greptile |
| source: Final = parser.add_mutually_exclusive_group(required=True) | ||
| source.add_argument("--base-ref", help="compare against the merge base of HEAD and this ref (needs history)") | ||
| source.add_argument("--base-commit", help="compare against this commit as is (works in a shallow clone)") | ||
| options: Final = TypeAdapter(dict[str, str | None]).validate_python(vars(parser.parse_args())) | ||
| base_commit: Final = options["base_commit"] | ||
| base: Final = base_commit if base_commit else _merge_base(options["base_ref"] or "") |
There was a problem hiding this comment.
Required regression tests are missing
AGENTS.md requires regression tests before merging. Existing tests bypass main. Test that --base-commit works without history and rejects a removed field
Context Used: AGENTS.md (source)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…llback and register it with the merge-base step test
|
bugbot run |
| def _schema_base_commit_and_its_type_in_the_checkout(run: StepRun) -> tuple[str, str]: | ||
| argv: Final = _argv_recorded(run.runner, "uv") | ||
| base_commit: Final = argv[argv.index("--base-commit") + 1] | ||
| return base_commit, _git(run.runner.checkout, "cat-file", "-t", base_commit).strip() |
There was a problem hiding this comment.
This consumer runs Git through _git, violating tests/unit/AGENTS.md's no-subprocess rule. Move this check outside tests/unit before merging
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…r took over 33 seconds
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0e2a676. Configure here.
Handwritten 1-3 sentence description
The db-and-spend unit shard was the only one cloning the whole repo (2.8 GB of git objects) and it kept dying at checkout after 10 minutes before a single test ran. The full clone existed only so the schema compatibility script could find the merge base, so the job now asks GitHub for that sha, fetches that one commit, and clones one commit like every other shard
Details
TLDR
Problem this solves:
How it solves it:
fetch-depth: 1with the 3 minute cap, same as the other shardsCheck schema.prisma against the merge base, PR events on db-and-spend only, 3 minute capgit fetch --depth=1 origin <sha>ui-unitdoescheck_schema_compatibility.pygains--base-commit <sha>next to--base-reftest_lint_workflow_diff_gates.py, which runs it against a fake upstreamInstall dependenciescap goes from 8 to 5 minutes so the setup ceilingcheck_workflow_startup_safety.pysums stays at 35. That step took 33 s at most over the last 246 main jobs, median 12 sUser Flow
Before: a contributor's PR goes red on
unit / db-and-spendwithout any test outputunit / db-and-spendred after 10 minutesactions/checkoutwith the step timed out, no pytest output anywhereAfter: the same shard checks out in seconds and only fails on a real test or schema break
unit / db-and-spendchecks out one commit in under 30 s like the other shardsSchema compatibility passed against merge base <sha>and the 7 test files runschema.prismastill fails the step withBreaking: Field <Model>.<field> was removedPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreScreenshots / Proof of Fix
E2E exception at 0e2a676. Scope is one workflow step, the argument parsing of one CI script and one consumer entry in the workflow test, no proxy code changes, so the proof is the exact commands the job now runs, in a real one-commit clone, plus the job itself on this PR
Dry run in a fresh
git clone --depth=1of this branch (git rev-list --count HEADprints 1), using the head of #50118 as the PR headgh api repos/BerriAI/litellm/compare/main...ff624cdd2b --jq .merge_base_commit.sha->1967b41368833ea4c9a150a74e4c71df7246060dgit merge-base HEAD 1967b413...in that clone ->fatal: Not a valid commit name, which is why the old--base-refpath cannot work without historygit fetch --no-tags --depth=1 origin 1967b413...-> 11 spython scripts/check_schema_compatibility.py --base-commit 1967b413...->Schema compatibility passed against merge base 1967b413..., exit 0budget_durationfromLiteLLM_BudgetTableinschema.prisma, run step 4 again ->Breaking: Field LiteLLM_BudgetTable.budget_duration was removed, exit 1The
unit / db-and-spendjob on this PR at e7eac43 (job 126899653336): checkout 4 s, install plus schema step 10 s withSchema compatibility passed against merge base 9703e01c...in the log, tests 154 s, green. Before this PR the same checkout was 108 s at the median and up to 461 stests/unit/test_lint_workflow_diff_gates.pydiscovers every workflow step that readsmerge_base_commitand runs it against a fake upstream, including a rerun after the base branch was deleted, renamed, or retargeted. Without the consumer entry the six new cases fail withKeyError: 'test-unit.yml:unit', with it113 passed in 13.69stogether withtest_unit_shard_per_test_timeout.pyandtest_assert_ci_coverage.py.tests/code_coverage_tests/check_workflow_startup_safety.pyprintsWorkflow startup invariants hold (setup ceiling 35m)In the full checkout,
--base-ref origin/mainstill works unchanged, running with neither flag exits withone of the arguments --base-ref --base-commit is required.ruff check,ruff format --checkandbasedpyrightare clean on the script (the oldoptions.base_refread was areportAny, the new typed mapping removes it)Type
🚄 Infrastructure
Caveats (if any)
Low
stable/**,rc/**andlts/**workflow_dispatchruns skip the step instead of diffing the schema against itselfgithub.token, the same calls the UI unit test step already makesmain()of the script shells out to git, so its--base-commitpath is covered by the workflow test with a recordeduvargv, not by a unit test of the functionuv sync. The worst observed over 246 recent main jobs was 33 sFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/a353beb13ddd45f79cf8333fdbc421ad
Open in Devin Desktop: https://app.devin.ai/desktop/session/a353beb13ddd45f79cf8333fdbc421ad?variant=devin
Requested by: @kerry-berri
Note
Low Risk
CI-only changes to checkout depth and how the Prisma schema gate obtains its base commit; runtime product behavior is unchanged.
Overview
Fixes db-and-spend unit CI failing on checkout timeouts by dropping the full-repo clone that existed only to resolve a merge base for
schema.prismachecks.Workflow (
test-unit.yml): All unit shards now usefetch-depth: 1and a 3-minute checkout timeout (no special 10-minute / full-history path for db-and-spend). Schema validation moves out of the install step intoCheck schema.prisma against the merge base, which runs only on pull requests for the db-and-spend shard. That step resolves the merge base via the GitHub compare API,git fetch --depth=1that SHA, then runs the compatibility script with--base-commit. Pushes to main no longer run this check.scripts/check_schema_compatibility.py: Adds--base-commit(direct SHA, shallow-clone friendly) as an alternative to--base-ref(still usesgit merge-basewhen history exists).Tests: Registers
test-unit.yml:unitintest_lint_workflow_diff_gates.pyso merge-base workflow steps stay covered against a fake upstream.Reviewed by Cursor Bugbot for commit 0e2a676. Bugbot is set up for automated code reviews on this repo. Configure here.