CI workflow (PyCQA/isort)
The CI workflow from PyCQA/isort, explained and optimized by Latchkey.
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.
What it does
This is the CI workflow from the PyCQA/isort 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
---
name: CI
"on":
push:
branches:
- main
pull_request:
merge_group:
permissions:
contents: read
env:
DEFAULT_PYTHON: "3.14"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- &checkout
name: Check out the repository
uses: actions/checkout@v7
with:
fetch-depth: 2
- &setup-python
name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v6.0.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- &setup-uv
name: Install UV
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version-file: "pyproject.toml"
- &install-dependencies
name: Install dependencies
run: uv sync --all-extras --frozen
- name: Lint
run: uv run --with tox-uv tox -e lint
build:
if: github.repository_owner == 'PyCQA'
name: Build
runs-on: ubuntu-latest
steps:
- *checkout
- *setup-python
- *setup-uv
- name: Build package
run: uv build
test:
name: Tests
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
FORCE_COLOR: 1
steps:
- *checkout
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
check-latest: true
- *setup-uv
- *install-dependencies
- name: Run tests
run: uv run --with tox-uv tox -e py,coverage_report-ci
- name: Report Coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == ${{ env.DEFAULT_PYTHON }}
uses: codecov/codecov-action@v7
integration:
name: Integration tests
runs-on: ubuntu-latest
steps:
- *checkout
- *setup-python
- *setup-uv
- *install-dependencies
- name: Test integration
run: ./scripts/test_integration.sh
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 pull_request: merge_group: permissions: contents: read env: DEFAULT_PYTHON: "3.14" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 name: Lint runs-on: latchkey-small steps: - &checkout name: Check out the repository uses: actions/checkout@v7 with: fetch-depth: 2 - &setup-python name: Set up Python ${{ env.DEFAULT_PYTHON }} uses: actions/setup-python@v6.0.0 with: cache: 'pip' python-version: ${{ env.DEFAULT_PYTHON }} check-latest: true - &setup-uv name: Install UV uses: astral-sh/setup-uv@v7 with: enable-cache: true version-file: "pyproject.toml" - &install-dependencies name: Install dependencies run: uv sync --all-extras --frozen - name: Lint run: uv run --with tox-uv tox -e lint build: timeout-minutes: 30 if: github.repository_owner == 'PyCQA' name: Build runs-on: latchkey-small steps: - *checkout - *setup-python - *setup-uv - name: Build package run: uv build test: timeout-minutes: 30 name: Tests strategy: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} env: FORCE_COLOR: 1 steps: - *checkout - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ matrix.python-version }} allow-prereleases: true check-latest: true - *setup-uv - *install-dependencies - name: Run tests run: uv run --with tox-uv tox -e py,coverage_report-ci - name: Report Coverage if: matrix.os == 'ubuntu-latest' && matrix.python-version == ${{ env.DEFAULT_PYTHON }} uses: codecov/codecov-action@v7 integration: timeout-minutes: 30 name: Integration tests runs-on: latchkey-small steps: - *checkout - *setup-python - *setup-uv - *install-dependencies - name: Test integration run: ./scripts/test_integration.sh
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.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 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.
This workflow runs 4 jobs (21 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.