Skip to content

Commit 7fa1318

Browse files
committed
🧪 Generalize cibuildwheel config w/ env vars
1 parent 2f05c7b commit 7fa1318

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

‎.github/workflows/ci-cd.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,26 @@ jobs:
142142
with:
143143
check-name: >-
144144
Build ${{ matrix.tag }} wheels on ${{ matrix.runner-vm-os }}
145-
wheel-tags-to-skip: >-
146-
${{
147-
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
148-
&& '*_i686
149-
*-macosx_universal2
150-
*-musllinux_*
151-
*-win32
152-
pp*'
153-
|| (matrix.tag == 'musllinux') && '*-manylinux_* pp*'
154-
|| '*-musllinux_* pp*'
155-
}}
156145
runner-vm-os: ${{ matrix.runner-vm-os }}
157146
timeout-minutes: 15
158147
source-tarball-name: >-
159148
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
160149
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
150+
environment-variables: |-
151+
CIBW_ARCHS_MACOS=x86_64 arm64 universal2
152+
153+
CIBW_SKIP<<EOF
154+
${{
155+
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
156+
&& '*_i686
157+
*-macosx_universal2
158+
*-musllinux_*
159+
*-win32'
160+
|| (matrix.tag == 'musllinux') && '*-manylinux_*'
161+
|| '*-musllinux_*'
162+
}}
163+
pp*
164+
EOF
161165
162166
test:
163167
name: >-
@@ -565,17 +569,22 @@ jobs:
565569
with:
566570
check-name: >-
567571
Build ${{ matrix.tag }} wheels for ${{ matrix.qemu }}
568-
qemu: ${{ matrix.qemu }}
569-
wheel-tags-to-skip: >-
570-
${{
571-
(matrix.tag == 'musllinux')
572-
&& '*-manylinux_* pp*'
573-
|| '*-musllinux_* pp*'
574-
}}
572+
qemu: true
575573
timeout-minutes: 120
576574
source-tarball-name: >-
577575
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
578576
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
577+
# CIBW_ARCHS_LINUX: Build emulated architectures if QEMU, else "auto"
578+
environment-variables: |-
579+
CIBW_ARCHS_LINUX=${{ matrix.qemu }}
580+
581+
CIBW_ARCHS_MACOS=x86_64 arm64 universal2
582+
583+
CIBW_SKIP=${{
584+
(matrix.tag == 'musllinux')
585+
&& '*-manylinux_*'
586+
|| '*-musllinux_*'
587+
}} pp*
579588
580589
deploy:
581590
name: Deploy

‎.github/workflows/reusable-cibuildwheel.yml

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ on: # yamllint disable-line rule:truthy
1313
description: A custom name for the Checks API-reported status
1414
required: false
1515
type: string
16-
qemu:
17-
description: Emulated QEMU architecture
18-
default: ''
16+
environment-variables:
17+
description: >-
18+
A newline-delimited blob of text with environment variables
19+
to be set using `${GITHUB_ENV}`
1920
required: false
2021
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
2129
runner-vm-os:
2230
description: VM OS to use
2331
default: ubuntu-latest
@@ -31,11 +39,6 @@ on: # yamllint disable-line rule:truthy
3139
description: Deadline for the job to complete
3240
required: true
3341
type: number
34-
wheel-tags-to-skip:
35-
description: Wheel tags to skip building
36-
default: ''
37-
required: false
38-
type: string
3942

4043
env:
4144
FORCE_COLOR: "1" # Make tools pretty.
@@ -50,14 +53,21 @@ jobs:
5053
inputs.check-name
5154
&& inputs.check-name
5255
|| format(
53-
'Build wheels on {0} {1}',
56+
'Build wheels on {0}{1}',
5457
inputs.runner-vm-os,
55-
inputs.qemu
58+
inputs.qemu && ' under QEMU' || ''
5659
)
5760
}}
5861
runs-on: ${{ inputs.runner-vm-os }}
5962
timeout-minutes: ${{ fromJSON(inputs.timeout-minutes) }}
6063
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+
6171
- name: Compute GHA artifact name ending
6272
id: gha-artifact-name
6373
run: |
@@ -88,32 +98,16 @@ jobs:
8898
uses: docker/setup-qemu-action@v3
8999
with:
90100
platforms: all
91-
id: qemu
92-
- name: Prepare emulation
93-
if: inputs.qemu
94-
run: |
95-
# Build emulated architectures only if QEMU is set,
96-
# use default "auto" otherwise
97-
echo "CIBW_ARCHS_LINUX=${{ inputs.qemu }}" >> "${GITHUB_ENV}"
98-
shell: bash
99-
100-
- name: Skip building some wheel tags
101-
if: inputs.wheel-tags-to-skip
102-
run: |
103-
echo "CIBW_SKIP=${{ inputs.wheel-tags-to-skip }}" >> "${GITHUB_ENV}"
104-
shell: bash
105101

106102
- name: Build wheels
107103
uses: pypa/[email protected]
108-
env:
109-
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
110104

111105
- name: Upload built artifacts for testing and publishing
112106
uses: actions/upload-artifact@v4
113107
with:
114108
name: ${{ inputs.dists-artifact-name }}-
115109
${{ inputs.runner-vm-os }}-
116-
${{ inputs.qemu }}-
110+
${{ inputs.qemu && 'qemu-' || '' }}
117111
${{ steps.gha-artifact-name.outputs.hash }}
118112
path: ./wheelhouse/*.whl
119113

0 commit comments

Comments
 (0)