Test workflow (explosion/srsly)
The Test workflow from explosion/srsly, explained and optimized by Latchkey.
CI health: C - fair
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 Test workflow from the explosion/srsly 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: Test
on:
push:
branches: [master]
pull_request:
branches: ["*"]
workflow_dispatch: # allows you to trigger manually
# When this workflow is queued, automatically cancel any previous running
# or pending jobs from the same branch
concurrency:
group: Test-${{ github.ref }}
cancel-in-progress: true
env:
RUN_MYPY: 'false'
jobs:
tests:
name: ${{ matrix.python_version }} ${{ matrix.os }} numpy=${{ matrix.numpy }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
# Note: ruamel.yaml does not support Python 3.13t
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]
numpy: [true]
include:
- os: ubuntu-latest
python_version: "3.9"
numpy: false
- os: ubuntu-latest
python_version: "3.14"
numpy: false
runs-on: ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v5
- name: Configure Python version
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Run mypy
if: ${{ env.RUN_MYPY == 'true' }}
run: |
python -m pip install mypy
python -m mypy srsly
- name: Install package
run: python -m pip install .
- name: Test that numpy was not installed
shell: bash
run: if pip list | grep -q '^numpy'; then exit 1; fi
- name: Install numpy
if: ${{ matrix.numpy }}
run: python -m pip install numpy
- name: Install test requirements
run: python -m pip install pytest
- name: Run tests
run: pytest
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: Test on: push: branches: [master] pull_request: branches: ["*"] workflow_dispatch: # allows you to trigger manually # When this workflow is queued, automatically cancel any previous running # or pending jobs from the same branch concurrency: group: Test-${{ github.ref }} cancel-in-progress: true env: RUN_MYPY: 'false' jobs: tests: timeout-minutes: 30 name: ${{ matrix.python_version }} ${{ matrix.os }} numpy=${{ matrix.numpy }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] # Note: ruamel.yaml does not support Python 3.13t python_version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] numpy: [true] include: - os: ubuntu-latest python_version: "3.9" numpy: false - os: ubuntu-latest python_version: "3.14" numpy: false runs-on: ${{ matrix.os }} steps: - name: Check out repo uses: actions/checkout@v5 - name: Configure Python version uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ matrix.python_version }} - name: Run mypy if: ${{ env.RUN_MYPY == 'true' }} run: | python -m pip install mypy python -m mypy srsly - name: Install package run: python -m pip install . - name: Test that numpy was not installed shell: bash run: if pip list | grep -q '^numpy'; then exit 1; fi - name: Install numpy if: ${{ matrix.numpy }} run: python -m pip install numpy - name: Install test requirements run: python -m pip install pytest - name: Run tests run: pytest
What changed
- 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 (14 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.