Build wheel workflow (holgern/pyedflib)
The Build wheel workflow from holgern/pyedflib, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Build wheel workflow from the holgern/pyedflib repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Build wheel
on:
workflow_dispatch:
push:
# Pattern matched against refs/tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CIBW_BUILD_VERBOSITY: 1
# Run the package tests using `pytest`
# CIBW_TEST_REQUIRES: pytest
# CIBW_TEST_COMMAND: pytest
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install deps
run: python -m pip install build twine
- name: Build SDist
run: python -m build --sdist
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
- name: Check metadata
run: twine check dist/*
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
# Used to host cibuildwheel
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
# Disable building PyPy wheels
CIBW_SKIP: "pp* cp313* cp312*i686"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_PRERELEASE_PYTHONS: False
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}
path: wheelhouse/*.whl
build_aarch64_wheels:
name: Build wheels aarch64
runs-on: ubuntu-latest
strategy:
matrix:
python: [38, 39, 310, 311, 312, 313]
include:
- os: ubuntu-latest
arch: aarch64
platform_id: manylinux_aarch64
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: ${{matrix.arch}}
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python }}-${{ matrix.platform_id }}
path: wheelhouse/*.whl
upload_pypi:
name: Upload to PyPI (prod)
needs: [build_wheels, build_aarch64_wheels, make_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Build wheel on: workflow_dispatch: push: # Pattern matched against refs/tags tags: - 'v[0-9]+.[0-9]+.[0-9]+' env: CIBW_BUILD_VERBOSITY: 1 # Run the package tests using `pytest` # CIBW_TEST_REQUIRES: pytest # CIBW_TEST_COMMAND: pytest concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true jobs: make_sdist: timeout-minutes: 30 name: Make SDist runs-on: latchkey-small steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: '3.10' - name: Install deps run: python -m pip install build twine - name: Build SDist run: python -m build --sdist - uses: actions/upload-artifact@v4 with: path: dist/*.tar.gz - name: Check metadata run: twine check dist/* build_wheels: timeout-minutes: 30 name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 # Used to host cibuildwheel - uses: actions/setup-python@v5 with: cache: 'pip' python-version: '3.10' - name: Install cibuildwheel run: python -m pip install cibuildwheel - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: # Disable building PyPy wheels CIBW_SKIP: "pp* cp313* cp312*i686" CIBW_ARCHS_MACOS: "x86_64 arm64" CIBW_PRERELEASE_PYTHONS: False - uses: actions/upload-artifact@v4 with: name: wheel-${{ matrix.os }} path: wheelhouse/*.whl build_aarch64_wheels: timeout-minutes: 30 name: Build wheels aarch64 runs-on: latchkey-small strategy: matrix: python: [38, 39, 310, 311, 312, 313] include: - os: ubuntu-latest arch: aarch64 platform_id: manylinux_aarch64 steps: - uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Install cibuildwheel run: python -m pip install cibuildwheel - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_ARCHS_LINUX: ${{matrix.arch}} CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} - uses: actions/upload-artifact@v4 with: name: wheel-${{ matrix.python }}-${{ matrix.platform_id }} path: wheelhouse/*.whl upload_pypi: timeout-minutes: 30 name: Upload to PyPI (prod) needs: [build_wheels, build_aarch64_wheels, make_sdist] runs-on: latchkey-small steps: - uses: actions/download-artifact@v4 with: merge-multiple: true path: dist - uses: pypa/gh-action-pypi-publish@v1.5.0 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 4 jobs (11 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.