name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test Suite
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/cache
~/.cargo/registry
target/
key: macos-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check macOS and CoreML version
run: |
echo "macOS version: $(sw_vers -productVersion)"
echo "macOS build: $(sw_vers -buildVersion)"
python3 -c "import platform; print(f'Python can detect CoreML: {platform.mac_ver()}')" || true
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run library tests
run: cargo test --lib --verbose
- name: Run unit tests (no integration tests)
run: |
# Run only unit tests that don't require large model downloads
cargo test --verbose --test builder_tests
cargo test --verbose --test utils_tests
cargo test --verbose --test tensor_regression_tests
cargo test --verbose --test discover_shapes_tests
# Skip integration tests that require actual models in CI
echo "Skipping integration tests that require model downloads in CI"
continue-on-error: true
- name: Run cross-platform compatibility tests
run: |
# Run tests that specifically check non-macOS compilation behavior
echo "Testing cross-platform compilation stubs..."
# These should pass on macOS but test the non-macOS code paths exist
cargo test --verbose qwen_tests::non_macos_tests --lib 2>/dev/null || echo "Non-macOS test module not available (expected on macOS)"
cargo test --verbose performance_regression_tests::non_macos_tests --lib 2>/dev/null || echo "Non-macOS test module not available (expected on macOS)"
cargo test --verbose utils_tests::non_macos_tests --lib 2>/dev/null || echo "Non-macOS test module not available (expected on macOS)"
continue-on-error: true
- name: Test examples (with error handling)
run: |
echo "Testing basic examples..."
# Only test examples that don't require large model downloads
# debug_mlstate example was removed during cleanup
timeout 30s cargo run --example clean_download_example || echo "clean_download_example failed or timed out (expected without network)"
continue-on-error: true
security:
name: Security Audit
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit
publish-check:
name: Publish Check
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check if publishable
run: cargo publish --dry-run