Skip to content
Latchkey

CI workflow (epfl-lts2/pyunlocbox)

The CI workflow from epfl-lts2/pyunlocbox, 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: epfl-lts2/pyunlocbox.github/workflows/ci.ymlLicense BSD-3-ClauseView source

What it does

This is the CI workflow from the epfl-lts2/pyunlocbox repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

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

The workflow

workflow (.yml)
name: CI

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: "3.11"
    - uses: pre-commit/action@v3.0.1

  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

    steps:
    - uses: actions/checkout@v4

    - name: Install uv
      uses: astral-sh/setup-uv@v4
      with:
        version: "latest"

    - name: Set up Python ${{ matrix.python-version }}
      run: uv python install ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        uv sync --dev
        # Install additional system dependencies for documentation
        sudo apt-get update
        sudo apt-get install -y graphviz

    # - name: Lint with flake8
    #   run: |
    #     # Replicate: flake8 --doctests --exclude=doc, also exclude .venv
    #     uv run flake8 --doctests --exclude=doc,.venv

    - name: Test with pytest
      run: |
        # Set matplotlib backend for headless testing
        export MPLBACKEND=agg
        # Run tests with pytest and coverage
        uv run pytest --cov=pyunlocbox --cov-report=term-missing --cov-report=html --cov-report=xml -v

    - name: Upload coverage to Coveralls
      if: matrix.python-version == '3.11'  # Only upload once
      uses: coverallsapp/github-action@v2
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        file: coverage.xml
      continue-on-error: true

    - name: Build documentation
      if: matrix.python-version == '3.11'  # Only build docs once
      run: |
        # Replicate: sphinx-build commands from Makefile
        uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
        uv run sphinx-build -b linkcheck -d doc/_build/doctrees doc doc/_build/linkcheck

    - name: Upload documentation artifacts
      if: matrix.python-version == '3.11'
      uses: actions/upload-artifact@v4
      with:
        name: documentation
        path: doc/_build/html/

  # Separate job for building and checking distribution
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Install uv
      uses: astral-sh/setup-uv@v4

    - name: Set up Python
      run: uv python install 3.11

    - name: Install dependencies
      run: uv sync --dev

    - name: Build package
      run: |
        uv build
        ls -lh dist/*

    - name: Check package
      run: |
        uv run twine check dist/*

    - name: Upload build artifacts
      uses: actions/upload-artifact@v4
      with:
        name: dist
        path: dist/

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: CI
 
on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        cache: 'pip'
        python-version: "3.11"
    - uses: pre-commit/action@v3.0.1
 
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      fail-fast: true
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
 
    steps:
    - uses: actions/checkout@v4
 
    - name: Install uv
      uses: astral-sh/setup-uv@v4
      with:
        version: "latest"
 
    - name: Set up Python ${{ matrix.python-version }}
      run: uv python install ${{ matrix.python-version }}
 
    - name: Install dependencies
      run: |
        uv sync --dev
        # Install additional system dependencies for documentation
        sudo apt-get update
        sudo apt-get install -y graphviz
 
    # - name: Lint with flake8
    #   run: |
    #     # Replicate: flake8 --doctests --exclude=doc, also exclude .venv
    #     uv run flake8 --doctests --exclude=doc,.venv
 
    - name: Test with pytest
      run: |
        # Set matplotlib backend for headless testing
        export MPLBACKEND=agg
        # Run tests with pytest and coverage
        uv run pytest --cov=pyunlocbox --cov-report=term-missing --cov-report=html --cov-report=xml -v
 
    - name: Upload coverage to Coveralls
      if: matrix.python-version == '3.11'  # Only upload once
      uses: coverallsapp/github-action@v2
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        file: coverage.xml
      continue-on-error: true
 
    - name: Build documentation
      if: matrix.python-version == '3.11'  # Only build docs once
      run: |
        # Replicate: sphinx-build commands from Makefile
        uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
        uv run sphinx-build -b linkcheck -d doc/_build/doctrees doc doc/_build/linkcheck
 
    - name: Upload documentation artifacts
      if: matrix.python-version == '3.11'
      uses: actions/upload-artifact@v4
      with:
        name: documentation
        path: doc/_build/html/
 
  # Separate job for building and checking distribution
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v4
 
    - name: Install uv
      uses: astral-sh/setup-uv@v4
 
    - name: Set up Python
      run: uv python install 3.11
 
    - name: Install dependencies
      run: uv sync --dev
 
    - name: Build package
      run: |
        uv build
        ls -lh dist/*
 
    - name: Check package
      run: |
        uv run twine check dist/*
 
    - name: Upload build artifacts
      uses: actions/upload-artifact@v4
      with:
        name: dist
        path: dist/
 

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