name: LiteLLM Rust on: push: paths: - "litellm-rust/**" - "litellm/rust_bridge/**" - "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/llms/base_llm/ocr/**" - "litellm/llms/custom_httpx/llm_http_handler.py" - "tests/test_litellm/ocr/**" - "tests/test_litellm/conftest.py" - "Makefile" - ".cargo/**" - "pyproject.toml" - "uv.lock" - "rust-toolchain.toml" - ".github/actions/setup-uv-with-retries/**" - ".github/scripts/smoke_test_native_wheel.py" - ".github/scripts/verify_linux_native_wheel.py" - "tests/test_litellm/rust_bridge/native_route_wheel_test.py" - ".github/workflows/test-rust.yml" pull_request: branches: - main - litellm_internal_staging - litellm_oss_staging - "litellm_**" paths: - "litellm-rust/**" - "litellm/rust_bridge/**" - "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/llms/base_llm/ocr/**" - "litellm/llms/custom_httpx/llm_http_handler.py" - "tests/test_litellm/ocr/**" - "tests/test_litellm/conftest.py" - "Makefile" - ".cargo/**" - "pyproject.toml" - "uv.lock" - "rust-toolchain.toml" - ".github/actions/setup-uv-with-retries/**" - ".github/scripts/smoke_test_native_wheel.py" - ".github/scripts/verify_linux_native_wheel.py" - "tests/test_litellm/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 }} cancel-in-progress: true env: CARGO_TERM_COLOR: always jobs: rust-fmt: runs-on: ubuntu-latest timeout-minutes: 5 defaults: run: working-directory: litellm-rust steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 with: persist-credentials: false - run: rustup toolchain install --no-self-update - run: cargo fmt --all --check rust-clippy: 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 - run: rustup toolchain install --no-self-update - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: workspaces: litellm-rust cache-on-failure: true - run: cargo clippy --workspace --all-targets --locked -- -D warnings rust-test: runs-on: ubuntu-latest timeout-minutes: 20 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" - run: rustup toolchain install --no-self-update - name: Install cargo-nextest 0.9.143 working-directory: ${{ runner.temp }} run: | curl -fsSL --retry 3 -o cargo-nextest.tar.gz \ https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-0.9.143/cargo-nextest-0.9.143-x86_64-unknown-linux-gnu.tar.gz echo "66786b9abe23920d022a182d1416b1bbc8130dd4872a9553d76985a1708dcd1e cargo-nextest.tar.gz" | sha256sum -c - mkdir -p bin tar xzf cargo-nextest.tar.gz -C bin cargo-nextest echo "$PWD/bin" >> "$GITHUB_PATH" - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: workspaces: litellm-rust cache-on-failure: true - run: cargo nextest run --workspace --locked - run: cargo test --workspace --doc --locked rust-wheel: 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 - 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/test_litellm/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