rs build #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| lint: | |
| name: Lint & Format Check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev libudev-dev pkg-config | |
| - name: Check rustfmt | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy (all features) | |
| run: cargo clippy --workspace --all-features --all-targets -- -D warnings | |
| - name: Run clippy (no_std core) | |
| run: cargo clippy -p qres_core --no-default-features --lib -- -D warnings | |
| - name: Check docs | |
| run: cargo doc --workspace --all-features --no-deps --document-private-items | |
| env: | |
| RUSTDOCFLAGS: "-D warnings" | |
| test-rust: | |
| name: Test Rust (${{ matrix.os }}, ${{ matrix.toolchain }}) | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| toolchain: [stable, nightly] | |
| exclude: | |
| # Only test nightly on Ubuntu to save CI time | |
| - os: macos-latest | |
| toolchain: nightly | |
| - os: windows-latest | |
| toolchain: nightly | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust ${{ matrix.toolchain }} | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ matrix.toolchain }} | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev libudev-dev pkg-config | |
| - name: Build qres_core (no_std) | |
| run: cargo build -p qres_core --no-default-features --release | |
| - name: Build all workspace members (Linux, all features incl. Python) | |
| if: runner.os == 'Linux' | |
| run: cargo build --workspace --all-features --release | |
| - name: Build all workspace members (macOS/Windows, skip Python & legacy swarm_sim) | |
| if: runner.os != 'Linux' | |
| run: cargo build --workspace --exclude swarm_sim --features std --release | |
| - name: Run tests (qres_core with std) | |
| run: cargo test -p qres_core --features std --release | |
| - name: Run tests (full workspace, Linux) | |
| if: runner.os == 'Linux' | |
| run: cargo test --workspace --all-features --release -- --test-threads=1 | |
| - name: Run tests (full workspace, macOS/Windows) | |
| if: runner.os != 'Linux' | |
| run: cargo test --workspace --exclude swarm_sim --features std --release -- --test-threads=1 | |
| - name: Run power module tests | |
| run: cargo test -p qres_core --features std --release -- "power::" | |
| - name: Run verification tests | |
| run: cargo test -p qres_core --features std --release -- verify | |
| - name: Run benchmarks (compile only, Linux) | |
| if: runner.os == 'Linux' | |
| run: cargo bench --workspace --all-features --no-run | |
| - name: Run benchmarks (compile only, macOS/Windows) | |
| if: runner.os != 'Linux' | |
| run: cargo bench --workspace --exclude swarm_sim --features std --no-run | |
| test-python: | |
| name: Test Python Bindings (${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev libudev-dev pkg-config | |
| - name: Setup Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install maturin pytest numpy scipy networkx | |
| - name: Build Python bindings | |
| run: | | |
| cd bindings/python | |
| maturin build --release | |
| pip install --force-reinstall ../../target/wheels/*.whl | |
| - name: Run Python tests | |
| run: | | |
| pytest tests/ -v --tb=short || true | |
| # Continue on test failures for now (graceful degradation) | |
| - name: Test Python imports | |
| run: | | |
| python -c "import qres; print(f'QRES version: {qres.__version__ if hasattr(qres, \"__version__\") else \"unknown\"}')" | |
| python -c "from qres import QRES_API; api = QRES_API(mode='hybrid'); print('✓ QRES_API initialized')" | |
| test-wasm: | |
| name: Test WASM Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Build WASM | |
| run: | | |
| cd crates/qres_wasm | |
| wasm-pack build --target web --release | |
| - name: Check WASM output | |
| run: | | |
| ls -lh crates/qres_wasm/pkg/ | |
| test -f crates/qres_wasm/pkg/qres_wasm_bg.wasm | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit --locked | |
| - name: Run cargo-audit | |
| run: cargo audit --ignore RUSTSEC-0000-0000 | |
| continue-on-error: true | |
| - name: Install cargo-deny | |
| run: cargo install cargo-deny --locked | |
| - name: Run cargo-deny | |
| run: cargo deny check advisories | |
| continue-on-error: true | |
| minimum-rust-version: | |
| name: Check MSRV (Minimum Rust 1.83) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust 1.83 | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: "1.83" | |
| - name: Build with Rust 1.83 | |
| run: cargo build -p qres_core --no-default-features | |
| summary: | |
| name: CI Summary | |
| runs-on: ubuntu-latest | |
| needs: [lint, test-rust, test-python, test-wasm, security, minimum-rust-version] | |
| if: always() | |
| steps: | |
| - name: Check results | |
| run: | | |
| if [ "${{ needs.lint.result }}" != "success" ]; then | |
| echo "❌ Lint failed" | |
| exit 1 | |
| fi | |
| if [ "${{ needs.test-rust.result }}" != "success" ]; then | |
| echo "❌ Rust tests failed" | |
| exit 1 | |
| fi | |
| if [ "${{ needs.test-python.result }}" != "success" ]; then | |
| echo "⚠️ Python tests failed (non-blocking)" | |
| fi | |
| if [ "${{ needs.test-wasm.result }}" != "success" ]; then | |
| echo "❌ WASM build failed" | |
| exit 1 | |
| fi | |
| if [ "${{ needs.security.result }}" != "success" ]; then | |
| echo "⚠️ Security audit found issues (non-blocking)" | |
| fi | |
| if [ "${{ needs.minimum-rust-version.result }}" != "success" ]; then | |
| echo "❌ MSRV check failed" | |
| exit 1 | |
| fi | |
| echo "✓ CI passed" |