292 lines
8.4 KiB
YAML
292 lines
8.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # Run after merging into the "main" target
|
|
paths: # Run only if files relevant to CI have changed (i.e. not install.sh, scripts or .github/workflows)
|
|
- 'llmfit-*/**'
|
|
- 'Cargo.{lock,toml}'
|
|
pull_request:
|
|
branches:
|
|
- main # Run in PRs targeting the "main" branch
|
|
paths:
|
|
- 'llmfit-*/**'
|
|
- 'Cargo.{lock,toml}'
|
|
types: # Avoid low-impact events like "edited" or "labeled"
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
changes:
|
|
name: Detect changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
rust-changed: ${{ steps.filter.outputs.rust }}
|
|
python-changed: ${{ steps.filter.outputs.python }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Filter changed paths
|
|
id: filter
|
|
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
|
|
with:
|
|
filters: |
|
|
rust:
|
|
- 'llmfit-!(python)/**'
|
|
- 'Cargo.{lock,toml}'
|
|
python:
|
|
- 'llmfit-python/**'
|
|
- 'Cargo.toml'
|
|
|
|
test:
|
|
name: Test Suite
|
|
needs: changes
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
rust: [stable]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v6.4.0
|
|
with:
|
|
node-version: lts/*
|
|
cache: npm
|
|
cache-dependency-path: llmfit-web/package-lock.json
|
|
|
|
- name: Build web dashboard assets
|
|
run: |
|
|
cd llmfit-web
|
|
npm ci
|
|
npx vite build
|
|
|
|
- name: Run web unit tests
|
|
run: |
|
|
cd llmfit-web
|
|
npx vitest run
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-index-
|
|
|
|
- name: Cache target directory
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-target-
|
|
|
|
- name: Run tests
|
|
if: needs.changes.outputs.rust-changed == 'true'
|
|
run: cargo test --verbose
|
|
|
|
# If `cargo test` already ran, most work can be reused from that step.
|
|
- name: Build debug binary
|
|
run: cargo build
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v8.2.0
|
|
|
|
# Tests integration of Rust code with hatch_build.py and key Python tests when
|
|
# the full Python test suite is not required. Redundant if Python tests below run.
|
|
- name: Run Rust/Python integration tests
|
|
if: needs.changes.outputs.python-changed == 'false'
|
|
run: uv run pytest -vv -m rust_integration
|
|
working-directory: llmfit-python
|
|
|
|
- name: Run Python tests
|
|
if: needs.changes.outputs.python-changed == 'true'
|
|
run: uv run pytest -vv
|
|
working-directory: llmfit-python
|
|
|
|
fmt:
|
|
name: Rustfmt
|
|
needs: changes
|
|
if: needs.changes.outputs.rust-changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
clippy:
|
|
name: Clippy
|
|
needs: changes
|
|
if: needs.changes.outputs.rust-changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v6.4.0
|
|
with:
|
|
node-version: lts/*
|
|
cache: npm
|
|
cache-dependency-path: llmfit-web/package-lock.json
|
|
|
|
- name: Build web dashboard assets
|
|
run: |
|
|
cd llmfit-web
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-index-
|
|
|
|
- name: Cache target directory
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-target-
|
|
|
|
- name: Run clippy
|
|
run: cargo clippy --all-targets --all-features
|
|
|
|
check:
|
|
name: Cargo Check
|
|
needs: changes
|
|
if: needs.changes.outputs.rust-changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v6.4.0
|
|
with:
|
|
node-version: lts/*
|
|
cache: npm
|
|
cache-dependency-path: llmfit-web/package-lock.json
|
|
|
|
- name: Build web dashboard assets
|
|
run: |
|
|
cd llmfit-web
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-index-
|
|
|
|
- name: Cache target directory
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-target-
|
|
|
|
- name: Run cargo check
|
|
run: cargo check --all-targets --all-features
|
|
|
|
check-python:
|
|
name: Python Checks
|
|
needs: changes
|
|
if: needs.changes.outputs.python-changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v8.2.0
|
|
|
|
- name: Ruff lint
|
|
run: uv run --only-group=dev ruff check .
|
|
working-directory: llmfit-python
|
|
|
|
- name: Ruff format check
|
|
run: uv run --only-group=dev ruff format --check .
|
|
working-directory: llmfit-python
|
|
|
|
- name: Type check
|
|
run: uv run --only-group=dev ty check .
|
|
working-directory: llmfit-python
|