name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTDOCFLAGS: "-D warnings"
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain (with rustfmt)
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
needs: fmt steps:
- uses: actions/checkout@v4
- name: Install stable toolchain (with clippy)
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-clippy-
- name: Clippy (all targets, deny warnings)
run: cargo clippy --all-targets --all-features -- -D warnings
docs:
name: Documentation
runs-on: ubuntu-latest
needs: fmt
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-docs-
- name: Build documentation (deny warnings)
run: cargo doc --no-deps --all-features
msrv:
name: MSRV (rust-version in Cargo.toml)
runs-on: ubuntu-latest
needs: fmt
steps:
- uses: actions/checkout@v4
- name: Read MSRV from Cargo.toml
id: msrv
run: |
msrv=$(grep '^rust-version' Cargo.toml | cut -d'"' -f2)
echo "version=$msrv" >> "$GITHUB_OUTPUT"
- name: Install MSRV toolchain (${{ steps.msrv.outputs.version }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.msrv.outputs.version }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-msrv-${{ steps.msrv.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-msrv-
- name: Build on MSRV
run: cargo build --locked
test:
name: Test (${{ matrix.os }} / ${{ matrix.rust }})
needs: [fmt, clippy]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-test-${{ matrix.rust }}-
- name: Build (locked)
run: cargo build --locked --verbose
- name: Build examples (locked)
run: cargo build --examples --locked
- name: Run unit + integration tests (locked)
run: cargo test --locked --verbose
test-azure:
name: Azure E2E tests
needs: [fmt, clippy]
runs-on: ubuntu-latest
if: vars.AZURE_E2E_ENABLED == 'true'
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-azure-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-azure-
- name: Build
run: cargo build --locked
- name: Run Azure E2E tests
env:
AZURE_OPENAI_CONTENTGEN_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_CONTENTGEN_API_ENDPOINT }}
AZURE_OPENAI_CONTENTGEN_API_KEY: ${{ secrets.AZURE_OPENAI_CONTENTGEN_API_KEY }}
AZURE_OPENAI_CONTENTGEN_MODEL_DEPLOYMENT: ${{ secrets.AZURE_OPENAI_CONTENTGEN_MODEL_DEPLOYMENT }}
AZURE_OPENAI_CONTENTGEN_API_VERSION: ${{ secrets.AZURE_OPENAI_CONTENTGEN_API_VERSION }}
run: cargo test --locked --test e2e_azure -- --nocapture
test-gemini:
name: Gemini E2E tests
needs: [fmt, clippy]
runs-on: ubuntu-latest
if: vars.GEMINI_E2E_ENABLED == 'true'
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-gemini-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-gemini-
- name: Build
run: cargo build --locked
- name: Run Gemini E2E tests
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: cargo test --locked --test e2e_gemini -- --nocapture
test-vertexai:
name: Vertex AI E2E tests
needs: [fmt, clippy]
runs-on: ubuntu-latest
if: vars.VERTEXAI_E2E_ENABLED == 'true'
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-vertexai-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-vertexai-
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY_JSON }}
- name: Build
run: cargo build --locked
- name: Run Vertex AI E2E tests
env:
GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }}
GOOGLE_CLOUD_REGION: ${{ secrets.GOOGLE_CLOUD_REGION || 'us-central1' }}
GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: cargo test --locked --test e2e_gemini -- --nocapture --ignored
audit:
name: Security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo-audit binary
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-audit
key: ${{ runner.os }}-cargo-audit-bin
- name: Install cargo-audit
run: which cargo-audit || cargo install cargo-audit
- name: Run security audit
run: cargo audit