Skip to content
Latchkey

tox workflow (pytest-dev/pytest-testinfra)

The tox workflow from pytest-dev/pytest-testinfra, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: pytest-dev/pytest-testinfra.github/workflows/tox.ymlLicense Apache-2.0View source

What it does

This is the tox workflow from the pytest-dev/pytest-testinfra repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: tox

on:
  create:  # is used for publishing to TestPyPI
    tags:  # any tag regardless of its name, no branches
      - "**"
  push:  # only publishes pushes to the main branch to TestPyPI
    branches:  # any integration branch but not tag
      - "main"
  pull_request:
  release:
    types:
      - published  # It seems that you can publish directly without creating
  schedule:
    - cron: 1 0 15 * *  # Run each month on day 15 at 0:01 UTC

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
    - uses: actions/checkout@v6
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox
    - name: Run tox -e lint
      run: |
        tox -e lint
    - name: Run tox -e mypy
      run: |
        tox -e mypy
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        toxenv: [docs, packaging, py311]
    steps:
    - uses: actions/checkout@v6
    - name: Set up Python 3.11
      uses: actions/setup-python@v6
      with:
        python-version: "3.11"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox
    - name: Run tox -e ${{ matrix.toxenv }}
      run: |
        tox -e ${{ matrix.toxenv }}
  check: # This job does nothing and is only used for the branch protection
    if: always()
    permissions:
      pull-requests: write # allow codenotify to comment on pull-request
    needs:
    - lint
    - build
    runs-on: ubuntu-latest
    steps:
    - name: Decide whether the needed jobs succeeded or failed
      uses: re-actors/alls-green@release/v1
      with:
        jobs: ${{ toJSON(needs) }}

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: tox
 
on:
  create:  # is used for publishing to TestPyPI
    tags:  # any tag regardless of its name, no branches
      - "**"
  push:  # only publishes pushes to the main branch to TestPyPI
    branches:  # any integration branch but not tag
      - "main"
  pull_request:
  release:
    types:
      - published  # It seems that you can publish directly without creating
  schedule:
    - cron: 1 0 15 * *  # Run each month on day 15 at 0:01 UTC
 
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
    - uses: actions/checkout@v6
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        cache: 'pip'
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox
    - name: Run tox -e lint
      run: |
        tox -e lint
    - name: Run tox -e mypy
      run: |
        tox -e mypy
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        toxenv: [docs, packaging, py311]
    steps:
    - uses: actions/checkout@v6
    - name: Set up Python 3.11
      uses: actions/setup-python@v6
      with:
        cache: 'pip'
        python-version: "3.11"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox
    - name: Run tox -e ${{ matrix.toxenv }}
      run: |
        tox -e ${{ matrix.toxenv }}
  check: # This job does nothing and is only used for the branch protection
    timeout-minutes: 30
    if: always()
    permissions:
      pull-requests: write # allow codenotify to comment on pull-request
    needs:
    - lint
    - build
    runs-on: latchkey-small
    steps:
    - name: Decide whether the needed jobs succeeded or failed
      uses: re-actors/alls-green@release/v1
      with:
        jobs: ${{ toJSON(needs) }}
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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 3 jobs (9 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