Add CI steps to build sdist and archive all release artifacts #32
This file contains 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: Unit tests | |
on: [push, pull_request] | |
concurrency: | |
group: test-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
- uses: dtolnay/[email protected] | |
with: | |
components: rustfmt, clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install pre-commit | |
run: pip install -c requirements.txt pre-commit | |
- name: Run pre-commit checks | |
run: pre-commit run --all-files | |
docs: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build Rust docs | |
# Document private items to validate their doc formatting. | |
run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --locked | |
- name: Install Python doc dependencies | |
run: pip install -r doc-requirements.txt | |
- name: Install Python package | |
run: pip install . | |
- name: Build Python docs | |
run: SPHINX_OPTS="-W --keep-going" make -C doc html | |
rust-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run Rust tests | |
run: RUSTFLAGS="-D warnings" cargo test --locked | |
python-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Install package | |
run: pip install . | |
- name: Run Python tests | |
run: pytest -v -ra | |
linux-wheels: | |
needs: [pre-commit, python-tests, rust-tests] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [x86_64, aarch64] | |
python: [cp38] # Using limited ABI, so newer versions are not required | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
if: matrix.arch != 'x86_64' | |
- id: rust-toolchain | |
uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS: ${{ matrix.arch }} | |
CIBW_BUILD: ${{ matrix.python }}-manylinux* | |
RUST_VERSION: ${{ steps.rust-toolchain.outputs.name }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel_linux-${{ matrix.arch }}-${{ matrix.python }} | |
path: ./wheelhouse/*.whl | |
macos-wheels: | |
needs: [pre-commit, python-tests, rust-tests] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [x86_64, arm64] | |
python: [cp38] # Using limited ABI, so newer versions are not required | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install x86_64 Rust compiler | |
run: rustup target add x86_64-apple-darwin | |
if: matrix.arch == 'x86_64' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- name: Install pipx | |
run: pip install pipx | |
- uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS: ${{ matrix.arch }} | |
CIBW_BUILD: ${{ matrix.python }}-macos* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel_macos-${{ matrix.arch }}-${{ matrix.python }} | |
path: ./wheelhouse/*.whl | |
sdist: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
- name: install build tool | |
run: pip install -c requirements.txt build | |
- name: build sdist | |
run: python -m build --sdist . | |
- uses: action/upload-artifact@v4 | |
with: | |
name: sdist | |
path: ./dist/*.tar.gz | |
combine-wheels: | |
needs: [linux-wheels, macos-wheels, sdist] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Create paths | |
run: mkdir -p dist wheelhouse | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheel_* | |
path: wheelhouse/ | |
merge-multiple: true | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist/ | |
merge-multiple: true | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release | |
path: | | |
dist/ | |
wheelhouse/ |