164 lines
4.7 KiB
YAML
164 lines
4.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
# ============================================================================
|
|
# Rust linting
|
|
# ============================================================================
|
|
lint-rust:
|
|
name: Lint Rust
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Check formatting
|
|
run: cd rust && cargo fmt --all -- --check
|
|
|
|
- name: Clippy
|
|
run: cd rust && cargo clippy -- -D warnings
|
|
|
|
# ============================================================================
|
|
# Python linting
|
|
# ============================================================================
|
|
lint-python:
|
|
name: Lint Python
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install linting tools
|
|
run: pip install flake8
|
|
|
|
- name: Run flake8
|
|
run: cd python && python -m flake8 . --count --statistics
|
|
|
|
|
|
# ============================================================================
|
|
# Rust tests
|
|
# ============================================================================
|
|
test-rust:
|
|
name: Test Rust
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Run tests
|
|
run: cd rust && cargo test --verbose
|
|
|
|
- name: Build release
|
|
run: cd rust && cargo build --release
|
|
|
|
# ============================================================================
|
|
# Python wheel build (multi-platform)
|
|
# ============================================================================
|
|
build-wheels:
|
|
name: Build wheels (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install maturin
|
|
run: pip install maturin
|
|
|
|
- name: Build wheels
|
|
run: cd python && maturin build --release
|
|
|
|
- name: Upload wheels
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: wheels-${{ matrix.os }}
|
|
path: rust/target/wheels/*.whl
|
|
|
|
# ============================================================================
|
|
# Python tests (multi-version)
|
|
# ============================================================================
|
|
test-python:
|
|
name: Test Python ${{ matrix.python-version }}
|
|
needs: build-wheels
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
allow-prereleases: true
|
|
|
|
- name: Install maturin and pytest
|
|
run: pip install maturin pytest
|
|
|
|
- name: Build wheel
|
|
run: cd python && maturin build --release --interpreter python${{ matrix.python-version }}
|
|
|
|
- name: Install wheel
|
|
run: pip install rust/target/wheels/*.whl
|
|
|
|
- name: Run tests
|
|
run: cd python && pytest tests/ -v
|
|
|
|
# ============================================================================
|
|
# Summary
|
|
# ============================================================================
|
|
ci-success:
|
|
name: CI Success
|
|
needs: [lint-rust, lint-python, test-rust, build-wheels, test-python]
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
steps:
|
|
- name: Check all jobs passed
|
|
run: |
|
|
if [[ "${{ needs.lint-rust.result }}" != "success" ]] || \
|
|
[[ "${{ needs.lint-python.result }}" != "success" ]] || \
|
|
[[ "${{ needs.test-rust.result }}" != "success" ]] || \
|
|
[[ "${{ needs.build-wheels.result }}" != "success" ]] || \
|
|
[[ "${{ needs.test-python.result }}" != "success" ]]; then
|
|
echo "Some jobs failed"
|
|
exit 1
|
|
fi
|
|
echo "All CI jobs passed!"
|
|
|