litellm/.github/actions/rust-bridge/action.yml
Yujong Lee 93dd636fe6
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
ci: cache the built Rust bridge and reuse it in every uv sync job
The rust-bridge action without artifact now restores the editable wheel and _native keyed per OS on Rust sources and build config, building on a miss and saving only on main. Jobs that run uv sync install the cached bridge through uv_sync_with_rust_bridge.sh instead of compiling it inside uv sync
2026-10-19 10:46:44 -07:00

45 lines
2 KiB
YAML

name: Set up the Rust bridge
description: >-
Fill rust-bridge-dist with the editable Rust bridge wheel and native module, and
install them with .github/scripts/uv_sync_with_rust_bridge.sh.
Restore the build for the current Rust sources, so most commits, which leave Rust
untouched, skip Cargo entirely. Only main saves it. A miss builds on cache-cargo-build, so
Cargo rebuilds only what changed. Requires Python and uv on the PATH.
runs:
using: composite
steps:
- name: Restore the Rust bridge build
id: restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: rust-bridge-dist
key: ${{ runner.os }}-rust-bridge-editable-${{ hashFiles('litellm-rust/Cargo.lock', 'litellm-rust/Cargo.toml', 'litellm-rust/crates/**', 'pyproject.toml', 'rust-toolchain.toml', '.cargo/config.toml') }}
- name: Restore the Cargo build cache
if: steps.restore.outputs.cache-hit != 'true'
uses: ./.github/actions/cache-cargo-build
- name: Build the Rust bridge
if: steps.restore.outputs.cache-hit != 'true'
shell: bash
env:
RUNNER_OS_NAME: ${{ runner.os }}
run: |
rm -rf rust-bridge-dist
mkdir -p rust-bridge-dist/litellm/rust_bridge
uv run --no-project --with maturin==1.15.0 python -c 'import maturin; maturin.build_editable("rust-bridge-dist")'
for native in litellm/rust_bridge/_native.abi3.so litellm/rust_bridge/_native.pyd; do
[ -f "$native" ] || continue
if [ "$RUNNER_OS_NAME" = "Linux" ]; then
strip --strip-debug "$native"
fi
cp "$native" rust-bridge-dist/litellm/rust_bridge/
done
- name: Save the Rust bridge build
if: steps.restore.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: rust-bridge-dist
key: ${{ steps.restore.outputs.cache-primary-key }}