Skip to content
Latchkey

Test Suite workflow (smithyhq/sqladmin)

The Test Suite workflow from smithyhq/sqladmin, explained and optimized by Latchkey.

C

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 →
Source: smithyhq/sqladmin.github/workflows/test-suite.ymlLicense BSD-3-ClauseView source

What it does

This is the Test Suite workflow from the smithyhq/sqladmin 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

workflow (.yml)
---
name: Test Suite

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]

jobs:
  tests:
    name: "Python ${{ matrix.python-version }} / SQLAlchemy ${{ matrix.sqlalchemy-version }}"
    runs-on: "ubuntu-latest"

    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        sqlalchemy-version: ["1.4", "2.0"]

    services:
      postgres:
        image: postgres:14-alpine
        env:
          POSTGRES_USER: username
          POSTGRES_PASSWORD: password
          POSTGRES_DB: test_db
        ports:
          - 5432:5432
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
      - uses: "actions/checkout@v3"
      - uses: "actions/setup-python@v4"
        with:
          python-version: "${{ matrix.python-version }}"
      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          python-version: "${{ matrix.python-version }}"
      - name: "Install dependencies"
        run: uv sync --all-groups
      - name: Force SQLAlchemy version
        run: uv pip install "sqlalchemy>=${{ matrix.sqlalchemy-version }}"
      - name: "Run linting checks"
        run: make lint
      - name: "Build package & docs"
        run: |
          make build
          make docs-build
      - name: "Run tests with SQLite"
        env:
          TEST_DATABASE_URI_SYNC: "sqlite:///test.db?check_same_thread=False"
          TEST_DATABASE_URI_ASYNC: "sqlite+aiosqlite:///test.db?check_same_thread=False"
        run: make test
      - name: "Run tests with PostgreSQL (pyscopg2)"
        env:
          TEST_DATABASE_URI_SYNC: "postgresql+psycopg2://username:password@localhost:5432/test_db"
          TEST_DATABASE_URI_ASYNC: "postgresql+asyncpg://username:password@localhost:5432/test_db"
        run: make test
      - name: "Run tests with PostgreSQL (pyscopg)"
        if: matrix.sqlalchemy-version == '2.0'
        env:
          TEST_DATABASE_URI_SYNC: "postgresql+psycopg://username:password@localhost:5432/test_db"
          TEST_DATABASE_URI_ASYNC: "postgresql+asyncpg://username:password@localhost:5432/test_db"
        run: make test
      - name: "Enforce coverage"
        run: make cov
      - name: "Upload Coverage"
        uses: codecov/codecov-action@v3
        with:
          files: coverage.xml

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

---
name: Test Suite
 
on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    name: "Python ${{ matrix.python-version }} / SQLAlchemy ${{ matrix.sqlalchemy-version }}"
    runs-on: "ubuntu-latest"
 
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        sqlalchemy-version: ["1.4", "2.0"]
 
    services:
      postgres:
        image: postgres:14-alpine
        env:
          POSTGRES_USER: username
          POSTGRES_PASSWORD: password
          POSTGRES_DB: test_db
        ports:
          - 5432:5432
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
 
    steps:
      - uses: "actions/checkout@v3"
      - uses: "actions/setup-python@v4"
        with:
          python-version: "${{ matrix.python-version }}"
      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          python-version: "${{ matrix.python-version }}"
      - name: "Install dependencies"
        run: uv sync --all-groups
      - name: Force SQLAlchemy version
        run: uv pip install "sqlalchemy>=${{ matrix.sqlalchemy-version }}"
      - name: "Run linting checks"
        run: make lint
      - name: "Build package & docs"
        run: |
          make build
          make docs-build
      - name: "Run tests with SQLite"
        env:
          TEST_DATABASE_URI_SYNC: "sqlite:///test.db?check_same_thread=False"
          TEST_DATABASE_URI_ASYNC: "sqlite+aiosqlite:///test.db?check_same_thread=False"
        run: make test
      - name: "Run tests with PostgreSQL (pyscopg2)"
        env:
          TEST_DATABASE_URI_SYNC: "postgresql+psycopg2://username:password@localhost:5432/test_db"
          TEST_DATABASE_URI_ASYNC: "postgresql+asyncpg://username:password@localhost:5432/test_db"
        run: make test
      - name: "Run tests with PostgreSQL (pyscopg)"
        if: matrix.sqlalchemy-version == '2.0'
        env:
          TEST_DATABASE_URI_SYNC: "postgresql+psycopg://username:password@localhost:5432/test_db"
          TEST_DATABASE_URI_ASYNC: "postgresql+asyncpg://username:password@localhost:5432/test_db"
        run: make test
      - name: "Enforce coverage"
        run: make cov
      - name: "Upload Coverage"
        uses: codecov/codecov-action@v3
        with:
          files: coverage.xml
 

What changed

2 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:

This workflow runs 1 job (10 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow