Skip to content
Latchkey

Check examples run workflow (hsahovic/poke-env)

The Check examples run 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/check-examples.ymlLicense MITView source

What it does

This is the Check examples run 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: Check examples run
on:
  push:
    branches:
      - "master"
  pull_request:
    branches:
      - "master"

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

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

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

      # Setup Python
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.11

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

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

      - name: Install Python Kernel
        run: |
          uv pip install -p .venv/bin/python ipykernel
          uv run python -m ipykernel install --user --name python3

      - 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: 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-python3.11-${{ steps.showdown-hash.outputs.hash }}
          restore-keys: showdown-python3.11-

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

      - name: Run example notebooks
        run: |
            for notebook in $(find examples -name '*.ipynb'); do
              uv run --no-sync jupyter nbconvert --to notebook --execute "$notebook" --output temp.ipynb
              if [ $? -ne 0 ]; then
              echo "Execution of $notebook failed"
              exit 1
              fi
              rm examples/temp.ipynb
            done

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: Check examples run
on:
  push:
    branches:
      - "master"
  pull_request:
    branches:
      - "master"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
 
jobs:
  tests:
    runs-on: latchkey-small
    timeout-minutes: 10
 
    steps:
      - name: Checkout repository code
        uses: actions/checkout@v7
 
      # Setup Python
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.11
 
      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
 
      - name: Install dependencies
        run: uv sync --dev
 
      - name: Install Python Kernel
        run: |
          uv pip install -p .venv/bin/python ipykernel
          uv run python -m ipykernel install --user --name python3
 
      - 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: 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-python3.11-${{ steps.showdown-hash.outputs.hash }}
          restore-keys: showdown-python3.11-
 
      - name: Install PS dependencies and start server
        run: bash scripts/ci_setup_showdown.sh
 
      - name: Run example notebooks
        run: |
            for notebook in $(find examples -name '*.ipynb'); do
              uv run --no-sync jupyter nbconvert --to notebook --execute "$notebook" --output temp.ipynb
              if [ $? -ne 0 ]; then
              echo "Execution of $notebook failed"
              exit 1
              fi
              rm examples/temp.ipynb
            done
 

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

Actions used in this workflow