Build workflow (CalebBell/ht)
The Build workflow from CalebBell/ht, 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 workflow from the CalebBell/ht repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Build
on:
push:
branches: [master, release]
pull_request:
branches: [master, release]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.13t', 'pypy3.11']
os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest]
architecture: ['x86', 'x64']
exclude:
# Only test pypy on Linux
- os: windows-latest
python-version: pypy3.11
- os: macos-latest
python-version: pypy3.11
- os: macos-15-intel
python-version: pypy3.11
# no python builds available on macos 32 bit, arm or x64
- os: macos-latest
architecture: x86
- os: macos-15-intel
architecture: x86
# no python builds available on linux 32 bit
- os: ubuntu-latest
architecture: x86
# scipy dropped 32 bit windows builds
- os: windows-latest
architecture: x86
python-version: 3.9
- os: windows-latest
architecture: x86
python-version: 3.10
- os: windows-latest
architecture: x86
python-version: 3.11
- os: windows-latest
architecture: x86
python-version: 3.12
- os: windows-latest
architecture: x86
python-version: 3.13
- os: windows-latest
architecture: x86
python-version: 3.13t
- os: windows-latest
architecture: x86
python-version: 3.14
# pandas doesn't have wheels for 3.13t on Windows x64
- os: windows-latest
architecture: x64
python-version: 3.13t
# These are arm - old versions of Python are not supported
- os: macos-latest
python-version: 3.9
- os: macos-latest
python-version: 3.10
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.architecture }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install uv
if: matrix.python-version != '3.13t'
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install Ubuntu dependencies
if: startsWith(runner.os, 'Linux')
run: |
# Taken from scipy
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev libjpeg-dev zlib1g-dev libtiff-dev libfreetype6-dev liblcms2-dev libwebp-dev
- name: Install dependencies
run: |
python -c "import platform; print(platform.platform()); print(platform.architecture())"
if [[ "${{ matrix.python-version }}" == "3.13t" ]]; then
# Use pip for 3.13t (free-threading) as uv may not fully support it yet
python -m pip install --upgrade pip
pip install -e .[test]
else
uv pip install --system -e .[test]
fi
shell: bash
- name: Add numba
if: ${{ !contains(fromJSON('["pypy3.11", "3.13t"]'), matrix.python-version) }}
run: |
uv pip install --system -e .[numba]
- name: Test with pytest
run: |
pytest . -v --cov-report html --cov=ht --cov-report term-missing -m "not online and not thermo"
coveralls || true
env:
COVERALLS_REPO_TOKEN: ${{ secrets.coveralls }}
COVERALLS_PARALLEL: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTHON_GIL: ${{ matrix.python-version == '3.13t' && '0' || '' }}
- name: Upload coverage HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-html-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.architecture }}
path: htmlcov/
finish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
env:
COVERALLS_REPO_TOKEN: ${{ secrets.coveralls }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl https://coveralls.io/webhook?repo_token=${{ secrets.coveralls }} -d "payload[build_num]=${{ github.sha }}&payload[status]=done"
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 on: push: branches: [master, release] pull_request: branches: [master, release] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }} jobs: build: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.13t', 'pypy3.11'] os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest] architecture: ['x86', 'x64'] exclude: # Only test pypy on Linux - os: windows-latest python-version: pypy3.11 - os: macos-latest python-version: pypy3.11 - os: macos-15-intel python-version: pypy3.11 # no python builds available on macos 32 bit, arm or x64 - os: macos-latest architecture: x86 - os: macos-15-intel architecture: x86 # no python builds available on linux 32 bit - os: ubuntu-latest architecture: x86 # scipy dropped 32 bit windows builds - os: windows-latest architecture: x86 python-version: 3.9 - os: windows-latest architecture: x86 python-version: 3.10 - os: windows-latest architecture: x86 python-version: 3.11 - os: windows-latest architecture: x86 python-version: 3.12 - os: windows-latest architecture: x86 python-version: 3.13 - os: windows-latest architecture: x86 python-version: 3.13t - os: windows-latest architecture: x86 python-version: 3.14 # pandas doesn't have wheels for 3.13t on Windows x64 - os: windows-latest architecture: x64 python-version: 3.13t # These are arm - old versions of Python are not supported - os: macos-latest python-version: 3.9 - os: macos-latest python-version: 3.10 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} ${{ matrix.architecture }} uses: actions/setup-python@v5 with: cache: 'pip' python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Install uv if: matrix.python-version != '3.13t' uses: astral-sh/setup-uv@v4 with: enable-cache: true cache-dependency-glob: "pyproject.toml" - name: Install Ubuntu dependencies if: startsWith(runner.os, 'Linux') run: | # Taken from scipy sudo apt-get update sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev libjpeg-dev zlib1g-dev libtiff-dev libfreetype6-dev liblcms2-dev libwebp-dev - name: Install dependencies run: | python -c "import platform; print(platform.platform()); print(platform.architecture())" if [[ "${{ matrix.python-version }}" == "3.13t" ]]; then # Use pip for 3.13t (free-threading) as uv may not fully support it yet python -m pip install --upgrade pip pip install -e .[test] else uv pip install --system -e .[test] fi shell: bash - name: Add numba if: ${{ !contains(fromJSON('["pypy3.11", "3.13t"]'), matrix.python-version) }} run: | uv pip install --system -e .[numba] - name: Test with pytest run: | pytest . -v --cov-report html --cov=ht --cov-report term-missing -m "not online and not thermo" coveralls || true env: COVERALLS_REPO_TOKEN: ${{ secrets.coveralls }} COVERALLS_PARALLEL: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PYTHON_GIL: ${{ matrix.python-version == '3.13t' && '0' || '' }} - name: Upload coverage HTML report if: always() uses: actions/upload-artifact@v4 with: name: coverage-html-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.architecture }} path: htmlcov/ finish: timeout-minutes: 30 needs: build runs-on: latchkey-small steps: - name: Coveralls Finished env: COVERALLS_REPO_TOKEN: ${{ secrets.coveralls }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | curl https://coveralls.io/webhook?repo_token=${{ secrets.coveralls }} -d "payload[build_num]=${{ github.sha }}&payload[status]=done"
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.
1 third-party action is referenced by a movable tag. Pin it 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
- Network fetches
This workflow runs 2 jobs (57 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.