CI workflow (python-arq/arq)
The CI workflow from python-arq/arq, 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 python-arq/arq 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
tags:
- '**'
pull_request: {}
env:
COLUMNS: 150
FORCE_COLOR: 1
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
- run: |
uv sync --group linting --extra watch
uv pip install pre-commit
- run: uv run pre-commit run -a --verbose
env:
SKIP: no-commit-to-branch
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
- run: uv sync --group docs
- run: make docs
- name: Store docs site
uses: actions/upload-artifact@v6
with:
name: docs
path: docs/_build/
test:
name: test py${{ matrix.python }} with redis:${{ matrix.redis }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu]
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
redis: ['5']
include:
- python: '3.11'
redis: '6'
os: 'ubuntu'
- python: '3.11'
redis: '7'
os: 'ubuntu'
env:
PYTHON: ${{ matrix.python }}
OS: ${{ matrix.os }}
ARQ_TEST_REDIS_VERSION: ${{ matrix.redis }}
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}
- run: uv sync --group testing --extra watch
- run: make test
- run: uv run coverage xml
- uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
env_vars: PYTHON,OS
check:
if: always()
needs: [lint, docs, test]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
id: all-green
with:
jobs: ${{ toJSON(needs) }}
release:
name: Release
needs: [check]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- name: get docs
uses: actions/download-artifact@v6
with:
name: docs
path: docs/_build/
- name: set up python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: install
run: pip install -U build
- name: check version
id: check-version
uses: samuelcolvin/check-python-version@v5
with:
version_file_path: 'arq/version.py'
- name: build
run: python -m build
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: publish docs
if: '!fromJSON(steps.check-version.outputs.IS_PRERELEASE)'
run: make publish-docs
env:
NETLIFY: ${{ secrets.netlify_token }}
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 tags: - '**' pull_request: {} env: COLUMNS: 150 FORCE_COLOR: 1 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 with: python-version: '3.13' - run: | uv sync --group linting --extra watch uv pip install pre-commit - run: uv run pre-commit run -a --verbose env: SKIP: no-commit-to-branch docs: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 with: python-version: '3.13' - run: uv sync --group docs - run: make docs - name: Store docs site uses: actions/upload-artifact@v6 with: name: docs path: docs/_build/ test: timeout-minutes: 30 name: test py${{ matrix.python }} with redis:${{ matrix.redis }} on ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu] python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] redis: ['5'] include: - python: '3.11' redis: '6' os: 'ubuntu' - python: '3.11' redis: '7' os: 'ubuntu' env: PYTHON: ${{ matrix.python }} OS: ${{ matrix.os }} ARQ_TEST_REDIS_VERSION: ${{ matrix.redis }} runs-on: ${{ matrix.os }}-latest steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 with: python-version: ${{ matrix.python }} - run: uv sync --group testing --extra watch - run: make test - run: uv run coverage xml - uses: codecov/codecov-action@v5 with: file: ./coverage.xml env_vars: PYTHON,OS check: timeout-minutes: 30 if: always() needs: [lint, docs, test] runs-on: latchkey-small steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 id: all-green with: jobs: ${{ toJSON(needs) }} release: timeout-minutes: 30 name: Release needs: [check] if: "success() && startsWith(github.ref, 'refs/tags/')" runs-on: latchkey-small environment: release permissions: id-token: write steps: - uses: actions/checkout@v6 - name: get docs uses: actions/download-artifact@v6 with: name: docs path: docs/_build/ - name: set up python uses: actions/setup-python@v6 with: cache: 'pip' python-version: '3.13' - name: install run: pip install -U build - name: check version id: check-version uses: samuelcolvin/check-python-version@v5 with: version_file_path: 'arq/version.py' - name: build run: python -m build - name: Upload package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - name: publish docs if: '!fromJSON(steps.check-version.outputs.IS_PRERELEASE)' run: make publish-docs env: NETLIFY: ${{ secrets.netlify_token }}
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.
5 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:
- Dependency installs
This workflow runs 5 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.