Skip to content
Latchkey

Tests workflow (mitogen-hq/mitogen)

The Tests workflow from mitogen-hq/mitogen, 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: mitogen-hq/mitogen.github/workflows/tests.ymlLicense BSD-3-ClauseView source

What it does

This is the Tests workflow from the mitogen-hq/mitogen 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)
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: Tests

# env:
#  ANSIBLE_VERBOSITY: 3
#  MITOGEN_LOG_LEVEL: DEBUG

on:
  pull_request:
  push:
    branches-ignore:
      - docs-master

# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
# https://github.com/actions/runner-images/blob/main/README.md#software-and-image-support
jobs:
  u2204:
    name: u2204 ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
    runs-on: ubuntu-22.04
    timeout-minutes: 25

    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py27-m_ans-ans2.10
          - tox_env: py27-m_ans-ans4

          - tox_env: py36-m_ans-ans2.10
          - tox_env: py36-m_ans-ans4

          - tox_env: py27-m_mtg
          - tox_env: py36-m_mtg

    steps:
      - uses: actions/checkout@v6
      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - run: .ci/show_python_versions
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"

          sudo apt-get update

          if [[ $PYTHON == "python2.7" ]]; then
              sudo apt install -y python2-dev sshpass virtualenv
              curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" --output "get-pip.py"
              "$PYTHON" get-pip.py --user --no-python-version-warning
              # Avoid Python 2.x pip masking system pip
              rm -f ~/.local/bin/{easy_install,pip,wheel}
          elif [[ $PYTHON == "python3.6" ]]; then
              sudo apt install -y gcc-10 make libbz2-dev liblzma-dev libreadline-dev libsqlite3-dev libssl-dev sshpass virtualenv zlib1g-dev
              curl --fail --silent --show-error --location https://pyenv.run | bash
              CC=gcc-10 ~/.pyenv/bin/pyenv install --force 3.6
              PYTHON="$HOME/.pyenv/versions/3.6.15/bin/python3.6"
          fi

          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"

          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"

  u2404:
    name: u2404 ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
    runs-on: ubuntu-24.04
    timeout-minutes: 25

    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py311-m_ans-ans2.10
            python_version: '3.11'
          - tox_env: py311-m_ans-ans3
            python_version: '3.11'
          - tox_env: py311-m_ans-ans4
            python_version: '3.11'
          - tox_env: py311-m_ans-ans5
            python_version: '3.11'
          - tox_env: py313-m_ans-ans6
            python_version: '3.13'
          - tox_env: py313-m_ans-ans7
            python_version: '3.13'
          - tox_env: py313-m_ans-ans8
            python_version: '3.13'
          - tox_env: py314-m_ans-ans9
            python_version: '3.14'
          - tox_env: py314-m_ans-ans10
            python_version: '3.14'
          - tox_env: py314-m_ans-ans11
            python_version: '3.14'
          - tox_env: py314-m_ans-ans12
            python_version: '3.14'
          - tox_env: py314-m_ans-ans13
            python_version: '3.14'
          - tox_env: py314-m_ans-ans14
            python_version: '3.14'

          - tox_env: py314-m_ans-ans14-s_lin
            python_version: '3.14'

          - tox_env: py314-m_mtg
            python_version: '3.14'

    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python_version }}
        if: ${{ matrix.python_version }}
      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - run: .ci/show_python_versions
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"

          sudo apt-get update
          sudo apt-get install -y sshpass virtualenv

          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"

          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"

  macos:
    name: macos ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
    runs-on: macos-15
    timeout-minutes: 20
    env:
      MITOGEN_TEST_SKIP_CONTAINER_TESTS: 1

    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py314-m_lcl-ans14
            python_version: '3.14'
          - tox_env: py314-m_lcl-ans14-s_lin
            python_version: '3.14'

          - tox_env: py314-m_mtg
            python_version: '3.14'

    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python_version }}
        if: ${{ matrix.python_version }}
      - run: .ci/show_python_versions
      - run: .ci/install_sshpass ${{ matrix.sshpass_version }}
        if: ${{ matrix.sshpass_version }}
      - run: .ci/setup_ssh_key_localhost
        if: ${{ contains(matrix.tox_env, 'm_lcl') }}
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"

          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"

          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"

  # https://github.com/marketplace/actions/alls-green
  check:
    if: always()
    needs:
      - u2204
      - u2404
      - macos
    runs-on: ubuntu-latest
    steps:
      - 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.

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
 
name: Tests
 
# env:
#  ANSIBLE_VERBOSITY: 3
#  MITOGEN_LOG_LEVEL: DEBUG
 
on:
  pull_request:
  push:
    branches-ignore:
      - docs-master
 
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
# https://github.com/actions/runner-images/blob/main/README.md#software-and-image-support
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  u2204:
    name: u2204 ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
    runs-on: latchkey-small
    timeout-minutes: 25
 
    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py27-m_ans-ans2.10
          - tox_env: py27-m_ans-ans4
 
          - tox_env: py36-m_ans-ans2.10
          - tox_env: py36-m_ans-ans4
 
          - tox_env: py27-m_mtg
          - tox_env: py36-m_mtg
 
    steps:
      - uses: actions/checkout@v6
      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - run: .ci/show_python_versions
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
 
          sudo apt-get update
 
          if [[ $PYTHON == "python2.7" ]]; then
              sudo apt install -y python2-dev sshpass virtualenv
              curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" --output "get-pip.py"
              "$PYTHON" get-pip.py --user --no-python-version-warning
              # Avoid Python 2.x pip masking system pip
              rm -f ~/.local/bin/{easy_install,pip,wheel}
          elif [[ $PYTHON == "python3.6" ]]; then
              sudo apt install -y gcc-10 make libbz2-dev liblzma-dev libreadline-dev libsqlite3-dev libssl-dev sshpass virtualenv zlib1g-dev
              curl --fail --silent --show-error --location https://pyenv.run | bash
              CC=gcc-10 ~/.pyenv/bin/pyenv install --force 3.6
              PYTHON="$HOME/.pyenv/versions/3.6.15/bin/python3.6"
          fi
 
          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
 
          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
 
  u2404:
    name: u2404 ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
    runs-on: latchkey-small
    timeout-minutes: 25
 
    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py311-m_ans-ans2.10
            python_version: '3.11'
          - tox_env: py311-m_ans-ans3
            python_version: '3.11'
          - tox_env: py311-m_ans-ans4
            python_version: '3.11'
          - tox_env: py311-m_ans-ans5
            python_version: '3.11'
          - tox_env: py313-m_ans-ans6
            python_version: '3.13'
          - tox_env: py313-m_ans-ans7
            python_version: '3.13'
          - tox_env: py313-m_ans-ans8
            python_version: '3.13'
          - tox_env: py314-m_ans-ans9
            python_version: '3.14'
          - tox_env: py314-m_ans-ans10
            python_version: '3.14'
          - tox_env: py314-m_ans-ans11
            python_version: '3.14'
          - tox_env: py314-m_ans-ans12
            python_version: '3.14'
          - tox_env: py314-m_ans-ans13
            python_version: '3.14'
          - tox_env: py314-m_ans-ans14
            python_version: '3.14'
 
          - tox_env: py314-m_ans-ans14-s_lin
            python_version: '3.14'
 
          - tox_env: py314-m_mtg
            python_version: '3.14'
 
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python_version }}
        if: ${{ matrix.python_version }}
      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - run: .ci/show_python_versions
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
 
          sudo apt-get update
          sudo apt-get install -y sshpass virtualenv
 
          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
 
          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
 
  macos:
    name: macos ${{ matrix.tox_env }}
    # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
    runs-on: macos-15
    timeout-minutes: 20
    env:
      MITOGEN_TEST_SKIP_CONTAINER_TESTS: 1
 
    strategy:
      fail-fast: false
      matrix:
        include:
          - tox_env: py314-m_lcl-ans14
            python_version: '3.14'
          - tox_env: py314-m_lcl-ans14-s_lin
            python_version: '3.14'
 
          - tox_env: py314-m_mtg
            python_version: '3.14'
 
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python_version }}
        if: ${{ matrix.python_version }}
      - run: .ci/show_python_versions
      - run: .ci/install_sshpass ${{ matrix.sshpass_version }}
        if: ${{ matrix.sshpass_version }}
      - run: .ci/setup_ssh_key_localhost
        if: ${{ contains(matrix.tox_env, 'm_lcl') }}
      - run: .ci/setup_ssh_key_mitogen__has_sudo_pubkey
      - run: .ci/setup_sudoers_defaults
        if: ${{ contains(matrix.tox_env, 'm_mtg') }}
      - name: Install deps
        id: install-deps
        run: |
          set -o errexit -o nounset -o pipefail
          source .ci/bash_functions
          PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
 
          "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
          echo "python=$PYTHON" >> $GITHUB_OUTPUT
      - name: Create environments
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
          "$PYTHON" -m tox --notest -e "${{ matrix.tox_env }}"
      - name: Run tests
        env:
          GITHUB_ACTOR: ${{ github.actor }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o errexit -o nounset -o pipefail
          PYTHON="${{ steps.install-deps.outputs.python }}"
 
          "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
 
  # https://github.com/marketplace/actions/alls-green
  check:
    timeout-minutes: 30
    if: always()
    needs:
      - u2204
      - u2404
      - macos
    runs-on: latchkey-small
    steps:
      - uses: re-actors/alls-green@release/v1
        with:
          jobs: ${{ toJSON(needs) }}
 

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 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow