Skip to content
Latchkey

CI workflow (mkdocs/mkdocs-redirects)

The CI workflow from mkdocs/mkdocs-redirects, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: mkdocs/mkdocs-redirects.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the mkdocs/mkdocs-redirects 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: CI
on:
  push:
  pull_request:
  schedule:
    - cron: '0 6 * * 6'
defaults:
  run:
    shell: bash
jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        include:
          - python: '^3.12'
            os: ubuntu-latest
          - python: '3.12'
            os: macos-latest
          - python: '3.11'
            os: windows-latest
          - python: '3.10'
            os: ubuntu-latest
          - python: '3.9'
            os: macos-latest
          - python: '3.9'
            os: windows-latest
          - python: '3.9'
            os: ubuntu-latest
            versions: minimal
    runs-on: ${{matrix.os}}
    steps:
      - name: Download source
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{matrix.python}}
      - name: Pin to lowest versions
        if: matrix.versions == 'minimal'
        run: |
          sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml
      - name: Install Hatch
        run: |
          pip install hatch
      - name: Install dependencies
        run: |
          hatch run test:pip freeze
      - name: Run tests
        run: |
          hatch run test:test
  style:
    runs-on: ubuntu-latest
    steps:
      - name: Download source
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install Hatch
        run: |
          pip install hatch
      - name: Install dependencies
        run: |
          hatch run style:pip freeze
          hatch run types:pip freeze
      - name: Check style
        if: always()
        run: |
          hatch run style:check
      - name: Check types
        if: always()
        run: |
          hatch run types:check

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:
  pull_request:
  schedule:
    - cron: '0 6 * * 6'
defaults:
  run:
    shell: bash
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        include:
          - python: '^3.12'
            os: ubuntu-latest
          - python: '3.12'
            os: macos-latest
          - python: '3.11'
            os: windows-latest
          - python: '3.10'
            os: ubuntu-latest
          - python: '3.9'
            os: macos-latest
          - python: '3.9'
            os: windows-latest
          - python: '3.9'
            os: ubuntu-latest
            versions: minimal
    runs-on: ${{matrix.os}}
    steps:
      - name: Download source
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: ${{matrix.python}}
      - name: Pin to lowest versions
        if: matrix.versions == 'minimal'
        run: |
          sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml
      - name: Install Hatch
        run: |
          pip install hatch
      - name: Install dependencies
        run: |
          hatch run test:pip freeze
      - name: Run tests
        run: |
          hatch run test:test
  style:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Download source
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: '3.12'
      - name: Install Hatch
        run: |
          pip install hatch
      - name: Install dependencies
        run: |
          hatch run style:pip freeze
          hatch run types:pip freeze
      - name: Check style
        if: always()
        run: |
          hatch run style:check
      - name: Check types
        if: always()
        run: |
          hatch run types:check
 

What changed

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