Skip to content

Commit 3a3fe5f

Browse files
committed
🧪 Generalize cibuildwheel config w/ env vars
1 parent 34a7e05 commit 3a3fe5f

File tree

2 files changed

+85
-69
lines changed

2 files changed

+85
-69
lines changed

.github/workflows/ci-cd.yml

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -633,36 +633,35 @@ jobs:
633633
with:
634634
runner-vm-os: ${{ matrix.runner-vm-os }}
635635
timeout-minutes: 9
636-
wheel-tags-to-skip: >-
637-
${{
638-
!fromJSON(needs.pre-setup.outputs.release-requested)
639-
&& '*_i686
640-
*-macosx_universal2
641-
*-musllinux_*
642-
*-win32
643-
*_arm64
644-
pp*'
645-
|| ''
646-
}}
647636
source-tarball-name: >-
648637
${{ needs.pre-setup.outputs.sdist-artifact-name }}
649638
dists-artifact-name: >-
650639
${{ needs.pre-setup.outputs.dists-artifact-name }}
651-
# cython-tracing: >- # Cython line tracing for coverage collection
652-
# ${{
653-
# (
654-
# github.event_name == 'push'
655-
# && contains(github.ref, 'refs/tags/')
656-
# )
657-
# && 'false'
658-
# || 'true'
659-
# }}
660-
cython-tracing: >- # Cython line tracing for coverage collection
661-
${{
640+
# CIBW_CONFIG_SETTINGS: `with-cython-tracing` — for coverage collection
641+
# CIBW_ARCHS_MACOS=all x86_64 arm64 universal2
642+
environment-variables: |-
643+
CIBW_ARCHS_MACOS=native
644+
645+
CIBW_CONFIG_SETTINGS<<EOF
646+
with-cython-tracing=${{
662647
fromJSON(needs.pre-setup.outputs.profiling-enabled)
663648
&& 'true'
664649
|| 'false'
665650
}}
651+
EOF
652+
653+
${{
654+
!fromJSON(needs.pre-setup.outputs.release-requested)
655+
&& 'CIBW_SKIP<<EOF
656+
*_i686
657+
*-macosx_universal2
658+
*-musllinux_*
659+
*-win32
660+
*_arm64
661+
pp*
662+
EOF'
663+
|| ''
664+
}}
666665
667666
build-bin-manylinux-tested-arches:
668667
name: >-
@@ -686,21 +685,33 @@ jobs:
686685
with:
687686
runner-vm-os: ubuntu-latest
688687
timeout-minutes: 9
689-
wheel-tags-to-skip: >-
690-
*_i686
691-
*-musllinux_*
692-
*-*linux_{aarch64,ppc64le,s390x}
693-
pp*
694688
source-tarball-name: >-
695689
${{ needs.pre-setup.outputs.sdist-artifact-name }}
696690
dists-artifact-name: >-
697691
${{ needs.pre-setup.outputs.dists-artifact-name }}
698-
cython-tracing: >- # Cython line tracing for coverage collection
699-
${{
692+
# CIBW_CONFIG_SETTINGS: `with-cython-tracing` — for coverage collection
693+
# CIBW_ARCHS_MACOS=all x86_64 arm64 universal2
694+
environment-variables: |-
695+
CIBW_ARCHS_MACOS=native
696+
697+
CIBW_CONFIG_SETTINGS<<EOF
698+
with-cython-tracing=${{
700699
fromJSON(needs.pre-setup.outputs.profiling-enabled)
701700
&& 'true'
702701
|| 'false'
703702
}}
703+
EOF
704+
705+
${{
706+
!fromJSON(needs.pre-setup.outputs.release-requested)
707+
&& 'CIBW_SKIP<<EOF
708+
*_i686
709+
*-musllinux_*
710+
*-*linux_{aarch64,ppc64le,s390x}
711+
pp*
712+
EOF'
713+
|| ''
714+
}}
704715
705716
build-bin-manylinux-odd-arches:
706717
name: >-
@@ -724,22 +735,37 @@ jobs:
724735
with:
725736
runner-vm-os: ubuntu-latest
726737
timeout-minutes: 70
727-
wheel-tags-to-skip: >-
728-
*_i686
729-
*-musllinux_*
730-
*-*linux_x86_64
731-
pp*
732738
source-tarball-name: >-
733739
${{ needs.pre-setup.outputs.sdist-artifact-name }}
734740
dists-artifact-name: >-
735741
${{ needs.pre-setup.outputs.dists-artifact-name }}
736-
qemu: all
737-
cython-tracing: >- # Cython line tracing for coverage collection
738-
${{
742+
qemu: true
743+
# CIBW_ARCHS_LINUX: Build emulated architectures if QEMU, else "auto"
744+
# CIBW_CONFIG_SETTINGS: `with-cython-tracing` — for coverage collection
745+
# CIBW_ARCHS_MACOS=all x86_64 arm64 universal2
746+
environment-variables: |-
747+
CIBW_ARCHS_LINUX=all
748+
749+
CIBW_ARCHS_MACOS=native
750+
751+
CIBW_CONFIG_SETTINGS<<EOF
752+
with-cython-tracing=${{
739753
fromJSON(needs.pre-setup.outputs.profiling-enabled)
740754
&& 'true'
741755
|| 'false'
742756
}}
757+
EOF
758+
759+
${{
760+
!fromJSON(needs.pre-setup.outputs.release-requested)
761+
&& 'CIBW_SKIP<<EOF
762+
*_i686
763+
*-musllinux_*
764+
*-*linux_x86_64
765+
pp*
766+
EOF'
767+
|| ''
768+
}}
743769
744770
build-src:
745771
name: >-

.github/workflows/reusable-cibuildwheel.yml

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +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-
cython-tracing:
17-
description: Whether to build Cython modules with line tracing
18-
default: '0'
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
2122
qemu:
22-
description: Emulated QEMU architecture
23-
default: ''
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".
2427
required: false
25-
type: string
28+
type: boolean
2629
runner-vm-os:
2730
description: VM OS to use
2831
default: ubuntu-latest
@@ -36,11 +39,6 @@ on: # yamllint disable-line rule:truthy
3639
description: Deadline for the job to complete
3740
required: true
3841
type: number
39-
wheel-tags-to-skip:
40-
description: Wheel tags to skip building
41-
default: ''
42-
required: false
43-
type: string
4442

4543
env:
4644
FORCE_COLOR: "1" # Make tools pretty.
@@ -54,11 +52,22 @@ jobs:
5452
${{
5553
inputs.check-name
5654
&& inputs.check-name
57-
|| format('Build wheels on {0} {1}', inputs.runner-vm-os, inputs.qemu)
55+
|| format(
56+
'Build wheels on {0}{1}',
57+
inputs.runner-vm-os,
58+
inputs.qemu && ' under QEMU' || ''
59+
)
5860
}}
5961
runs-on: ${{ inputs.runner-vm-os }}
6062
timeout-minutes: ${{ fromJSON(inputs.timeout-minutes) }}
6163
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+
6271
- name: Compute GHA artifact name ending
6372
id: gha-artifact-name
6473
run: |
@@ -89,35 +98,16 @@ jobs:
8998
uses: docker/setup-qemu-action@v3
9099
with:
91100
platforms: all
92-
id: qemu
93-
- name: Prepare emulation
94-
if: inputs.qemu
95-
run: |
96-
# Build emulated architectures only if QEMU is set,
97-
# use default "auto" otherwise
98-
echo "CIBW_ARCHS_LINUX=${{ inputs.qemu }}" >> "${GITHUB_ENV}"
99-
shell: bash
100-
101-
- name: Skip building some wheel tags
102-
if: inputs.wheel-tags-to-skip
103-
run: |
104-
echo "CIBW_SKIP=${{ inputs.wheel-tags-to-skip }}" >> "${GITHUB_ENV}"
105-
shell: bash
106101

107102
- name: Build wheels
108103
uses: pypa/[email protected]
109-
env:
110-
# CIBW_ARCHS_MACOS: all x86_64 arm64 universal2
111-
CIBW_ARCHS_MACOS: native
112-
CIBW_CONFIG_SETTINGS: >- # Cython line tracing for coverage collection
113-
with-cython-tracing=${{ inputs.cython-tracing }}
114104

115105
- name: Upload built artifacts for testing and publishing
116106
uses: actions/upload-artifact@v4
117107
with:
118108
name: ${{ inputs.dists-artifact-name }}-
119109
${{ inputs.runner-vm-os }}-
120-
${{ inputs.qemu }}-
110+
${{ inputs.qemu && 'qemu-' || '' }}
121111
${{ steps.gha-artifact-name.outputs.hash }}
122112
path: ./wheelhouse/*.whl
123113

0 commit comments

Comments
 (0)