Skip to content
Latchkey LogoLatchkey home

Test workflow (django/django-localflavor)

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

Source: django/django-localflavor.github/workflows/test.ymlLicense BSD-3-ClauseView source
D
CI health grade
53/100
Health score
3
Jobs per trigger
4
Fixes in the optimized version

In short

  1. CI health: D (needs work)
  2. The optimized version below points runs-on at Latchkey managed runners and adds run de-duplication, caching, and job timeouts.

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.

workflow (.yml), optimized
name: Test

on:
  push:
    branches:
      - master
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  docs:
    runs-on: ubuntu-latest
    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:
    runs-on: ubuntu-latest
    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:
    runs-on: ubuntu-latest
    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

  1. Run on Latchkey managed runners with one line (runs-on), which apply the fixes below automatically and self-heal transient failures. Each Linux x64 job moves to the Latchkey size matching its vCPU count, latchkey-small for a standard 2 vCPU runner; macOS, Windows and arm64 jobs stay as written.
  2. Cancel superseded runs when a branch or PR gets a newer push.
  3. Cache dependency installs on the setup step so they are served from cache.
  4. 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. All of them run on a standard GitHub-hosted Linux x64 runner, which in a private repository bills $0.006 a minute against $0.0025 on latchkey-small, 58% lower; in a public repository like this one they are free. Estimate the monthly difference with your own run counts.

Actions used in this workflow

  • actions/checkout
  • actions/setup-python

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?
Add run de-duplication, caching, and job timeouts. Latchkey applies these automatically on managed runners when you point runs-on at Latchkey.

References