Skip to content
Latchkey

Python test workflow (developmentseed/lonboard)

The Python test workflow from developmentseed/lonboard, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get 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: developmentseed/lonboard.github/workflows/test.ymlLicense MITView source

What it does

This is the Python test workflow from the developmentseed/lonboard 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: Python test

# On every pull request, but only on push to master
on:
  push:
    branches:
      - main
  pull_request:

jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12", "3.13"]

    steps:
      - uses: actions/checkout@v7

      - name: Set up Python ${{ matrix.python-version }}
        id: setup-python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - uses: pnpm/action-setup@v6

      # Note: this should stay synced with the volta-pinned version in
      # package.json
      - uses: actions/setup-node@v6
        with:
          node-version: "22"
          cache: "pnpm"

      - name: Install JS dependencies
        run: pnpm install --frozen-lockfile

      - name: Install a specific version of uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
          version: "0.4.x"

      # Note: we don't install the "watchfiles" group on CI because it gives
      # threading errors when running tests. See
      # https://github.com/developmentseed/lonboard/pull/234
      # https://github.com/manzt/anywidget/issues/374
      - name: Install root project
        run: uv sync --no-group watchfiles

      - name: Build JS bundle
        run: pnpm run build

      - name: Install Playwright browsers
        run: |
          uv run playwright install chromium

      - name: Run tests
        run: uv run pytest

      - name: Run tests (all deps)
        run: |
          uv sync --extra geopandas --extra cli
          uv run pytest

      # Ensure docs build without warnings
      - name: Check docs
        if: "${{ matrix.python-version == 3.11 }}"
        run: uv run --group docs mkdocs build --strict

      # Use ruff-action so we get annotations in the Github UI
      - uses: astral-sh/ruff-action@v3

      - name: Cache pre-commit virtualenvs
        uses: actions/cache@v6
        if: "${{ matrix.python-version == 3.11 }}"
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}

      - name: run pre-commit
        if: "${{ matrix.python-version == 3.11 }}"
        run: |
          uv run pre-commit run --show-diff-on-failure --color=always --all-files

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Python test
 
# On every pull request, but only on push to master
on:
  push:
    branches:
      - main
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      matrix:
        python-version: ["3.11", "3.12", "3.13"]
 
    steps:
      - uses: actions/checkout@v7
 
      - name: Set up Python ${{ matrix.python-version }}
        id: setup-python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
 
      - uses: pnpm/action-setup@v6
 
      # Note: this should stay synced with the volta-pinned version in
      # package.json
      - uses: actions/setup-node@v6
        with:
          node-version: "22"
          cache: "pnpm"
 
      - name: Install JS dependencies
        run: pnpm install --frozen-lockfile
 
      - name: Install a specific version of uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
          version: "0.4.x"
 
      # Note: we don't install the "watchfiles" group on CI because it gives
      # threading errors when running tests. See
      # https://github.com/developmentseed/lonboard/pull/234
      # https://github.com/manzt/anywidget/issues/374
      - name: Install root project
        run: uv sync --no-group watchfiles
 
      - name: Build JS bundle
        run: pnpm run build
 
      - name: Install Playwright browsers
        run: |
          uv run playwright install chromium
 
      - name: Run tests
        run: uv run pytest
 
      - name: Run tests (all deps)
        run: |
          uv sync --extra geopandas --extra cli
          uv run pytest
 
      # Ensure docs build without warnings
      - name: Check docs
        if: "${{ matrix.python-version == 3.11 }}"
        run: uv run --group docs mkdocs build --strict
 
      # Use ruff-action so we get annotations in the Github UI
      - uses: astral-sh/ruff-action@v3
 
      - name: Cache pre-commit virtualenvs
        uses: actions/cache@v6
        if: "${{ matrix.python-version == 3.11 }}"
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}
 
      - name: run pre-commit
        if: "${{ matrix.python-version == 3.11 }}"
        run: |
          uv run pre-commit run --show-diff-on-failure --color=always --all-files
 

What changed

3 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 (3 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