CI Tests workflow (astropy/halotools)
The CI Tests workflow from astropy/halotools, explained and optimized by Latchkey.
CI health: D - needs work
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the CI Tests workflow from the astropy/halotools 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: CI Tests
on:
push:
branches:
- master
# tags: # run CI if specific tags are pushed
pull_request:
branches:
- master
jobs:
# Github Actions supports ubuntu, windows, and macos virtual environments:
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
ci_tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Ubuntu - Python 3.11 with all optional dependencies
os: ubuntu-latest
python: "3.11"
toxenv: 'py11-test-alldeps'
- name: MacOs - Python 3.11 with all optional dependencies
os: macos-latest
python: "3.11"
toxenv: 'py11-test-alldeps'
- name: Ubuntu - Python 3.12 with all optional dependencies
os: ubuntu-latest
python: "3.12"
toxenv: 'py312-test-alldeps'
- name: MacOs - Python 3.12 with all optional dependencies
os: macos-latest
python: "3.12"
toxenv: 'py312-test-alldeps'
- name: Ubuntu - Python 3.13 with all optional dependencies
os: ubuntu-latest
python: "3.13"
toxenv: 'py313-test-alldeps'
- name: MacOs - Python 3.13 with all optional dependencies
os: macos-latest
python: "3.13"
toxenv: 'py313-test-alldeps'
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Set up python ${{ matrix.python }} on ${{ matrix.os }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python }}
- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox codecov
- name: Test with tox
run: |
tox -e ${{ matrix.toxenv }}
# This is an example of how to upload coverage to codecov
# - name: Upload coverage to codecov
# if: "contains(matrix.toxenv, '-cov')"
# uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
# with:
# file: ./coverage.xml
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: CI Tests on: push: branches: - master # tags: # run CI if specific tags are pushed pull_request: branches: - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # Github Actions supports ubuntu, windows, and macos virtual environments: # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners ci_tests: timeout-minutes: 30 name: ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: matrix: include: - name: Ubuntu - Python 3.11 with all optional dependencies os: ubuntu-latest python: "3.11" toxenv: 'py11-test-alldeps' - name: MacOs - Python 3.11 with all optional dependencies os: macos-latest python: "3.11" toxenv: 'py11-test-alldeps' - name: Ubuntu - Python 3.12 with all optional dependencies os: ubuntu-latest python: "3.12" toxenv: 'py312-test-alldeps' - name: MacOs - Python 3.12 with all optional dependencies os: macos-latest python: "3.12" toxenv: 'py312-test-alldeps' - name: Ubuntu - Python 3.13 with all optional dependencies os: ubuntu-latest python: "3.13" toxenv: 'py313-test-alldeps' - name: MacOs - Python 3.13 with all optional dependencies os: macos-latest python: "3.13" toxenv: 'py313-test-alldeps' steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: fetch-depth: 0 - name: Set up python ${{ matrix.python }} on ${{ matrix.os }} uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: cache: 'pip' python-version: ${{ matrix.python }} - name: Install base dependencies run: | python -m pip install --upgrade pip python -m pip install tox codecov - name: Test with tox run: | tox -e ${{ matrix.toxenv }} # This is an example of how to upload coverage to codecov # - name: Upload coverage to codecov # if: "contains(matrix.toxenv, '-cov')" # uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 # with: # file: ./coverage.xml
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- 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.
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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.