Skip to content

Commit

Permalink
Test wheel builds during PR CI on demand
Browse files Browse the repository at this point in the history
Refactor the wheels-build and deployment workflow into one re-usable
"build wheels" workflow and two orchestration workflows.  The
orchestration workflows are the existing "tag push" event, which also
deploys the wheels to PyPI, and a new "PR" trigger that runs the
all-wheels build if the PR is labelled with `ci: test wheels`.

The deployment job is slightly reorganised so that all the "core"
platforms build and deploy before the less common platforms even begin
the build.  The core platforms are all tier 1 platforms, the 32-bit
platforms, and the sdist.  These core platforms were already tied
together, but the other platforms ran concurrently with them.  This
could lead to other projects' CI failing when Qiskit was part way
through a deployment.

The "other" wheels are all tied together in this PR mostly as a
convenience to avoid repetition.  They could easily be untied from each
other (as the current state does).
  • Loading branch information
jakelishman committed Oct 14, 2024
1 parent 2e67cec commit 95f4b9d
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 186 deletions.
246 changes: 246 additions & 0 deletions .github/workflows/wheels-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
name: Build release artifacts
on:
workflow_call:
inputs:
default-action:
description: >-
The default action for each artifact.
Choose from 'build' (default) or 'skip'.
type: string
default: "build"
required: false

sdist:
description: >-
The action to take for the sdist.
Choose from 'default', 'build' or 'skip'.
type: string
default: "default"
required: false

wheels-tier-1:
description: >-
The action to take for Tier 1 wheels.
Choose from 'default', 'build' or 'skip'.
This builds multiple artifacts, which all match 'wheels-tier-1-*'.
type: string
default: "default"
required: false

wheels-32bit:
description: >-
The action to take for Tier 1 wheels.
Choose from 'default', 'build' or 'skip'.
This builds multiple artifacts, which all match 'wheels-32bit-*'.
type: string
default: "default"
required: false

wheels-linux-s390x:
description: >-
The action to take for Linux s390x wheels.
Choose from 'default', 'build' or 'skip'.
type: string
default: "default"
required: false

wheels-linux-ppc64le:
description: >-
The action to take for Linux ppc64le wheels.
Choose from 'default', 'build' or 'skip'.
type: string
default: "default"
required: false

wheels-linux-aarch64:
description: >-
The action to take for Linux AArch64 wheels.
Choose from 'default', 'build' or 'skip'.
type: string
default: "default"
required: false

artifact-prefix:
description: "A prefix to give all artifacts uploaded with 'actions/upload-artifact'."
type: string
default: ""
required: false

python-version:
description: "The Python version to use to host the build runner."
type: string
default: "3.10"
required: false


jobs:
wheels-tier-1:
name: "Tier 1 wheels"
if: (inputs.wheels-tier-1 == 'default' && inputs.default-action || inputs.wheels-tier-1) == 'build'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# Used for the x86_64 builds.
- macos-12
# Used for the ARM builds.
- macos-14
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
architecture: ${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: >-
bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata
CIBW_BEFORE_BUILD_WINDOWS: >-
bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata
&& cp /tmp/pgo-data/merged.profdata ~/.
CIBW_ENVIRONMENT: >-
RUSTUP_TOOLCHAIN="stable"
RUSTFLAGS="
-Cprofile-use=/tmp/pgo-data/merged.profdata
-Cllvm-args=-pgo-warn-missing-function
"
CIBW_ENVIRONMENT_LINUX: >-
RUSTUP_TOOLCHAIN="stable"
RUSTFLAGS="
-Cprofile-use=/tmp/pgo-data/merged.profdata
-Cllvm-args=-pgo-warn-missing-function
"
PATH="$PATH:$HOME/.cargo/bin"
CARGO_NET_GIT_FETCH_WITH_CLI="true"
CIBW_ENVIRONMENT_WINDOWS: >-
RUSTUP_TOOLCHAIN="stable"
RUSTFLAGS="
-Cprofile-use=c:\\Users\\runneradmin\\merged.profdata
-Cllvm-args=-pgo-warn-missing-function
"
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-tier-1-${{ matrix.os }}

wheels-32bit:
name: "32bit wheels"
if: (inputs.wheels-32bit == 'default' && inputs.default-action || inputs.wheels-32bit) == 'build'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: 'pp* cp36-* cp37-* cp38-* *musllinux* *amd64 *x86_64'
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-32bit-${{ matrix.os }}

wheels-linux-s390x:
name: "Linux s390x wheel"
if: (inputs.wheels-linux-s390x == 'default' && inputs.default-action || inputs.wheels-linux-s390x) == 'build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: ${{ inputs.python-version }}
- uses: dtolnay/rust-toolchain@stable
- uses: docker/setup-qemu-action@v3
with:
platforms: all
- uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: s390x
CIBW_TEST_SKIP: "cp*"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-s390x
path: ./wheelhouse/*.whl

wheels-linux-ppc64le:
name: "Linux pcc64le wheel"
if: (inputs.wheels-linux-ppc64le == 'default' && inputs.default-action || inputs.wheels-linux-ppc64le) == 'build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: ${{ inputs.python-version }}
- uses: dtolnay/rust-toolchain@stable
- uses: docker/setup-qemu-action@v3
with:
platforms: all
- uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: ppc64le
CIBW_TEST_SKIP: "cp*"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-ppc64le
path: ./wheelhouse/*.whl

wheels-linux-aarch64:
name: "Linux AArch64 wheel"
if: (inputs.wheels-linux-aarch64 == 'default' && inputs.default-action || inputs.wheels-linux-aarch64) == 'build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- uses: dtolnay/rust-toolchain@stable
- uses: docker/setup-qemu-action@v3
with:
platforms: all
- uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: aarch64
CIBW_TEST_COMMAND: >-
cp -r {project}/test .
&& QISKIT_PARALLEL=FALSE stestr --test-path test/python run --abbreviate -n test.python.compiler.test_transpiler
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-aarch64
path: ./wheelhouse/*.whl

sdist:
name: "sdist"
if: (inputs.sdist == 'default' && inputs.default-action || inputs.sdist) == 'build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Build sdist
run: |
set -e
python -m pip install -U build
python -m build --sdist .
- uses: actions/upload-artifact@v4
with:
name: sdist
path: ./dist/*.tar.gz
23 changes: 23 additions & 0 deletions .github/workflows/wheels-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test wheel builds

on:
pull_request:
types:
- opened
- synchronize
- reopened
# Above are the defaults for the PR trigger, below are our insertions.
# Trigger on 'labeled' so we catch the initial manual labelling event.
- labeled

concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
test-wheels:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci: test wheels') }}
name: Build
uses: './.github/workflows/wheels-build.yml'
with:
default-action: "build"
Loading

0 comments on commit 95f4b9d

Please sign in to comment.