Tests workflow (strawberry-graphql/strawberry-django)
The Tests workflow from strawberry-graphql/strawberry-django, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Tests workflow from the strawberry-graphql/strawberry-django 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: Tests
# yamllint disable-line rule:truthy
on:
push:
branches:
- main
- v*
pull_request:
branches:
- main
- v*
release:
types:
- released
jobs:
typing:
name: Typing
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install Deps
run: uv sync
- name: Check for pyright errors
uses: jakebailey/pyright-action@v2
with:
python-path: .venv/bin/python3
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
django-version:
- 5.2.*
- 6.0.*
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
mode:
- std
- geos
gql-core:
- '3.2'
- '3.3'
exclude:
# Django 6.0 only supports python 3.12+
- django-version: 6.0.*
python-version: '3.10'
- django-version: 6.0.*
python-version: '3.11'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install OS Dependencies
if: ${{ matrix.mode == 'geos' }}
run: |
sudo apt-get update
sudo apt-get install -y binutils gdal-bin libproj-dev libsqlite3-mod-spatialite
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install Deps
run: uv sync
- name: Install Django ${{ matrix.django-version }}
run: uv pip install "django==${{ matrix.django-version }}"
- name: Install graphql-core ${{ matrix.gql-core }}
run: |
if [ "${{ matrix.gql-core }}" = "3.2" ]; then
uv pip install "graphql-core>=3.2.0,<3.3.0"
else
uv pip install "graphql-core==3.3.0a12"
fi
- name: Test with pytest
run: uv run --no-sync pytest -n auto --showlocals -vvv --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
--- name: Tests # yamllint disable-line rule:truthy on: push: branches: - main - v* pull_request: branches: - main - v* release: types: - released concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: typing: timeout-minutes: 30 name: Typing runs-on: latchkey-small steps: - name: Checkout uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v7 with: enable-cache: true - name: Install Deps run: uv sync - name: Check for pyright errors uses: jakebailey/pyright-action@v2 with: python-path: .venv/bin/python3 tests: timeout-minutes: 30 runs-on: latchkey-small strategy: fail-fast: false matrix: django-version: - 5.2.* - 6.0.* python-version: - '3.10' - '3.11' - '3.12' - '3.13' - '3.14' mode: - std - geos gql-core: - '3.2' - '3.3' exclude: # Django 6.0 only supports python 3.12+ - django-version: 6.0.* python-version: '3.10' - django-version: 6.0.* python-version: '3.11' steps: - name: Checkout uses: actions/checkout@v4 - name: Install OS Dependencies if: ${{ matrix.mode == 'geos' }} run: | sudo apt-get update sudo apt-get install -y binutils gdal-bin libproj-dev libsqlite3-mod-spatialite - name: Install uv uses: astral-sh/setup-uv@v7 with: enable-cache: true python-version: ${{ matrix.python-version }} - name: Install Deps run: uv sync - name: Install Django ${{ matrix.django-version }} run: uv pip install "django==${{ matrix.django-version }}" - name: Install graphql-core ${{ matrix.gql-core }} run: | if [ "${{ matrix.gql-core }}" = "3.2" ]; then uv pip install "graphql-core>=3.2.0,<3.3.0" else uv pip install "graphql-core==3.3.0a12" fi - name: Test with pytest run: uv run --no-sync pytest -n auto --showlocals -vvv --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_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. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
3 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 2 jobs (41 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.