Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 48 additions & 33 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,51 +110,58 @@ jobs:
codecov-token: ${{ secrets.CODECOV_TOKEN }}

build-wheels-for-tested-arches:
name: Build wheels on ${{ matrix.os }}
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
📦 Build wheels for tested arches${{ '' }}
needs:
- build-pure-python-dists
- pre-setup # transitive, for accessing settings
strategy:
matrix:
os:
- ubuntu
- windows
runner-vm-os:
- ubuntu-latest
- windows-latest
- windows-11-arm
- macos
- macos-latest
tag:
- ''
- 'musllinux'
exclude:
- os: windows
- runner-vm-os: windows-latest
tag: 'musllinux'
- os: windows-11-arm
- runner-vm-os: windows-11-arm
tag: 'musllinux'
- os: macos
- runner-vm-os: macos-latest
tag: 'musllinux'
- os: ubuntu
- runner-vm-os: ubuntu-latest
tag: >-
${{
(github.event_name != 'push' || github.ref_type != 'tag')
&& 'musllinux' || 'none'
}}
uses: ./.github/workflows/reusable-build-wheel.yml
uses: ./.github/workflows/reusable-cibuildwheel.yml
with:
os: ${{ matrix.os }}
tag: ${{ matrix.tag }}
wheel-tags-to-skip: >-
${{
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
&& '*_i686
*-macosx_universal2
*-musllinux_*
*-win32
pp*'
|| (matrix.tag == 'musllinux') && '*-manylinux_* pp*'
|| '*-musllinux_* pp*'
}}
check-name: >-
Build ${{ matrix.tag }} wheels on ${{ matrix.runner-vm-os }}
runner-vm-os: ${{ matrix.runner-vm-os }}
timeout-minutes: 15
source-tarball-name: >-
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
environment-variables: |-
CIBW_ARCHS_MACOS=x86_64 arm64 universal2

CIBW_SKIP<<EOF
${{
(github.event_name != 'push' || !contains(github.ref, 'refs/tags/'))
&& '*_i686
*-macosx_universal2
*-musllinux_*
*-win32'
|| (matrix.tag == 'musllinux') && '*-manylinux_*'
|| '*-musllinux_*'
}}
pp*
EOF

test:
name: >-
Expand Down Expand Up @@ -542,7 +549,8 @@ jobs:
echo "Predeploy step"

build-wheels-for-odd-archs:
name: Build wheels on ${{ matrix.tag }} ${{ matrix.qemu }}
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
📦 Build wheels for odd arches${{ '' }}
needs:
- build-pure-python-dists
- pre-deploy
Expand All @@ -557,19 +565,26 @@ jobs:
tag:
- ''
- musllinux
uses: ./.github/workflows/reusable-build-wheel.yml
uses: ./.github/workflows/reusable-cibuildwheel.yml
with:
qemu: ${{ matrix.qemu }}
tag: ${{ matrix.tag }}
wheel-tags-to-skip: >-
${{
(matrix.tag == 'musllinux')
&& '*-manylinux_* pp*'
|| '*-musllinux_* pp*'
}}
check-name: >-
Build ${{ matrix.tag }} wheels for ${{ matrix.qemu }}
qemu: true
timeout-minutes: 120
source-tarball-name: >-
${{ needs.build-pure-python-dists.outputs.sdist-filename }}
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
# CIBW_ARCHS_LINUX: Build emulated architectures if QEMU, else "auto"
environment-variables: |-
CIBW_ARCHS_LINUX=${{ matrix.qemu }}

CIBW_ARCHS_MACOS=x86_64 arm64 universal2

CIBW_SKIP=${{
(matrix.tag == 'musllinux')
&& '*-manylinux_*'
|| '*-musllinux_*'
}} pp*

deploy:
name: Deploy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,43 @@

name: Build wheel

on:
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
dists-artifact-name:
description: Workflow artifact name containing dists
required: true
type: string
os:
description: VM OS to use, without version suffix
default: ubuntu
check-name:
description: A custom name for the Checks API-reported status
required: false
type: string
qemu:
description: Emulated QEMU architecture
default: ''
environment-variables:
description: >-
A newline-delimited blob of text with environment variables
to be set using `${GITHUB_ENV}`
required: false
type: string
tag:
description: Build platform tag wheels
default: ''
qemu:
default: false
description: >-
Whether this job needs to configure QEMU to emulate a foreign
architecture before running `cibuildwheel`. Defaults to "false".
required: false
type: boolean
runner-vm-os:
description: VM OS to use
default: ubuntu-latest
required: false
type: string
source-tarball-name:
description: Sdist filename wildcard
required: true
type: string
wheel-tags-to-skip:
description: Wheel tags to skip building
default: ''
required: false
type: string
timeout-minutes:
description: Deadline for the job to complete
required: true
type: number

env:
FORCE_COLOR: "1" # Make tools pretty.
Expand All @@ -43,22 +49,38 @@ jobs:

build-wheel:
name: >-
Build ${{ inputs.tag }} wheels on ${{ inputs.os }} ${{ inputs.qemu }}
runs-on: ${{
inputs.os == 'windows-11-arm' && inputs.os ||
format('{0}-latest', inputs.os)
${{
inputs.check-name
&& inputs.check-name
|| format(
'Build wheels on {0}{1}',
inputs.runner-vm-os,
inputs.qemu && ' under QEMU' || ''
)
}}
timeout-minutes: ${{ inputs.qemu && 120 || 15 }}
runs-on: ${{ inputs.runner-vm-os }}
timeout-minutes: ${{ fromJSON(inputs.timeout-minutes) }}
steps:
- name: Export requested job-global environment variables
if: inputs.environment-variables != ''
env:
INPUT_ENVIRONMENT_VARIABLES: ${{ inputs.environment-variables }}
run: echo "${INPUT_ENVIRONMENT_VARIABLES}" >> "${GITHUB_ENV}"
shell: bash

- name: Compute GHA artifact name ending
id: gha-artifact-name
run: |
from hashlib import sha512
from os import environ
from pathlib import Path

FILE_APPEND_MODE = 'a'

inputs_json_str = """${{ toJSON(inputs) }}"""

hash = sha512(inputs_json_str.encode()).hexdigest()

with Path(environ['GITHUB_OUTPUT']).open(
mode=FILE_APPEND_MODE,
) as outputs_file:
Expand All @@ -76,33 +98,16 @@ jobs:
uses: docker/setup-qemu-action@v3
with:
platforms: all
id: qemu
- name: Prepare emulation
if: inputs.qemu
run: |
# Build emulated architectures only if QEMU is set,
# use default "auto" otherwise
echo "CIBW_ARCHS_LINUX=${{ inputs.qemu }}" >> "${GITHUB_ENV}"
shell: bash

- name: Skip building some wheel tags
if: inputs.wheel-tags-to-skip
run: |
echo "CIBW_SKIP=${{ inputs.wheel-tags-to-skip }}" >> "${GITHUB_ENV}"
shell: bash

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: x86_64 arm64 universal2

- name: Upload built artifacts for testing and publishing
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.dists-artifact-name }}-
${{ inputs.os }}-
${{ inputs.qemu }}-
${{ inputs.tag }}-
${{ inputs.runner-vm-os }}-
${{ inputs.qemu && 'qemu-' || '' }}
${{ steps.gha-artifact-name.outputs.hash }}
path: ./wheelhouse/*.whl

Expand Down
3 changes: 3 additions & 0 deletions CHANGES/1193.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :file:`reusable-cibuildwheel.yml` workflow has been refactored to
be more generic and :file:`ci-cd.yml` now holds all the configuration
toggles -- by :user:`webknjaz`.
Loading