Skip to content
Latchkey

CI workflow (nateshmbhat/pyttsx3)

The CI workflow from nateshmbhat/pyttsx3, 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: nateshmbhat/pyttsx3.github/workflows/python_publish.ymlLicense MPL-2.0View source

What it does

This is the CI workflow from the nateshmbhat/pyttsx3 repository, a real project running GitHub Actions. It is shown here with attribution under its MPL-2.0 license.

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

The workflow

workflow (.yml)
# This workflow will upload a Python Package using Twine when a release is created.
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# CAUTION: Renaming this file will break Trusted Publishing to PyPI.
# https://github.com/pypa/gh-action-pypi-publish

name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
  release:
    types: [created]  # Only publish on tagged releases

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - run: pipx install pre-commit
      - run: pre-commit install
      - run: pre-commit run --all-files

  test:
    needs: [pre-commit]
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
        python-version: ['3.10', '3.12', '3.14', '3.14t']
        exclude:  # https://github.com/nateshmbhat/pyttsx3/pull/430
          - os: windows-latest
            python-version: '3.14t'
        include:
          - os: macos-26
            python-version: '3.x'

    runs-on: ${{ matrix.os }}
    steps:
      - if: runner.os == 'Linux'
        run: sudo apt-get update -q -q && sudo apt-get install --yes espeak-ng libespeak1
      - if: runner.os == 'macOS'
        run: brew install espeak-ng
      - name: Download and install eSpeak-NG
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Invoke-WebRequest -Uri "https://github.com/espeak-ng/espeak-ng/releases/download/1.51/espeak-ng-X64.msi" -OutFile "espeak-ng.msi"
          Start-Process msiexec.exe -ArgumentList '/i espeak-ng.msi /quiet /norestart' -Wait
          # dir "$env:ProgramFiles\eSpeak NG"
          $env:Path += ";$env:ProgramFiles\eSpeak NG"
          espeak-ng --version
      - if: runner.os != 'Windows'
        run: espeak-ng --version

      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true

      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install pytest pytest-run-parallel
          pip install --editable .

      - timeout-minutes: 15  # Save resources while our pytests are hanging
        run: pytest --full-trace -s -vvv --strict
      - if: runner.os == 'Linux'
        timeout-minutes: 15  # Save resources while our pytests are hanging
        run: pytest --full-trace --iterations=8 -s --strict
      #- timeout-minutes: 15  # Save resources while our pytests are hanging
      #  env:
      #    PYTEST_RUN_PARALLEL_VERBOSE: 1
      #  run: pytest --full-trace --parallel-threads=auto --strict tests/test_engines.py || true
      #- timeout-minutes: 15  # Save resources while our pytests are hanging
      #  env:
      #    PYTEST_RUN_PARALLEL_VERBOSE: 1
      #  run: pytest --full-trace --parallel-threads=auto --strict tests/test_pyttsx3.py || true

  build:
    runs-on: ubuntu-latest
    needs: [test]  # This ensures tests pass before build
    permissions:
      id-token: write

    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.x'

      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install build

      - name: Clean previous builds
        run: |
          rm -rf dist

      - name: Build package
        run: |
          python -m build
          pipx run twine check --strict dist/*

      - name: Upload dist
        uses: actions/upload-artifact@v6
        with:
          name: dist
          path: dist

  deploy:
    needs: [build]
    runs-on: ubuntu-latest
    environment:
      name: "pypi"
      url: https://pypi.org/p/pyttsx3
    permissions:
      id-token: write  # IMPORTANT: this permission is mandatory for trusted publishing
    if: github.event_name == 'release' && github.event.action == 'created'  # Only on release creation

    steps:
      - name: Download dist
        uses: actions/download-artifact@v7
        with:
          name: dist
          path: dist
      - run: pipx run twine check --strict dist/*
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          print-hash: true

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.

# This workflow will upload a Python Package using Twine when a release is created.
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
 
# CAUTION: Renaming this file will break Trusted Publishing to PyPI.
# https://github.com/pypa/gh-action-pypi-publish
 
name: CI
 
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
  release:
    types: [created]  # Only publish on tagged releases
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - run: pipx install pre-commit
      - run: pre-commit install
      - run: pre-commit run --all-files
 
  test:
    timeout-minutes: 30
    needs: [pre-commit]
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
        python-version: ['3.10', '3.12', '3.14', '3.14t']
        exclude:  # https://github.com/nateshmbhat/pyttsx3/pull/430
          - os: windows-latest
            python-version: '3.14t'
        include:
          - os: macos-26
            python-version: '3.x'
 
    runs-on: ${{ matrix.os }}
    steps:
      - if: runner.os == 'Linux'
        run: sudo apt-get update -q -q && sudo apt-get install --yes espeak-ng libespeak1
      - if: runner.os == 'macOS'
        run: brew install espeak-ng
      - name: Download and install eSpeak-NG
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Invoke-WebRequest -Uri "https://github.com/espeak-ng/espeak-ng/releases/download/1.51/espeak-ng-X64.msi" -OutFile "espeak-ng.msi"
          Start-Process msiexec.exe -ArgumentList '/i espeak-ng.msi /quiet /norestart' -Wait
          # dir "$env:ProgramFiles\eSpeak NG"
          $env:Path += ";$env:ProgramFiles\eSpeak NG"
          espeak-ng --version
      - if: runner.os != 'Windows'
        run: espeak-ng --version
 
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
 
      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install pytest pytest-run-parallel
          pip install --editable .
 
      - timeout-minutes: 15  # Save resources while our pytests are hanging
        run: pytest --full-trace -s -vvv --strict
      - if: runner.os == 'Linux'
        timeout-minutes: 15  # Save resources while our pytests are hanging
        run: pytest --full-trace --iterations=8 -s --strict
      #- timeout-minutes: 15  # Save resources while our pytests are hanging
      #  env:
      #    PYTEST_RUN_PARALLEL_VERBOSE: 1
      #  run: pytest --full-trace --parallel-threads=auto --strict tests/test_engines.py || true
      #- timeout-minutes: 15  # Save resources while our pytests are hanging
      #  env:
      #    PYTEST_RUN_PARALLEL_VERBOSE: 1
      #  run: pytest --full-trace --parallel-threads=auto --strict tests/test_pyttsx3.py || true
 
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    needs: [test]  # This ensures tests pass before build
    permissions:
      id-token: write
 
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: '3.x'
 
      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install build
 
      - name: Clean previous builds
        run: |
          rm -rf dist
 
      - name: Build package
        run: |
          python -m build
          pipx run twine check --strict dist/*
 
      - name: Upload dist
        uses: actions/upload-artifact@v6
        with:
          name: dist
          path: dist
 
  deploy:
    timeout-minutes: 30
    needs: [build]
    runs-on: latchkey-small
    environment:
      name: "pypi"
      url: https://pypi.org/p/pyttsx3
    permissions:
      id-token: write  # IMPORTANT: this permission is mandatory for trusted publishing
    if: github.event_name == 'release' && github.event.action == 'created'  # Only on release creation
 
    steps:
      - name: Download dist
        uses: actions/download-artifact@v7
        with:
          name: dist
          path: dist
      - run: pipx run twine check --strict dist/*
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          print-hash: true
 

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 4 jobs (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