Skip to content
Latchkey

Sphinx Build and Doctest workflow (tenpy/tenpy)

The Sphinx Build and Doctest workflow from tenpy/tenpy, 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: tenpy/tenpy.github/workflows/doc-build.ymlLicense Apache-2.0View source

What it does

This is the Sphinx Build and Doctest workflow from the tenpy/tenpy repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

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

The workflow

workflow (.yml)
name: Sphinx Build and Doctest
# Check if the documentation can be built and run the doctests

on:
  # pushes to main
  push:
    branches:
      - main
  # PRs
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]


jobs:
  build:
    if: github.event.pull_request.draft == false

    runs-on: ubuntu-latest
    defaults:
      run:
        # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
        shell: bash -el {0}
    steps:

    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: recursive

    - name: Setup miniconda
      uses: conda-incubator/setup-miniconda@v3.2.0
      with:
        auto-update-conda: true
        activate-environment: tenpydoc
        environment-file: doc/environment.yml
        python-version: 3.13
        conda-remove-defaults: "true"

    - name: Build documentation
      # -W treats warnings as errors, i.e. the action fails if there are warnings from sphinx
      # --keep-going causes sphinx to not quit on a warning/error, so we get to see all of them
      run: |
        conda activate tenpydoc
        python -m sphinx -W --keep-going -b html ./doc ./doc/sphinx_build

    - name: Run doctests
      run: python -m sphinx -b doctest ./doc ./doc/sphinx_build

The same workflow, on Latchkey

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

name: Sphinx Build and Doctest
# Check if the documentation can be built and run the doctests
 
on:
  # pushes to main
  push:
    branches:
      - main
  # PRs
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
 
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    if: github.event.pull_request.draft == false
 
    runs-on: latchkey-small
    defaults:
      run:
        # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
        shell: bash -el {0}
    steps:
 
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: recursive
 
    - name: Setup miniconda
      uses: conda-incubator/setup-miniconda@v3.2.0
      with:
        auto-update-conda: true
        activate-environment: tenpydoc
        environment-file: doc/environment.yml
        python-version: 3.13
        conda-remove-defaults: "true"
 
    - name: Build documentation
      # -W treats warnings as errors, i.e. the action fails if there are warnings from sphinx
      # --keep-going causes sphinx to not quit on a warning/error, so we get to see all of them
      run: |
        conda activate tenpydoc
        python -m sphinx -W --keep-going -b html ./doc ./doc/sphinx_build
 
    - name: Run doctests
      run: python -m sphinx -b doctest ./doc ./doc/sphinx_build
 

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.

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