docs workflow (xarray-contrib/xarray-spatial)
The docs workflow from xarray-contrib/xarray-spatial, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, run de-duplication, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the docs workflow from the xarray-contrib/xarray-spatial 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
name: docs
on:
pull_request:
paths:
- 'docs/**'
- 'README.md'
- 'setup.cfg'
- '.readthedocs.yml'
- '.github/workflows/docs.yml'
workflow_dispatch:
schedule:
# Weekly linkcheck (Monday 06:00 UTC). External links rot on their
# own schedule, not the PR schedule; checking them per-PR cost ~10
# minutes of runner time and its failures were masked by
# continue-on-error anyway.
- cron: '0 6 * * 1'
jobs:
# Job id/name kept distinct from the pytest workflow's `run` job:
# duplicate check names across workflows get deduplicated in the PR
# checks UI and can hide failures.
docs-build:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
# Normal runs take ~4 minutes (install ~1, HTML build ~3 with
# parallel read), so 15 leaves headroom without letting a wedged
# run camp on a runner.
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
# Match the Read the Docs build (.readthedocs.yml).
python-version: '3.12'
- name: Install pandoc
# nbsphinx needs the pandoc binary; the `pandoc` pip package in
# the doc extra does not ship it.
run: sudo apt-get update && sudo apt-get install -y pandoc
- name: Install dependencies
# Same extras as the Read the Docs pre_build step, so this job
# and RTD cannot drift apart.
run: |
python -m pip install --upgrade pip
pip install -e '.[doc,tests]'
- name: Build HTML
# No -W: the build carries a handful of pre-existing warnings in
# notebooks and reference pages. Gate on errors only.
#
# -j auto: the read phase is dominated by plot-directive examples
# in the reference docstrings (sample data load + numba compile
# per page, 30-60s each); all extensions in conf.py declare
# parallel_read_safe, so this fans them out across the runner's
# cores.
run: sphinx-build -b html -j auto docs/source docs/build/html
# Linkcheck runs on the weekly schedule (or manual dispatch), not on
# PRs: it took ~10 minutes per PR and never gated anything. Here it
# is allowed to fail loudly so broken links actually surface.
linkcheck:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pandoc
run: sudo apt-get update && sudo apt-get install -y pandoc
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[doc,tests]'
- name: Link check
run: sphinx-build -b linkcheck docs/source docs/build/linkcheck
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: docs on: pull_request: paths: - 'docs/**' - 'README.md' - 'setup.cfg' - '.readthedocs.yml' - '.github/workflows/docs.yml' workflow_dispatch: schedule: # Weekly linkcheck (Monday 06:00 UTC). External links rot on their # own schedule, not the PR schedule; checking them per-PR cost ~10 # minutes of runner time and its failures were masked by # continue-on-error anyway. - cron: '0 6 * * 1' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # Job id/name kept distinct from the pytest workflow's `run` job: # duplicate check names across workflows get deduplicated in the PR # checks UI and can hide failures. docs-build: if: github.event_name != 'schedule' runs-on: latchkey-small # Normal runs take ~4 minutes (install ~1, HTML build ~3 with # parallel read), so 15 leaves headroom without letting a wedged # run camp on a runner. timeout-minutes: 15 steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: cache: 'pip' # Match the Read the Docs build (.readthedocs.yml). python-version: '3.12' - name: Install pandoc # nbsphinx needs the pandoc binary; the `pandoc` pip package in # the doc extra does not ship it. run: sudo apt-get update && sudo apt-get install -y pandoc - name: Install dependencies # Same extras as the Read the Docs pre_build step, so this job # and RTD cannot drift apart. run: | python -m pip install --upgrade pip pip install -e '.[doc,tests]' - name: Build HTML # No -W: the build carries a handful of pre-existing warnings in # notebooks and reference pages. Gate on errors only. # # -j auto: the read phase is dominated by plot-directive examples # in the reference docstrings (sample data load + numba compile # per page, 30-60s each); all extensions in conf.py declare # parallel_read_safe, so this fans them out across the runner's # cores. run: sphinx-build -b html -j auto docs/source docs/build/html # Linkcheck runs on the weekly schedule (or manual dispatch), not on # PRs: it took ~10 minutes per PR and never gated anything. Here it # is allowed to fail loudly so broken links actually surface. linkcheck: if: github.event_name != 'pull_request' runs-on: latchkey-small timeout-minutes: 30 steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: '3.12' - name: Install pandoc run: sudo apt-get update && sudo apt-get install -y pandoc - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e '.[doc,tests]' - name: Link check run: sphinx-build -b linkcheck docs/source docs/build/linkcheck
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
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:
- Dependency installs
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.