Skip to content

Commit

Permalink
Modernize the release workflow
Browse files Browse the repository at this point in the history
Copy the approach from `asyncpg` to make the build matrix more granular
  • Loading branch information
elprans committed Aug 14, 2023
1 parent 2c4e7a6 commit 5e6f2b7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 30 deletions.
69 changes: 39 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,48 @@ jobs:
python -m pip install -U setuptools wheel pip
python setup.py sdist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.tar.*

build-wheels:
build-wheels-matrix:
needs: validate-release-request
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: pip install cibuildwheel==2.15.0
- id: set-matrix
run: |
MATRIX_INCLUDE=$(
{
cibuildwheel --print-build-identifiers --platform linux --arch x86_64,aarch64 | grep cp | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos --arch x86_64,arm64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows --arch x86,AMD64 | grep cp | jq -nRc '{"only": inputs, "os": "windows-latest"}'
} | jq -sc
)
echo "include=$MATRIX_INCLUDE" >> $GITHUB_OUTPUT
build-wheels:
needs: build-wheels-matrix
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.only }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
cibw_arch: ["auto64", "aarch64", "universal2"]
cibw_python:
- "cp38-*"
- "cp39-*"
- "cp310-*"
- "cp311-*"
- "cp312-*"
exclude:
- os: ubuntu-latest
cibw_arch: universal2
- os: macos-latest
cibw_arch: aarch64
- os: windows-latest
cibw_arch: universal2
- os: windows-latest
cibw_arch: aarch64
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}

defaults:
run:
shell: bash

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- uses: actions/checkout@v3
Expand All @@ -94,23 +109,17 @@ jobs:
submodules: true

- name: Set up QEMU
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- uses: pypa/cibuildwheel@v2.9.0
- uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
with:
only: ${{ matrix.only }}
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.cibw_python }}
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
CIBW_TEST_SKIP: "*universal2:arm64"
CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1"

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: dist
path: wheelhouse/*.whl
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "immutables"
description = "Immutable Collections"
authors = [{name = "MagicStack Inc", email = "hello@magic.io"}]
requires-python = '>=3.8.0'
readme = "README.rst"
license = {text = "Apache License, Version 2.0"}
dynamic = ["version"]
Expand Down Expand Up @@ -78,3 +79,16 @@ ignore_errors = true
[[tool.mypy.overrides]]
module = "immutables._testutils"
ignore_errors = true

[tool.cibuildwheel]
build-frontend = "build"
test-extras = "test"

[tool.cibuildwheel.macos]
test-command = "python {project}/tests/__init__.py"

[tool.cibuildwheel.windows]
test-command = "python {project}\\tests\\__init__.py"

[tool.cibuildwheel.linux]
test-command = "python {project}/tests/__init__.py"

0 comments on commit 5e6f2b7

Please sign in to comment.