The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
perf(ci): cache the Rust build the unit shards compile from scratch (#37795)
yuneng-jiangafec9b8ab901
diff --git a/.github/actions/cache-cargo-build/action.yml b/.github/actions/cache-cargo-build/action.ymlnew file mode 100644index 00000000000..36c6c790b84--- /dev/null+++ b/.github/actions/cache-cargo-build/action.yml@@ -0,0 +1,31 @@+name: "Cache the Rust build"+description: >-+ Cache the Cargo registry and target directory the root package's build needs,+ so only the first job on a given Cargo.lock compiles the bridge from scratch.++ litellm builds through maturin, which compiles litellm-rust/crates/python-bridge+ in release mode before it can produce a wheel. `uv sync` therefore pays a full+ build in every job that installs the workspace: measured at 2m40s per unit shard+ on 2026-08-21, more than the whole unit tier spends running tests. Nothing caught+ it, because the uv cache holds wheels uv downloads rather than wheels it builds,+ and a path dependency whose source moves every commit could never hit that cache+ anyway. Cargo rebuilds only what changed when its target directory survives, so a+ warm job pays for the bridge crate alone.++ The key namespace is separate from test-rust.yml's. Both cache the same directory,+ but that workflow fills it with debug and clippy artifacts, which a release build+ cannot reuse, and a shared key would let whichever ran first deny the other a save.++runs:+ using: composite+ steps:+ - name: Restore the Cargo registry and target directory+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ litellm-rust/target+ key: ${{ runner.os }}-cargo-release-${{ hashFiles('litellm-rust/Cargo.lock') }}+ restore-keys: |+ ${{ runner.os }}-cargo-release-diff --git a/.github/workflows/_test-unit-base.yml b/.github/workflows/_test-unit-base.ymlindex 54f50524a39..b7d185bd0b9 100644--- a/.github/workflows/_test-unit-base.yml+++ b/.github/workflows/_test-unit-base.yml@@ -27,7 +27,7 @@ on:default: 20job-timeout-minutes:description: >-- Backstop for the whole job. Keep it >= `timeout-minutes` plus 35: 30 for+ Backstop for the whole job. Keep it >= `timeout-minutes` plus 40: 35 forthe per-step ceilings on the setup steps below, and 5 for the runneroverhead the job clock charges but no step owns (job init, steptransitions, post-job cleanup). That headroom is what makes the test@@ -36,7 +36,7 @@ on:arithmetic, so the sum is passed in rather than computed.required: falsetype: number- default: 55+ default: 60max-failures:description: "Stop after this many failures"required: false@@ -103,6 +103,11 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ if: steps.changes.outputs.decision != 'skip'+ timeout-minutes: 5+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesif: steps.changes.outputs.decision != 'skip'timeout-minutes: 8diff --git a/.github/workflows/check-ui-api-types.yml b/.github/workflows/check-ui-api-types.ymlindex dbd663a2efa..285676a0ddd 100644--- a/.github/workflows/check-ui-api-types.yml+++ b/.github/workflows/check-ui-api-types.yml@@ -67,6 +67,10 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ if: steps.changes.outputs.relevant == 'true'+ uses: ./.github/actions/cache-cargo-build+- name: Install backend dependenciesif: steps.changes.outputs.relevant == 'true'run: .github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-routerdiff --git a/.github/workflows/mutation-test.yml b/.github/workflows/mutation-test.ymlindex 68317d5dd12..602c26a3e98 100644--- a/.github/workflows/mutation-test.yml+++ b/.github/workflows/mutation-test.yml@@ -53,6 +53,9 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesrun: |.github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-router --extra samldiff --git a/.github/workflows/publish-basedpyright-base-counts.yml b/.github/workflows/publish-basedpyright-base-counts.ymlindex 71e196d8361..cd443a8e9db 100644--- a/.github/workflows/publish-basedpyright-base-counts.yml+++ b/.github/workflows/publish-basedpyright-base-counts.yml@@ -43,6 +43,9 @@ jobs:with:version: "0.10.9"+ - name: Cache the Rust build+ uses: ./.github/actions/cache-cargo-build+- name: Cache Prisma binariesuses: ./.github/actions/cache-prisma-binariesdiff --git a/.github/workflows/test-code-quality.yml b/.github/workflows/test-code-quality.ymlindex 8f62837d29a..2a832d1956e 100644--- a/.github/workflows/test-code-quality.yml+++ b/.github/workflows/test-code-quality.yml@@ -56,6 +56,9 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesrun: uv sync --frozen --all-groups --all-extrasdiff --git a/.github/workflows/test-linting.yml b/.github/workflows/test-linting.ymlindex e031ba46773..ccb58f5cc9c 100644--- a/.github/workflows/test-linting.yml+++ b/.github/workflows/test-linting.yml@@ -78,6 +78,10 @@ jobs:run: |uv lock --check || (echo "❌ uv.lock is out of sync with pyproject.toml. Run 'uv lock' locally and commit the result." && exit 1)+ - name: Cache the Rust build+ if: steps.changes.outputs.decision != 'skip'+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesif: steps.changes.outputs.decision != 'skip'run: |diff --git a/.github/workflows/test-mcp.yml b/.github/workflows/test-mcp.ymlindex 95187ef2835..6ea814dc2de 100644--- a/.github/workflows/test-mcp.yml+++ b/.github/workflows/test-mcp.yml@@ -47,6 +47,10 @@ jobs:with:version: "0.10.9"+ - name: Cache the Rust build+ if: steps.changes.outputs.decision != 'skip'+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesif: steps.changes.outputs.decision != 'skip'run: |diff --git a/.github/workflows/test-terraform-provider.yml b/.github/workflows/test-terraform-provider.ymlindex 7ea22825f4f..e46432e0e31 100644--- a/.github/workflows/test-terraform-provider.yml+++ b/.github/workflows/test-terraform-provider.yml@@ -88,6 +88,9 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesrun: |.github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-routerdiff --git a/.github/workflows/test-unit-documentation.yml b/.github/workflows/test-unit-documentation.ymlindex cb8035aafa1..90b6b28374e 100644--- a/.github/workflows/test-unit-documentation.yml+++ b/.github/workflows/test-unit-documentation.yml@@ -67,6 +67,10 @@ jobs:restore-keys: |${{ runner.os }}-uv-+ - name: Cache the Rust build+ if: steps.changes.outputs.decision != 'skip'+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesif: steps.changes.outputs.decision != 'skip'run: |diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.ymlindex 3d6fffe7304..71eb0958bec 100644--- a/.github/workflows/test-unit.yml+++ b/.github/workflows/test-unit.yml@@ -55,7 +55,7 @@ jobs:workers: 2reruns: 1timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: enterprise-routingartifact-name: enterprise-routing@@ -67,7 +67,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: integrationsartifact-name: integrations@@ -75,7 +75,7 @@ jobs:workers: 2reruns: 3timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: Vertex AIartifact-name: llm-vertex-ai@@ -83,7 +83,7 @@ jobs:workers: 1reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: All Other Providersartifact-name: llm-other-providers@@ -91,7 +91,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: miscartifact-name: misc@@ -122,7 +122,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: proxy-authartifact-name: proxy-auth@@ -134,7 +134,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: proxy-endpointsartifact-name: proxy-endpoints@@ -171,7 +171,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: proxy-serverartifact-name: proxy-server@@ -179,7 +179,7 @@ jobs:workers: 4reruns: 2timeout-minutes: 60- job-timeout-minutes: 95+ job-timeout-minutes: 100- shard: proxy-infraartifact-name: proxy-infra@@ -198,7 +198,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60- shard: responses-caching-typesartifact-name: responses-caching-types@@ -209,7 +209,7 @@ jobs:workers: 2reruns: 2timeout-minutes: 20- job-timeout-minutes: 55+ job-timeout-minutes: 60uses: ./.github/workflows/_test-unit-base.ymlwith:test-path: ${{ matrix.test-path }}diff --git a/.github/workflows/weekly_load_anomaly.yml b/.github/workflows/weekly_load_anomaly.ymlindex 2dffc889d0e..3e1fca89645 100644--- a/.github/workflows/weekly_load_anomaly.yml+++ b/.github/workflows/weekly_load_anomaly.yml@@ -47,6 +47,9 @@ jobs:with:version: "0.10.9"+ - name: Cache the Rust build+ uses: ./.github/actions/cache-cargo-build+- name: Install dependenciesrun: |.github/scripts/uv_sync_with_retries.sh --frozen --group ci --group proxy-dev --extra proxy