Skip to content

Commit eeb048f

Browse files
committed
Merge branch 'maintenance/generic-gha-cibuildwheel'
PR #1193
2 parents 5ab49a5 + 0072f7e commit eeb048f

File tree

3 files changed

+95
-72
lines changed

3 files changed

+95
-72
lines changed

.github/workflows/ci-cd.yml

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -110,51 +110,58 @@ jobs:
110110
codecov-token: ${{ secrets.CODECOV_TOKEN }}
111111

112112
build-wheels-for-tested-arches:
113-
name: Build wheels on ${{ matrix.os }}
113+
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
114+
📦 Build wheels for tested arches${{ '' }}
114115
needs:
115116
- build-pure-python-dists
116117
- pre-setup # transitive, for accessing settings
117118
strategy:
118119
matrix:
119-
os:
120-
- ubuntu
121-
- windows
120+
runner-vm-os:
121+
- ubuntu-latest
122+
- windows-latest
122123
- windows-11-arm
123-
- macos
124+
- macos-latest
124125
tag:
125126
- ''
126127
- 'musllinux'
127128
exclude:
128-
- os: windows
129+
- runner-vm-os: windows-latest
129130
tag: 'musllinux'
130-
- os: windows-11-arm
131+
- runner-vm-os: windows-11-arm
131132
tag: 'musllinux'
132-
- os: macos
133+
- runner-vm-os: macos-latest
133134
tag: 'musllinux'
134-
- os: ubuntu
135+
- runner-vm-os: ubuntu-latest
135136
tag: >-
136137
${{
137138
(github.event_name != 'push' || github.ref_type != 'tag')
138139
&& 'musllinux' || 'none'
139140
}}
140-
uses: ./.github/workflows/reusable-build-wheel.yml
141+
uses: ./.github/workflows/reusable-cibuildwheel.yml
141142
with:
142-
os: ${{ matrix.os }}
143-
tag: ${{ matrix.tag }}
144-
wheel-tags-to-skip: >-
145-
${{
146-
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
147-
&& '*_i686
148-
*-macosx_universal2
149-
*-musllinux_*
150-
*-win32
151-
pp*'
152-
|| (matrix.tag == 'musllinux') && '*-manylinux_* pp*'
153-
|| '*-musllinux_* pp*'
154-
}}
143+
check-name: >-
144+
Build ${{ matrix.tag }} wheels on ${{ matrix.runner-vm-os }}
145+
runner-vm-os: ${{ matrix.runner-vm-os }}
146+
timeout-minutes: 15
155147
source-tarball-name: >-
156148
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
157149
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
158165
159166
test:
160167
name: >-
@@ -542,7 +549,8 @@ jobs:
542549
echo "Predeploy step"
543550
544551
build-wheels-for-odd-archs:
545-
name: Build wheels on ${{ matrix.tag }} ${{ matrix.qemu }}
552+
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
553+
📦 Build wheels for odd arches${{ '' }}
546554
needs:
547555
- build-pure-python-dists
548556
- pre-deploy
@@ -557,19 +565,26 @@ jobs:
557565
tag:
558566
- ''
559567
- musllinux
560-
uses: ./.github/workflows/reusable-build-wheel.yml
568+
uses: ./.github/workflows/reusable-cibuildwheel.yml
561569
with:
562-
qemu: ${{ matrix.qemu }}
563-
tag: ${{ matrix.tag }}
564-
wheel-tags-to-skip: >-
565-
${{
566-
(matrix.tag == 'musllinux')
567-
&& '*-manylinux_* pp*'
568-
|| '*-musllinux_* pp*'
569-
}}
570+
check-name: >-
571+
Build ${{ matrix.tag }} wheels for ${{ matrix.qemu }}
572+
qemu: true
573+
timeout-minutes: 120
570574
source-tarball-name: >-
571575
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
572576
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*
573588
574589
deploy:
575590
name: Deploy

.github/workflows/reusable-build-wheel.yml renamed to .github/workflows/reusable-cibuildwheel.yml

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,43 @@
22

33
name: Build wheel
44

5-
on:
5+
on: # yamllint disable-line rule:truthy
66
workflow_call:
77
inputs:
88
dists-artifact-name:
99
description: Workflow artifact name containing dists
1010
required: true
1111
type: string
12-
os:
13-
description: VM OS to use, without version suffix
14-
default: ubuntu
12+
check-name:
13+
description: A custom name for the Checks API-reported status
1514
required: false
1615
type: string
17-
qemu:
18-
description: Emulated QEMU architecture
19-
default: ''
16+
environment-variables:
17+
description: >-
18+
A newline-delimited blob of text with environment variables
19+
to be set using `${GITHUB_ENV}`
2020
required: false
2121
type: string
22-
tag:
23-
description: Build platform tag wheels
24-
default: ''
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
2532
required: false
2633
type: string
2734
source-tarball-name:
2835
description: Sdist filename wildcard
2936
required: true
3037
type: string
31-
wheel-tags-to-skip:
32-
description: Wheel tags to skip building
33-
default: ''
34-
required: false
35-
type: string
38+
timeout-minutes:
39+
description: Deadline for the job to complete
40+
required: true
41+
type: number
3642

3743
env:
3844
FORCE_COLOR: "1" # Make tools pretty.
@@ -43,22 +49,38 @@ jobs:
4349

4450
build-wheel:
4551
name: >-
46-
Build ${{ inputs.tag }} wheels on ${{ inputs.os }} ${{ inputs.qemu }}
47-
runs-on: ${{
48-
inputs.os == 'windows-11-arm' && inputs.os ||
49-
format('{0}-latest', inputs.os)
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+
)
5060
}}
51-
timeout-minutes: ${{ inputs.qemu && 120 || 15 }}
61+
runs-on: ${{ inputs.runner-vm-os }}
62+
timeout-minutes: ${{ fromJSON(inputs.timeout-minutes) }}
5263
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+
5371
- name: Compute GHA artifact name ending
5472
id: gha-artifact-name
5573
run: |
5674
from hashlib import sha512
5775
from os import environ
5876
from pathlib import Path
77+
5978
FILE_APPEND_MODE = 'a'
79+
6080
inputs_json_str = """${{ toJSON(inputs) }}"""
81+
6182
hash = sha512(inputs_json_str.encode()).hexdigest()
83+
6284
with Path(environ['GITHUB_OUTPUT']).open(
6385
mode=FILE_APPEND_MODE,
6486
) as outputs_file:
@@ -76,33 +98,16 @@ jobs:
7698
uses: docker/setup-qemu-action@v3
7799
with:
78100
platforms: all
79-
id: qemu
80-
- name: Prepare emulation
81-
if: inputs.qemu
82-
run: |
83-
# Build emulated architectures only if QEMU is set,
84-
# use default "auto" otherwise
85-
echo "CIBW_ARCHS_LINUX=${{ inputs.qemu }}" >> "${GITHUB_ENV}"
86-
shell: bash
87-
88-
- name: Skip building some wheel tags
89-
if: inputs.wheel-tags-to-skip
90-
run: |
91-
echo "CIBW_SKIP=${{ inputs.wheel-tags-to-skip }}" >> "${GITHUB_ENV}"
92-
shell: bash
93101

94102
- name: Build wheels
95103
uses: pypa/[email protected]
96-
env:
97-
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
98104

99105
- name: Upload built artifacts for testing and publishing
100106
uses: actions/upload-artifact@v4
101107
with:
102108
name: ${{ inputs.dists-artifact-name }}-
103-
${{ inputs.os }}-
104-
${{ inputs.qemu }}-
105-
${{ inputs.tag }}-
109+
${{ inputs.runner-vm-os }}-
110+
${{ inputs.qemu && 'qemu-' || '' }}
106111
${{ steps.gha-artifact-name.outputs.hash }}
107112
path: ./wheelhouse/*.whl
108113

CHANGES/1193.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)