name: Rust
on:
push:
branches:
- main
- master
paths:
- "**.rs"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- ".github/workflows/rust.yml"
- ".github/actions/**"
pull_request:
paths:
- "**.rs"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- ".github/workflows/rust.yml"
- ".github/actions/**"
workflow_dispatch:
jobs:
rust-check:
name: Rust Check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- name: Setup dependencies
uses: ./.github/actions/setup-dependencies
with:
python-version: "3.12"
os: ${{ matrix.os }}
- name: Install Python dependencies
run: |
source .venv/bin/activate
uv pip install .[all]
- name: Set PYO3_PYTHON for PyO3 compatibility
run: |
echo "PYO3_PYTHON=$(pwd)/.venv/bin/python" >> $GITHUB_ENV
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
cache-targets: true
cache-all-crates: true
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D clippy::erasing_op
- name: Cargo check
run: cargo check --all
- name: Cargo build
run: |
chmod +x .github/scripts/build.sh
.github/scripts/build.sh