Skip to content

Commit 2bccb2a

Browse files
committed
Merge branch 'maintenance/generic-gha-cibuildwheel'
PR #1535
2 parents 1fb2189 + 7905e2b commit 2bccb2a

File tree

4 files changed

+181
-134
lines changed

4 files changed

+181
-134
lines changed

.github/workflows/ci-cd.yml

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -136,51 +136,62 @@ jobs:
136136
- pre-setup # transitive, for accessing settings
137137
strategy:
138138
matrix:
139-
os:
140-
- ubuntu
141-
- windows
142-
- macos
139+
runner-vm-os:
140+
- ubuntu-latest
141+
- windows-latest
142+
- macos-latest
143143
tag:
144144
- ''
145145
- 'musllinux'
146146
exclude:
147-
- os: windows
147+
- runner-vm-os: windows-latest
148148
tag: 'musllinux'
149-
- os: macos
149+
- runner-vm-os: macos-latest
150150
tag: 'musllinux'
151-
- os: ubuntu
151+
- runner-vm-os: ubuntu-latest
152152
tag: >-
153153
${{
154154
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
155155
&& 'musllinux' || 'none'
156156
}}
157-
uses: ./.github/workflows/reusable-build-wheel.yml
157+
uses: ./.github/workflows/reusable-cibuildwheel.yml
158158
with:
159-
os: ${{ matrix.os }}
160-
tag: ${{ matrix.tag }}
161-
wheel-tags-to-skip: >-
162-
${{
163-
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
164-
&& '*_i686
165-
*-macosx_universal2
166-
*-musllinux_*
167-
*-win32
168-
pp*'
169-
|| (matrix.tag == 'musllinux') && '*-manylinux_* pp*'
170-
|| '*-musllinux_* pp*'
171-
}}
159+
check-name: >-
160+
Build ${{ matrix.tag }} wheels on ${{ matrix.runner-vm-os }}
161+
runner-vm-os: ${{ matrix.runner-vm-os }}
162+
timeout-minutes: 20
172163
source-tarball-name: >-
173164
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
174165
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
175-
cython-tracing: >- # Cython line tracing for coverage collection
176-
${{
166+
# CIBW_CONFIG_SETTINGS: `with-cython-tracing` — for coverage collection
167+
# CIBW_CONFIG_SETTINGS: `pure-python` — force C-extensions
168+
environment-variables: |-
169+
CIBW_ARCHS_MACOS=x86_64 arm64 universal2
170+
171+
CIBW_CONFIG_SETTINGS<<EOF
172+
pure-python=false
173+
with-cython-tracing=${{
177174
(
178175
github.event_name == 'push'
179176
&& contains(github.ref, 'refs/tags/')
180177
)
181178
&& 'false'
182179
|| 'true'
183180
}}
181+
EOF
182+
183+
CIBW_SKIP<<EOF
184+
${{
185+
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
186+
&& '*_i686
187+
*-macosx_universal2
188+
*-musllinux_*
189+
*-win32'
190+
|| (matrix.tag == 'musllinux') && '*-manylinux_*'
191+
|| '*-musllinux_*'
192+
}}
193+
pp*
194+
EOF
184195
185196
test:
186197
name: Test
@@ -508,19 +519,40 @@ jobs:
508519
tag:
509520
- ''
510521
- musllinux
511-
uses: ./.github/workflows/reusable-build-wheel.yml
522+
uses: ./.github/workflows/reusable-cibuildwheel.yml
512523
with:
513-
qemu: ${{ matrix.qemu }}
514-
tag: ${{ matrix.tag }}
515-
wheel-tags-to-skip: >-
516-
${{
517-
(matrix.tag == 'musllinux')
518-
&& '*-manylinux_* pp*'
519-
|| '*-musllinux_* pp*'
520-
}}
524+
check-name: >-
525+
Build ${{ matrix.tag }} wheels for ${{ matrix.qemu }}
526+
qemu: true
527+
timeout-minutes: 60
521528
source-tarball-name: >-
522529
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
523530
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
531+
# CIBW_ARCHS_LINUX: Build emulated architectures if QEMU, else "auto"
532+
# CIBW_CONFIG_SETTINGS: `with-cython-tracing` — for coverage collection
533+
# CIBW_CONFIG_SETTINGS: `pure-python` — force C-extensions
534+
environment-variables: |-
535+
CIBW_ARCHS_LINUX=${{ matrix.qemu }}
536+
537+
CIBW_ARCHS_MACOS=x86_64 arm64 universal2
538+
539+
CIBW_CONFIG_SETTINGS<<EOF
540+
pure-python=false
541+
with-cython-tracing=${{
542+
(
543+
github.event_name == 'push'
544+
&& contains(github.ref, 'refs/tags/')
545+
)
546+
&& 'false'
547+
|| 'true'
548+
}}
549+
EOF
550+
551+
CIBW_SKIP=${{
552+
(matrix.tag == 'musllinux')
553+
&& '*-manylinux_*'
554+
|| '*-musllinux_*'
555+
}} pp*
524556
525557
deploy:
526558
name: Deploy

.github/workflows/reusable-build-wheel.yml

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
3+
name: Build wheel
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_call:
7+
inputs:
8+
dists-artifact-name:
9+
description: Workflow artifact name containing dists
10+
required: true
11+
type: string
12+
check-name:
13+
description: A custom name for the Checks API-reported status
14+
required: false
15+
type: string
16+
environment-variables:
17+
description: >-
18+
A newline-delimited blob of text with environment variables
19+
to be set using `${GITHUB_ENV}`
20+
required: false
21+
type: string
22+
qemu:
23+
default: false
24+
description: >-
25+
Whether this job needs to configure QEMU to emulate a foreign
26+
architecture before running `cibuildwheel`. Defaults to "false".
27+
required: false
28+
type: boolean
29+
runner-vm-os:
30+
description: VM OS to use
31+
default: ubuntu-latest
32+
required: false
33+
type: string
34+
source-tarball-name:
35+
description: Sdist filename wildcard
36+
required: true
37+
type: string
38+
timeout-minutes:
39+
description: Deadline for the job to complete
40+
required: true
41+
type: number
42+
43+
env:
44+
FORCE_COLOR: "1" # Make tools pretty.
45+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
46+
PIP_NO_PYTHON_VERSION_WARNING: "1"
47+
48+
jobs:
49+
50+
build-wheel:
51+
name: >-
52+
${{
53+
inputs.check-name
54+
&& inputs.check-name
55+
|| format(
56+
'Build wheels on {0}{1}',
57+
inputs.runner-vm-os,
58+
inputs.qemu && ' under QEMU' || ''
59+
)
60+
}}
61+
runs-on: ${{ inputs.runner-vm-os }}
62+
timeout-minutes: ${{ fromJSON(inputs.timeout-minutes) }}
63+
steps:
64+
- name: Export requested job-global environment variables
65+
if: inputs.environment-variables != ''
66+
env:
67+
INPUT_ENVIRONMENT_VARIABLES: ${{ inputs.environment-variables }}
68+
run: echo "${INPUT_ENVIRONMENT_VARIABLES}" >> "${GITHUB_ENV}"
69+
shell: bash
70+
71+
- name: Compute GHA artifact name ending
72+
id: gha-artifact-name
73+
run: |
74+
from hashlib import sha512
75+
from os import environ
76+
from pathlib import Path
77+
78+
FILE_APPEND_MODE = 'a'
79+
80+
inputs_json_str = """${{ toJSON(inputs) }}"""
81+
82+
hash = sha512(inputs_json_str.encode()).hexdigest()
83+
84+
with Path(environ['GITHUB_OUTPUT']).open(
85+
mode=FILE_APPEND_MODE,
86+
) as outputs_file:
87+
print(f'hash={hash}', file=outputs_file)
88+
shell: python
89+
90+
- name: Retrieve the project source from an sdist inside the GHA artifact
91+
uses: re-actors/checkout-python-sdist@release/v2
92+
with:
93+
source-tarball-name: ${{ inputs.source-tarball-name }}
94+
workflow-artifact-name: ${{ inputs.dists-artifact-name }}
95+
96+
- name: Set up QEMU
97+
if: inputs.qemu
98+
uses: docker/setup-qemu-action@v3
99+
with:
100+
platforms: all
101+
102+
- name: Build wheels
103+
uses: pypa/[email protected]
104+
105+
- name: Upload built artifacts for testing and publishing
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: ${{ inputs.dists-artifact-name }}-
109+
${{ inputs.runner-vm-os }}-
110+
${{ inputs.qemu && 'qemu-' || '' }}
111+
${{ steps.gha-artifact-name.outputs.hash }}
112+
path: ./wheelhouse/*.whl
113+
114+
...

CHANGES/1535.contrib.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The :file:`reusable-cibuildwheel.yml` workflow has been refactored to
2+
be more generic and :file:`ci-cd.yml` now holds all the configuration
3+
toggles -- by :user:`webknjaz`.

0 commit comments

Comments
 (0)