Support Python >3.12 #46
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: Build & test | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "**.pyi?" | |
- "**.rs" | |
- "Cargo.*" | |
- "pyproject.toml" | |
push: | |
branches: | |
- "main" | |
paths: | |
- "**.pyi?" | |
- "**.rs" | |
- "Cargo.*" | |
- "pyproject.toml" | |
workflow_call: | |
inputs: | |
release: | |
type: boolean | |
description: Build for release | |
default: false | |
outputs: | |
run_id: | |
description: Workflow run ID | |
value: ${{ jobs.output_run_id.outputs.run_id }} | |
env: | |
# If this workflow is called to build for release, build using | |
# release profile. | |
build_profile: ${{ inputs.release && 'release' || 'dev' }} | |
jobs: | |
linux: | |
name: Build & test on Linux | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# If this workflow is called to build for release, build for x64 and ARM64 | |
# processors. However, run tests only for x64, as GH doesn't provide | |
# ARM64 runners. | |
target: ${{ inputs.release && fromJSON('["x64", "aarch64"]') || fromJSON('["x64"]') }} | |
# If this workflow is called to build for release, build using | |
# only one Python version, which is the lowest ABI version set | |
# in PyO3 features. | |
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }} | |
env: | |
DISPLAY: :0 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Install test dependencies | |
run: sudo apt-get update & sudo apt-get install -y xvfb xclip | |
- name: Run virtual X11 server | |
run: Xvfb :0 -screen 0 800x600x16 & | |
- name: Setup venv | |
run: python -m venv .venv | |
- name: Build extension module | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --profile ${{ env.build_profile }} --out dist | |
manylinux: auto | |
- name: Run tests | |
if: ${{ matrix.target == 'x64' }} | |
run: | | |
source .venv/bin/activate | |
pip install dist/* | |
pip install -r requirements-dev.txt | |
pytest -v | |
- name: Update build artifact | |
if: ${{ inputs.release }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ runner.os }}-${{ matrix.target }} | |
path: dist | |
windows: | |
name: Build & test on Windows | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
# If this workflow is called to build for release, build using | |
# only one Python version, which is the lowest ABI version set | |
# in PyO3 features. | |
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Setup venv | |
run: python -m venv .venv | |
- name: Build extension module | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x64 | |
args: --profile ${{ env.build_profile }} --out dist | |
- name: Run tests | |
shell: powershell | |
run: | | |
.venv\Scripts\activate.ps1 | |
pip install dist\$(Get-ChildItem -Name dist\*.whl) | |
pip install -r requirements-dev.txt | |
pytest -v | |
- name: Update build artifact | |
if: ${{ inputs.release }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ runner.os }} | |
path: dist | |
macos: | |
name: Build & test on MacOS | |
runs-on: macos-12 | |
strategy: | |
matrix: | |
# If this workflow is called to build for release, build for x64 and ARM64 | |
# processors. However, run tests only for x64, as GH doesn't provide | |
# ARM64 runners. | |
target: ${{ inputs.release && fromJSON('["x64", "aarch64"]') || fromJSON('["x64"]') }} | |
# If this workflow is called to build for release, build using | |
# only one Python version, which is the lowest ABI version set | |
# in PyO3 features. | |
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Setup venv | |
run: python -m venv .venv | |
- name: Build extension module | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --profile ${{ env.build_profile }} --out dist | |
- name: Run tests | |
if: ${{ matrix.target == 'x64' }} | |
run: | | |
source .venv/bin/activate | |
pip install dist/* | |
pip install -r requirements-dev.txt | |
pytest -v | |
- name: Update build artifact | |
if: ${{ inputs.release }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ runner.os }}-${{ matrix.target }} | |
path: dist | |
output_run_id: | |
name: Export workflow run ID to the caller | |
if: ${{ inputs.release }} | |
runs-on: ubuntu-latest | |
env: | |
RUN_ID: ${{ github.run_id }} | |
outputs: | |
run_id: ${{ steps.export.outputs.run_id }} | |
steps: | |
- id: export | |
run: echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT |