litellm/.github/actions/restore-rust-bridge/action.yml
Kerry Lu 8f33d6c154
Revert "ci: reuse Rust bridge builds across PR pushes and refresh the Cargo cache (#52718)" (#52770)
This reverts commit b0c734ff6e.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-18 23:07:25 -08:00

55 lines
2.2 KiB
YAML

name: "Restore the Rust bridge"
description: >-
Restore the prebuilt Rust bridge that the unit workflow's rust-bridge job saves
on main, keyed on every input of the Rust build.
The bridge is abi3, so one build serves every supported Python version. A job
whose Rust inputs match main installs the restored wheel and native library
instead of compiling them inside `uv sync`. On a miss the caller builds from
source as before.
The restored `rust-bridge-dist` directory holds the editable litellm wheel, the
litellm-proxy gateway wheel, and `litellm/rust_bridge/_native.abi3.so`.
inputs:
stale-cost-map:
description: >-
'true' to fall back to a bridge built from the same Rust inputs whose embedded
cost map is older, for a pull request that changes only the cost map
required: false
default: "false"
outputs:
key:
description: "Cache key for the bridge built from this checkout"
value: ${{ steps.key.outputs.key }}
cache-hit:
description: "'true' when the bridge for this exact key was restored"
value: ${{ steps.restore.outputs.cache-hit }}
restored:
description: "'true' when a bridge was restored, by exact key or by the stale cost map fallback"
value: ${{ steps.restore.outputs.cache-matched-key != '' }}
runs:
using: composite
steps:
- name: Define the Rust bridge cache key
id: key
shell: bash
env:
RUST_INPUTS: ${{ runner.os }}-rust-bridge-editable-${{ hashFiles('litellm/rust/Cargo.lock', 'litellm/rust/Cargo.toml', 'litellm/rust/crates/**', 'pyproject.toml', 'litellm/packaging/litellm-proxy/pyproject.toml') }}
COST_MAP: ${{ hashFiles('model_prices_and_context_window.json') }}
STALE_COST_MAP: ${{ inputs.stale-cost-map }}
run: |
echo "key=${RUST_INPUTS}-${COST_MAP}" >> "$GITHUB_OUTPUT"
if [ "${STALE_COST_MAP}" = true ]; then
echo "fallback=${RUST_INPUTS}-" >> "$GITHUB_OUTPUT"
fi
- name: Restore the Rust bridge
id: restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: rust-bridge-dist
key: ${{ steps.key.outputs.key }}
restore-keys: ${{ steps.key.outputs.fallback }}