Skip to content
Latchkey

Build docs workflow (TorchSim/torch-sim)

The Build docs workflow from TorchSim/torch-sim, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, 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: TorchSim/torch-sim.github/workflows/docs.ymlLicense MITView source

What it does

This is the Build docs workflow from the TorchSim/torch-sim 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: Build docs

on:
  workflow_dispatch:
  push:
    branches: [main]
  pull_request:

# set GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build-docs:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install pandoc
        run: sudo apt-get install pandoc

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Set up uv
        uses: astral-sh/setup-uv@v6

      - name: Install dependencies
        run: |
          uv pip install ".[test,docs]" --system

      - name: Install extras for tutorial generation
        run: uv pip install ".[mace]" --system

      - name: Copy tutorials
        run: |
          cp -r examples/tutorials docs/
          jupytext --set-formats "py:percent,ipynb" docs/tutorials/*.py
          jupytext --set-kernel python3 docs/tutorials/*.py
          jupytext --to notebook --execute docs/tutorials/*.py
          rm docs/tutorials/*.py
          rm docs/tutorials/*.h5*
          rm docs/tutorials/*.traj*

      - name: Generate package treemap
        run: uv run docs/_static/draw_pkg_treemap.py

      - name: Build
        run: sphinx-build docs docs_build

      - name: Upload build artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./docs_build

  deploy:
    if: github.repository_owner == 'TorchSim' && github.ref == 'refs/heads/main'
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    needs: build-docs
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

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: Build docs
 
on:
  workflow_dispatch:
  push:
    branches: [main]
  pull_request:
 
# set GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build-docs:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    steps:
      - uses: actions/checkout@v4
 
      - name: Install pandoc
        run: sudo apt-get install pandoc
 
      - uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: '3.12'
 
      - name: Set up uv
        uses: astral-sh/setup-uv@v6
 
      - name: Install dependencies
        run: |
          uv pip install ".[test,docs]" --system
 
      - name: Install extras for tutorial generation
        run: uv pip install ".[mace]" --system
 
      - name: Copy tutorials
        run: |
          cp -r examples/tutorials docs/
          jupytext --set-formats "py:percent,ipynb" docs/tutorials/*.py
          jupytext --set-kernel python3 docs/tutorials/*.py
          jupytext --to notebook --execute docs/tutorials/*.py
          rm docs/tutorials/*.py
          rm docs/tutorials/*.h5*
          rm docs/tutorials/*.traj*
 
      - name: Generate package treemap
        run: uv run docs/_static/draw_pkg_treemap.py
 
      - name: Build
        run: sphinx-build docs docs_build
 
      - name: Upload build artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./docs_build
 
  deploy:
    timeout-minutes: 30
    if: github.repository_owner == 'TorchSim' && github.ref == 'refs/heads/main'
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    needs: build-docs
    runs-on: latchkey-small
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
 

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

Actions used in this workflow