build workflow (napalm-automation/napalm)
The build workflow from napalm-automation/napalm, explained and optimized by Latchkey.
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.
What it does
This is the build workflow from the napalm-automation/napalm 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
name: build
on: [push, pull_request]
permissions:
contents: read
jobs:
linters:
name: linters
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install dependencies
run: uv sync --all-groups
- name: Run ruff check
run: uv run --no-project ruff check .
- name: Run ruff format
run: uv run --no-project ruff format .
- name: Run type checker
env:
MYPYC_OPT_LEVEL: 0 # Fixes the Python 3.13 symbol crash
run: |
uv run --no-project mypy --version
uv run --no-project mypy -p napalm --config-file mypy.ini
std_tests:
name: std_tests
strategy:
matrix:
python-version: ['3.10', '3.11', "3.12", "3.13", "3.14"]
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync
- name: Run Tests
run: uv run pytest --cov=napalm --cov-report term-missing -vs
std_tests_macos:
name: std_tests_macos
strategy:
matrix:
python-version: [ '3.12', '3.13', '3.14' ]
platform: [macos-15]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync
- name: Run Tests
run: uv run pytest --cov=napalm --cov-report term-missing -vs
build_docs:
name: build_docs
needs: std_tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: '3.13'
enable-cache: true
- name: Install dependencies
run: uv sync --all-groups
- name: Doctests
run: uv run make doctest
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: build on: [push, pull_request] permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: linters: timeout-minutes: 30 name: linters runs-on: latchkey-small steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v5 with: enable-cache: true - name: Set up Python run: uv python install 3.13 - name: Install dependencies run: uv sync --all-groups - name: Run ruff check run: uv run --no-project ruff check . - name: Run ruff format run: uv run --no-project ruff format . - name: Run type checker env: MYPYC_OPT_LEVEL: 0 # Fixes the Python 3.13 symbol crash run: | uv run --no-project mypy --version uv run --no-project mypy -p napalm --config-file mypy.ini std_tests: timeout-minutes: 30 name: std_tests strategy: matrix: python-version: ['3.10', '3.11', "3.12", "3.13", "3.14"] platform: [ubuntu-24.04] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} enable-cache: true - name: Install dependencies run: uv sync - name: Run Tests run: uv run pytest --cov=napalm --cov-report term-missing -vs std_tests_macos: timeout-minutes: 30 name: std_tests_macos strategy: matrix: python-version: [ '3.12', '3.13', '3.14' ] platform: [macos-15] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} enable-cache: true - name: Install dependencies run: uv sync - name: Run Tests run: uv run pytest --cov=napalm --cov-report term-missing -vs build_docs: timeout-minutes: 30 name: build_docs needs: std_tests runs-on: latchkey-small steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v5 with: python-version: '3.13' enable-cache: true - name: Install dependencies run: uv sync --all-groups - name: Doctests run: uv run make doctest
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.
- Add a job timeout so a hung step cannot burn hours of runner time.
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 4 jobs (10 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.