litellm/.github/workflows/test-rust.yml
yucheng 77fb630bd3 fix(rust-auth-aws): compute SigV4 in the AWS-LC FIPS module in the fips build
aws-sigv4 hard-wires RustCrypto hmac and sha2 for the SigV4 signing key,
signature and payload hash, with no hook to swap them. It is patched to
the vendored 1.5.3 copy, whose new fips feature computes those three
functions through aws-lc-rs. Every bridge signing path goes through them,
including Bedrock and the other SigV4 providers, the explicit AWS login
for Vertex, S3 logging, ElastiCache IAM, and the STS, Secrets Manager,
KMS and S3 SDK clients.

litellm-auth-aws gets a fips feature that turns it on, and computes its
own SHA-256 (botocore Date-header signing, the S3 logging payload hash)
through aws-lc-rs too. The bridge's fips feature enables it. The default
build compiles exactly the code it did before.

An aws-sigv4 bump that the vendored copy cannot satisfy now fails cargo
resolution, since the registry crate has no fips feature.
2026-11-25 06:46:38 -08:00

195 lines
6.8 KiB
YAML

name: LiteLLM Rust
on:
schedule:
- cron: "5 8-20/3 * * 1-6"
timezone: America/Los_Angeles
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
- "litellm_**"
- "rc/**"
- "stable/**"
- "lts/**"
paths:
- "litellm/rust/**"
- "model_prices_and_context_window.json"
- "litellm/rust_bridge/**"
- "litellm/scripts/generate_trace_types.py"
- "litellm/scripts/trace_codegen/**"
- "litellm/scripts/lens_assets/**"
- "litellm/integrations/lens/**"
- "tests/test_litellm_rust/**"
- "litellm/integrations/custom_logger.py"
- "litellm/litellm_core_utils/litellm_logging.py"
- "litellm/litellm_core_utils/logging_worker.py"
- "litellm/proxy/guardrails/**"
- "litellm/utils.py"
- "litellm/ocr/**"
- "litellm/chat_completions/dispatch.py"
- "litellm/embeddings/dispatch.py"
- "litellm/messages/dispatch.py"
- "litellm/responses/dispatch.py"
- "litellm/llms/base_llm/ocr/**"
- "litellm/llms/custom_httpx/llm_http_handler.py"
- "Makefile"
- "litellm/rust/.cargo/**"
- "pyproject.toml"
- "uv.lock"
- "litellm/rust/rust-toolchain.toml"
- ".github/actions/setup-uv-with-retries/**"
- ".github/scripts/smoke_test_native_wheel.py"
- ".github/scripts/verify_linux_native_wheel.py"
- "tests/unit/rust_bridge/native_route_wheel_test.py"
- ".github/workflows/test-rust.yml"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.event.action == 'labeled' && github.event.label.name || 'code' }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
jobs:
rust-lint:
if: github.event.action != 'labeled' || github.event.label.name == 'rust-tests'
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: litellm/rust
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- name: Configure the Rust build environment
working-directory: .
run: bash .github/scripts/setup_rust_environment.sh
- run: cargo fmt --all --check
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
workspaces: litellm/rust
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
rust-test:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'rust-tests')
runs-on: ubuntu-latest
timeout-minutes: 30
# Trim debuginfo to keep the job's target dir within the runner's disk
env:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
defaults:
run:
working-directory: litellm/rust
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- uses: ./.github/actions/setup-uv-with-retries
with:
version: "0.10.9"
- name: Install Python dependencies for the bridge tests
working-directory: .
run: |
uv sync --frozen --no-install-project
echo "PYTHONPATH=$PWD/.venv/lib/$(ls .venv/lib)/site-packages" >> "$GITHUB_ENV"
- run: rustup toolchain install --no-self-update
- uses: taiki-e/install-action@d438492cf8a250514fa2d34b30bc3c0dc37c65ff # v2.87.8
with:
tool: cargo-nextest@0.9.143
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
workspaces: litellm/rust
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check generated trace contracts
working-directory: .
run: uv run litellm/scripts/generate_trace_types.py --check
- run: cargo nextest run --workspace --locked
- run: cargo test --workspace --doc --locked
- name: Test token counter feature combinations
run: |
for features in '' fast huggingface tiktoken fast,huggingface fast,tiktoken huggingface,tiktoken fast,huggingface,tiktoken; do
cargo test -p litellm-token-counter --locked --no-default-features --features "$features"
cargo check -p litellm-python-bridge --locked --no-default-features --features "abi3${features:+,$features}"
done
- name: Test the FIPS build
run: |
cargo test -p litellm-http --locked --features fips
cargo test -p litellm-auth-aws --locked --features fips
cargo check -p litellm-gateway -p litellm-python-bridge --locked --features fips
- name: Test secret manager feature combinations
run: |
cargo test -p litellm-auth-gcp --locked --no-default-features
for features in '' aws google hashicorp azure cyberark aws,google aws,azure google,azure aws,google,azure aws,google,cyberark aws,google,azure,cyberark aws,google,hashicorp,azure,cyberark; do
cargo test -p litellm-secrets --locked --no-default-features --features "$features"
done
rust-wheel:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'rust-tests')
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- uses: ./.github/actions/setup-uv-with-retries
with:
version: "0.10.9"
- run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
workspaces: litellm/rust
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: uv build --wheel --out-dir dist
- run: python .github/scripts/verify_linux_native_wheel.py dist/*.whl
env:
RELEASE_WHEEL_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
- run: python tests/unit/rust_bridge/native_route_wheel_test.py dist/*.whl
- name: Run pytest tests/test_litellm_rust with the compiled extension
run: make test-rust-extension
- run: >-
uv build --wheel --out-dir panic-dist
--config-setting "maturin.build-args=--features panic-test,extension-module"
- run: python .github/scripts/smoke_test_native_wheel.py panic-dist/*.whl