CI workflow (borntyping/python-colorlog)
The CI workflow from borntyping/python-colorlog, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the CI workflow from the borntyping/python-colorlog 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", "pull_request"]
jobs:
lint:
name: "π Lint Python modules"
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.14"
steps:
- uses: "actions/checkout@master"
- name: "π Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "π Display Python version"
run: "python --version"
- name: "π Install dependencies"
run: "python -m pip install --user --pre black flake8 mypy types-PyYAML"
- name: "π Run mypy"
run: "python -m mypy ."
- name: "π Run flake8"
run: "python -m flake8"
- name: "π Run black"
run: "python -m black --check ."
test:
name: "π Test Python modules"
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
dependencies:
- ""
- "colorama"
steps:
- uses: "actions/checkout@master"
- name: "π Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
allow-prereleases: true
- name: "π Display Python version"
run: "python --version"
- name: "π Install dependencies"
run: "python -m pip install --user pytest ${{ matrix.dependencies }}"
- name: "π Run pytest"
run: "python -m pytest"
publish:
name: "π¦ Publish Python distributions"
if: "startsWith(github.ref, 'refs/tags')"
runs-on: "ubuntu-latest"
environment: "publish"
permissions:
id-token: write
strategy:
matrix:
python-version:
- "3.14"
steps:
- uses: "actions/checkout@master"
- name: "π Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "π Display Python version"
run: "python --version"
- name: "π Install wheel"
run: "python -m pip install setuptools wheel --user"
- name: "π Build a binary wheel and a source tarball"
run: "python setup.py sdist bdist_wheel"
- name: "π¦ Publish package distributions to PyPI"
uses: "pypa/gh-action-pypi-publish@release/v1"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: "CI" on: ["push", "pull_request"] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 name: "π Lint Python modules" runs-on: "ubuntu-latest" strategy: matrix: python-version: - "3.14" steps: - uses: "actions/checkout@master" - name: "π Set up Python ${{ matrix.python-version }}" uses: "actions/setup-python@v2" with: python-version: "${{ matrix.python-version }}" - name: "π Display Python version" run: "python --version" - name: "π Install dependencies" run: "python -m pip install --user --pre black flake8 mypy types-PyYAML" - name: "π Run mypy" run: "python -m mypy ." - name: "π Run flake8" run: "python -m flake8" - name: "π Run black" run: "python -m black --check ." test: timeout-minutes: 30 name: "π Test Python modules" runs-on: "ubuntu-latest" strategy: matrix: python-version: - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" - "3.14" dependencies: - "" - "colorama" steps: - uses: "actions/checkout@master" - name: "π Set up Python ${{ matrix.python-version }}" uses: "actions/setup-python@v2" with: python-version: "${{ matrix.python-version }}" allow-prereleases: true - name: "π Display Python version" run: "python --version" - name: "π Install dependencies" run: "python -m pip install --user pytest ${{ matrix.dependencies }}" - name: "π Run pytest" run: "python -m pytest" publish: timeout-minutes: 30 name: "π¦ Publish Python distributions" if: "startsWith(github.ref, 'refs/tags')" runs-on: "ubuntu-latest" environment: "publish" permissions: id-token: write strategy: matrix: python-version: - "3.14" steps: - uses: "actions/checkout@master" - name: "π Set up Python ${{ matrix.python-version }}" uses: "actions/setup-python@v2" with: python-version: "${{ matrix.python-version }}" - name: "π Display Python version" run: "python --version" - name: "π Install wheel" run: "python -m pip install setuptools wheel --user" - name: "π Build a binary wheel and a source tarball" run: "python setup.py sdist bdist_wheel" - name: "π¦ Publish package distributions to PyPI" uses: "pypa/gh-action-pypi-publish@release/v1"
What changed
- 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.
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:
- Dependency installs
This workflow runs 3 jobs (16 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.