Run tests workflow (sqlalchemy/alembic)
The Run tests workflow from sqlalchemy/alembic, 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 Run tests workflow from the sqlalchemy/alembic 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: Run tests
on:
# run on push in main or rel_* branches excluding changes are only on doc or example folders
push:
branches:
- main
- "rel_*"
# branches used to test the workflow
- "workflow_test_*"
paths-ignore:
- "docs/**"
env:
# global env to all steps
TOX_WORKERS: -n2
permissions:
contents: read
jobs:
run-test:
name: ${{ matrix.python-version }}-${{ matrix.sqlalchemy }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# run this job using this matrix, excluding some combinations below.
matrix:
os:
- "ubuntu-22.04"
- "windows-latest"
- "macos-latest"
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
sqlalchemy:
- sqla14
- sqla20
- sqlamain
exclude:
# sqla14 does not support 3.13+
- sqlalchemy: sqla14
python-version: "3.13"
fail-fast: false
# steps to run in each job. Some are github actions, others run shell commands
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Set up python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade nox setuptools
pip list
- name: Run tests
run: nox -t py-${{ matrix.sqlalchemy }}
run-pep484:
name: pep484-${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
- "3.12"
- "3.13"
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Set up python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade nox setuptools
pip list
- name: Run nox pep484
run: nox -s pep484
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: Run tests on: # run on push in main or rel_* branches excluding changes are only on doc or example folders push: branches: - main - "rel_*" # branches used to test the workflow - "workflow_test_*" paths-ignore: - "docs/**" env: # global env to all steps TOX_WORKERS: -n2 permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: run-test: timeout-minutes: 30 name: ${{ matrix.python-version }}-${{ matrix.sqlalchemy }}-${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: # run this job using this matrix, excluding some combinations below. matrix: os: - "ubuntu-22.04" - "windows-latest" - "macos-latest" python-version: - "3.10" - "3.11" - "3.12" - "3.13" sqlalchemy: - sqla14 - sqla20 - sqlamain exclude: # sqla14 does not support 3.13+ - sqlalchemy: sqla14 python-version: "3.13" fail-fast: false # steps to run in each job. Some are github actions, others run shell commands steps: - name: Checkout repo uses: actions/checkout@v7 - name: Set up python uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade nox setuptools pip list - name: Run tests run: nox -t py-${{ matrix.sqlalchemy }} run-pep484: timeout-minutes: 30 name: pep484-${{ matrix.python-version }}-${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: - "ubuntu-latest" python-version: - "3.12" - "3.13" fail-fast: false steps: - name: Checkout repo uses: actions/checkout@v7 - name: Set up python uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade nox setuptools pip list - name: Run nox pep484 run: nox -s pep484
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 2 jobs (38 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.