Skip to content
Latchkey

Latest docs workflow (asteroid-team/asteroid)

The Latest docs workflow from asteroid-team/asteroid, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, 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: asteroid-team/asteroid.github/workflows/test_docs.ymlLicense MITView source

What it does

This is the Latest docs workflow from the asteroid-team/asteroid 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: Latest docs

# Trigger the workflow on push or pull request, but only for the master branch
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  docs-test:
    name: docs
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: [3.13]  #, 3.7, 3.8]

    # Timeout: https://stackoverflow.com/a/59076067/4521646
    timeout-minutes: 20
    steps:
    - uses: actions/checkout@v5
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install git
      run: |
        sudo apt update
        sudo apt install git-core
        sudo apt install libsndfile1-dev libsndfile1  # Needed for sndfile import

    - name: Install python dependencies
      run: |
        python -m pip install --upgrade --user pip --quiet
        python -m pip install numpy Cython --upgrade-strategy only-if-needed --quiet
        python -m pip install -r requirements/docs.txt
        python --version
        pip --version
        python -m pip list
      shell: bash

    - name: Build the docs
      run: |
        pip install -e .  # Install asteroid-* scripts
        cd docs
        make html
        touch build/html/.nojekyll  # prevents use jekyll to build doc
        grep -qHrn "System Message" build/html && exit 1 || true # Check for "System Message" errors

    # Create an artifact of the html output.
    - uses: actions/upload-artifact@v4
      with:
        name: DocumentationHTML
        path: docs/build/html/

    # Publish built docs to gh-pages branch.
    - name: Commit documentation changes
      run: |
        git clone https://github.com/ammaraskar/sphinx-action-test.git --branch gh-pages --single-branch gh-pages
        cp -r docs/build/html/* gh-pages/
        cd gh-pages
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git add .
        git commit -m "Update documentation" -a || true
        # The above command will fail if no changes were present, so we ignore that.
    - name: Push changes
      if: github.ref == 'refs/heads/master'
      uses: ad-m/github-push-action@master
      with:
        branch: gh-pages
        directory: gh-pages
        github_token: ${{ secrets.GITHUB_TOKEN }}
        force: true

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: Latest docs
 
# Trigger the workflow on push or pull request, but only for the master branch
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  docs-test:
    name: docs
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        python-version: [3.13]  #, 3.7, 3.8]
 
    # Timeout: https://stackoverflow.com/a/59076067/4521646
    timeout-minutes: 20
    steps:
    - uses: actions/checkout@v5
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        cache: 'pip'
        python-version: ${{ matrix.python-version }}
 
    - name: Install git
      run: |
        sudo apt update
        sudo apt install git-core
        sudo apt install libsndfile1-dev libsndfile1  # Needed for sndfile import
 
    - name: Install python dependencies
      run: |
        python -m pip install --upgrade --user pip --quiet
        python -m pip install numpy Cython --upgrade-strategy only-if-needed --quiet
        python -m pip install -r requirements/docs.txt
        python --version
        pip --version
        python -m pip list
      shell: bash
 
    - name: Build the docs
      run: |
        pip install -e .  # Install asteroid-* scripts
        cd docs
        make html
        touch build/html/.nojekyll  # prevents use jekyll to build doc
        grep -qHrn "System Message" build/html && exit 1 || true # Check for "System Message" errors
 
    # Create an artifact of the html output.
    - uses: actions/upload-artifact@v4
      with:
        name: DocumentationHTML
        path: docs/build/html/
 
    # Publish built docs to gh-pages branch.
    - name: Commit documentation changes
      run: |
        git clone https://github.com/ammaraskar/sphinx-action-test.git --branch gh-pages --single-branch gh-pages
        cp -r docs/build/html/* gh-pages/
        cd gh-pages
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git add .
        git commit -m "Update documentation" -a || true
        # The above command will fail if no changes were present, so we ignore that.
    - name: Push changes
      if: github.ref == 'refs/heads/master'
      uses: ad-m/github-push-action@master
      with:
        branch: gh-pages
        directory: gh-pages
        github_token: ${{ secrets.GITHUB_TOKEN }}
        force: true
 

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