Skip to content
Latchkey

Tests workflow (pndurette/gTTS)

The Tests workflow from pndurette/gTTS, explained and optimized by Latchkey.

F

CI health: F - at risk

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: pndurette/gTTS.github/workflows/test.ymlLicense MITView source

What it does

This is the Tests workflow from the pndurette/gTTS 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: Tests

on:
  pull_request:
    branches:
      - main
    paths:
      - 'gtts/**'
      - 'pyproject.toml'

  push:
    # Creates a status check for the main branch
    # (so the badge on the README can show
    # the status of the main branch)
    branches:
      - main

jobs:
  test:
    name: Unit

    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
        os: [ubuntu-latest, macOS-latest, windows-latest]

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install
        run: |
          python -m pip install --upgrade pip
          pip install .[tests]

      - name: Unit Tests
        run: pytest -v --cov=gtts --cov-report=xml
        env:
          # TODO: Test all langs on release branch
          TEST_LANGS: en

      - name: Upload Coverage Report
        if: github.event_name == 'pull_request'
        uses: codecov/codecov-action@v5.3.1

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: Tests
 
on:
  pull_request:
    branches:
      - main
    paths:
      - 'gtts/**'
      - 'pyproject.toml'
 
  push:
    # Creates a status check for the main branch
    # (so the badge on the README can show
    # the status of the main branch)
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: Unit
 
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
        os: [ubuntu-latest, macOS-latest, windows-latest]
 
    steps:
      - uses: actions/checkout@v4
 
      - uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
      - name: Install
        run: |
          python -m pip install --upgrade pip
          pip install .[tests]
 
      - name: Unit Tests
        run: pytest -v --cov=gtts --cov-report=xml
        env:
          # TODO: Test all langs on release branch
          TEST_LANGS: en
 
      - name: Upload Coverage Report
        if: github.event_name == 'pull_request'
        uses: codecov/codecov-action@v5.3.1
 

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 1 job (15 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