Skip to content
Latchkey

test workflow (snok/django-guid)

The test workflow from snok/django-guid, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: snok/django-guid.github/workflows/test.ymlLicense MITView source

What it does

This is the test workflow from the snok/django-guid 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

workflow (.yml)
name: test

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  linting:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: "3.11"
      - run: pip install pre-commit
      - run: pre-commit run --all-files
        env:
          SKIP: rst

  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
        django-version: [ "4.2", "5.0", "5.1", "5.2", "6.0" ]
        exclude:
          # Django 4.2 does not support Python 3.13+
          - django-version: "4.2"
            python-version: "3.13"
          - django-version: "4.2"
            python-version: "3.14"
          # Django 5.x drops Python <3.10 support
          - django-version: "5.0"
            python-version: "3.8"
          - django-version: "5.0"
            python-version: "3.9"
          - django-version: "5.1"
            python-version: "3.8"
          - django-version: "5.1"
            python-version: "3.9"
          - django-version: "5.2"
            python-version: "3.8"
          - django-version: "5.2"
            python-version: "3.9"
          # Django 5.0 does not support Python 3.13+
          - django-version: "5.0"
            python-version: "3.13"
          - django-version: "5.0"
            python-version: "3.14"
          # Django 6.0 requires Python 3.13+
          - django-version: "6.0"
            python-version: "3.8"
          - django-version: "6.0"
            python-version: "3.9"
          - django-version: "6.0"
            python-version: "3.10"
          - django-version: "6.0"
            python-version: "3.11"
          - django-version: "6.0"
            python-version: "3.12"
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: "${{ matrix.python-version }}"
      - uses: snok/install-poetry@v1
        with:
          virtualenvs-create: false
          version: 1.8.5
      - run: |
          pip install virtualenv
          virtualenv .venv
          source .venv/bin/activate
          pip install pip setuptools wheel -U
          poetry install --no-interaction --no-root
      - run: |
          source .venv/bin/activate
          pip install "Django==${{ matrix.django-version }}"
      - name: Run tests
        run: |
          source .venv/bin/activate
          coverage run -m pytest tests
          coverage xml
          coverage report
      - uses: codecov/codecov-action@v2
        with:
          file: ./coverage.xml
          fail_ci_if_error: true
        if: matrix.python-version == '3.11'

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:
  pull_request:
  push:
    branches:
      - master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  linting:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: "3.11"
      - run: pip install pre-commit
      - run: pre-commit run --all-files
        env:
          SKIP: rst
 
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
        django-version: [ "4.2", "5.0", "5.1", "5.2", "6.0" ]
        exclude:
          # Django 4.2 does not support Python 3.13+
          - django-version: "4.2"
            python-version: "3.13"
          - django-version: "4.2"
            python-version: "3.14"
          # Django 5.x drops Python <3.10 support
          - django-version: "5.0"
            python-version: "3.8"
          - django-version: "5.0"
            python-version: "3.9"
          - django-version: "5.1"
            python-version: "3.8"
          - django-version: "5.1"
            python-version: "3.9"
          - django-version: "5.2"
            python-version: "3.8"
          - django-version: "5.2"
            python-version: "3.9"
          # Django 5.0 does not support Python 3.13+
          - django-version: "5.0"
            python-version: "3.13"
          - django-version: "5.0"
            python-version: "3.14"
          # Django 6.0 requires Python 3.13+
          - django-version: "6.0"
            python-version: "3.8"
          - django-version: "6.0"
            python-version: "3.9"
          - django-version: "6.0"
            python-version: "3.10"
          - django-version: "6.0"
            python-version: "3.11"
          - django-version: "6.0"
            python-version: "3.12"
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: "${{ matrix.python-version }}"
      - uses: snok/install-poetry@v1
        with:
          virtualenvs-create: false
          version: 1.8.5
      - run: |
          pip install virtualenv
          virtualenv .venv
          source .venv/bin/activate
          pip install pip setuptools wheel -U
          poetry install --no-interaction --no-root
      - run: |
          source .venv/bin/activate
          pip install "Django==${{ matrix.django-version }}"
      - name: Run tests
        run: |
          source .venv/bin/activate
          coverage run -m pytest tests
          coverage xml
          coverage report
      - uses: codecov/codecov-action@v2
        with:
          file: ./coverage.xml
          fail_ci_if_error: true
        if: matrix.python-version == '3.11'
 

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 2 jobs (36 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