Skip to content
Latchkey

Run tests workflow (hsahovic/poke-env)

The Run tests workflow from hsahovic/poke-env, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get caching, 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: hsahovic/poke-env.github/workflows/tests.ymlLicense MITView source

What it does

This is the Run tests workflow from the hsahovic/poke-env 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: Run tests
on:
  workflow_call:
  push:
    branches:
      - "master"
  pull_request:
    branches:
      - "master"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}

jobs:
  tests:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    strategy:
      matrix:
        version: ['3.10', '3.11', '3.12', '3.13', '3.14']

    steps:
      - name: Checkout repository code
        uses: actions/checkout@v7

      # Setup Python
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.version }}

      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true

      - name: Install dependencies
        run: uv sync --dev

      - name: Run tests
        run: uv run pytest -x --cov=src/poke_env unit_tests/

      - name: Convert coverage to XML
        run: uv run coverage xml

      - name: Upload coverage report to Codecov
        uses: codecov/codecov-action@v7
        with:
          file: coverage.xml

      - name: Build package
        run: uv build

      - name: Install built package
        run: uv pip install -p .venv/bin/python --reinstall dist/*.whl

      - name: Remove source
        run: rm -rf ./src

      - name: Run package-based tests
        run: uv run --no-sync pytest -x unit_tests/

      - name: Setup node
        uses: actions/setup-node@v6
        with:
          node-version: 18

      - name: Checkout PS
        uses: actions/checkout@v7
        with:
          repository: smogon/pokemon-showdown
          path: pokemon-showdown
          submodules: recursive

      - name: Get last showdown commit hash
        id: showdown-hash
        run: |
          cd pokemon-showdown/
          export hash=`git log -1 --pretty=format:%H`
          echo "hash=$hash" >> $GITHUB_OUTPUT

      - name: Restore server cache
        uses: actions/cache@v6
        with:
          path: pokemon-showdown/node_modules
          key: showdown-python${{ matrix.version }}-${{ steps.showdown-hash.outputs.hash }}
          restore-keys: showdown-python${{ matrix.version }}-

      - name: Install PS dependencies and start server
        run: bash scripts/ci_setup_showdown.sh

      - name: Run integration tests
        run: uv run --no-sync pytest -x integration_tests/

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: Run tests
on:
  workflow_call:
  push:
    branches:
      - "master"
  pull_request:
    branches:
      - "master"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
 
jobs:
  tests:
    runs-on: latchkey-small
    timeout-minutes: 10
 
    strategy:
      matrix:
        version: ['3.10', '3.11', '3.12', '3.13', '3.14']
 
    steps:
      - name: Checkout repository code
        uses: actions/checkout@v7
 
      # Setup Python
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.version }}
 
      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
 
      - name: Install dependencies
        run: uv sync --dev
 
      - name: Run tests
        run: uv run pytest -x --cov=src/poke_env unit_tests/
 
      - name: Convert coverage to XML
        run: uv run coverage xml
 
      - name: Upload coverage report to Codecov
        uses: codecov/codecov-action@v7
        with:
          file: coverage.xml
 
      - name: Build package
        run: uv build
 
      - name: Install built package
        run: uv pip install -p .venv/bin/python --reinstall dist/*.whl
 
      - name: Remove source
        run: rm -rf ./src
 
      - name: Run package-based tests
        run: uv run --no-sync pytest -x unit_tests/
 
      - name: Setup node
        uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 18
 
      - name: Checkout PS
        uses: actions/checkout@v7
        with:
          repository: smogon/pokemon-showdown
          path: pokemon-showdown
          submodules: recursive
 
      - name: Get last showdown commit hash
        id: showdown-hash
        run: |
          cd pokemon-showdown/
          export hash=`git log -1 --pretty=format:%H`
          echo "hash=$hash" >> $GITHUB_OUTPUT
 
      - name: Restore server cache
        uses: actions/cache@v6
        with:
          path: pokemon-showdown/node_modules
          key: showdown-python${{ matrix.version }}-${{ steps.showdown-hash.outputs.hash }}
          restore-keys: showdown-python${{ matrix.version }}-
 
      - name: Install PS dependencies and start server
        run: bash scripts/ci_setup_showdown.sh
 
      - name: Run integration tests
        run: uv run --no-sync pytest -x integration_tests/
 

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