fix: align CI Python versions with PyO3 support #2
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 | |
| tags: | |
| - "v*" | |
| pull_request: | |
| jobs: | |
| python-tests: | |
| name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install test dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install maturin pytest scipy | |
| - name: Build extension in editable mode | |
| run: maturin develop | |
| - name: Run test suite | |
| run: pytest -x -v | |
| rust-checks: | |
| name: Rust checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run cargo tests | |
| run: cargo test --all-targets | |
| - name: Run clippy | |
| run: cargo clippy --all-targets -- -D warnings | |
| build-wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: build | |
| args: --release --out dist | |
| manylinux: auto | |
| sccache: "true" | |
| - name: Upload wheel artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: dist | |
| build-sdist: | |
| name: Build source distribution | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload source distribution | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| publish: | |
| name: Publish to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-wheels | |
| - build-sdist | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download built artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish distributions | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist |