Skip to content
Latchkey

Test workflow (django/django-localflavor)

The Test workflow from django/django-localflavor, explained and optimized by Latchkey.

D

CI health: D - needs work

The optimized version below adds caching, run de-duplication, job timeouts.

Source: django/django-localflavor.github/workflows/test.ymlLicense BSD-3-ClauseView source

What it does

This is the Test workflow from the django/django-localflavor 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

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'
          architecture: x64
      - name: Install tox
        run: |
          python -m pip install --upgrade pip
          python -m pip install --upgrade 'tox>=4.0'
      - name: Run docs test build
        run: tox -e docs

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'
          architecture: x64
      - name: Install tox
        run: |
          python -m pip install --upgrade pip
          python -m pip install --upgrade 'tox>=4.0'
      - name: Run prospector linting
        run: tox -e prospector

  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
          - '3.9'
          - '3.10'
          - '3.11'
          - '3.12'
          - '3.13'
          - '3.14'
    name: Python ${{ matrix.python-version }}
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          architecture: x64
      - name: Install tox
        run: |
          python -m pip install --upgrade pip
          python -m pip install --upgrade 'tox>=4.0'
      - name: Run tests
        run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)

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: concurrency:  group: ${{ github.workflow }}-${{ github.ref }}  cancel-in-progress: true jobs:  docs:    timeout-minutes: 30    runs-on: latchkey-small    steps:      - uses: actions/checkout@v6      - name: Set up Python        uses: actions/setup-python@v6        with:          cache: 'pip'          python-version: '3.13'          architecture: x64      - name: Install tox        run: |          python -m pip install --upgrade pip          python -m pip install --upgrade 'tox>=4.0'      - name: Run docs test build        run: tox -e docs   lint:    timeout-minutes: 30    runs-on: latchkey-small    steps:      - uses: actions/checkout@v6      - name: Set up Python        uses: actions/setup-python@v6        with:          cache: 'pip'          python-version: '3.13'          architecture: x64      - name: Install tox        run: |          python -m pip install --upgrade pip          python -m pip install --upgrade 'tox>=4.0'      - name: Run prospector linting        run: tox -e prospector   test:    timeout-minutes: 30    runs-on: latchkey-small    strategy:      matrix:        python-version:          - '3.9'          - '3.10'          - '3.11'          - '3.12'          - '3.13'          - '3.14'    name: Python ${{ matrix.python-version }}    steps:      - uses: actions/checkout@v6      - name: Set up Python        uses: actions/setup-python@v6        with:          cache: 'pip'          python-version: ${{ matrix.python-version }}          architecture: x64      - name: Install tox        run: |          python -m pip install --upgrade pip          python -m pip install --upgrade 'tox>=4.0'      - name: Run tests        run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) 

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 uses latchkey-small; pick the runner size that fits the job.
  • 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 3 jobs (8 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

Frequently asked questions

What does the Test workflow (django/django-localflavor) workflow do?
This is the Test workflow from the django/django-localflavor repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
What CI health grade does this workflow get?
This Python workflow grades D. Paste your own workflow into the Latchkey grader to see its grade and the exact fixes.
How can I improve this Python workflow?
Apply caching, run de-duplication, job timeouts. Latchkey applies these automatically on managed runners when you point runs-on at Latchkey.

References