Main workflow (corydolphin/flask-cors)
The Main workflow from corydolphin/flask-cors, 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 Main workflow from the corydolphin/flask-cors 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: Main
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Run checks
run: make check
tests-and-type-check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
run: uv run python -m pytest tests --cov --cov-config=pyproject.toml --cov-report=xml
- name: Check typing
run: uv run mypy
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
uses: codecov/codecov-action@v4
if: ${{ matrix.python-version == '3.11' }}
check-docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Check if documentation can be built
run: uv run mkdocs build
deploy-docs:
# Publish the docs to GitHub Pages on every push to main, but never from a
# pull request. Gated behind check-docs so a broken build is never deployed.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: check-docs
runs-on: ubuntu-latest
permissions:
contents: write # gh-deploy pushes the built docs to the gh-pages branch
concurrency:
group: deploy-docs
cancel-in-progress: false
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Deploy documentation
run: uv run mkdocs gh-deploy --force
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Main on: push: branches: - main pull_request: types: [opened, synchronize, reopened, ready_for_review] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: quality: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Check out uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: ~/.cache/pre-commit key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - name: Set up the environment uses: ./.github/actions/setup-python-env - name: Run checks run: make check tests-and-type-check: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] fail-fast: false defaults: run: shell: bash steps: - name: Check out uses: actions/checkout@v4 - name: Set up the environment uses: ./.github/actions/setup-python-env with: python-version: ${{ matrix.python-version }} - name: Run tests run: uv run python -m pytest tests --cov --cov-config=pyproject.toml --cov-report=xml - name: Check typing run: uv run mypy - name: Upload coverage reports to Codecov with GitHub Action on Python 3.11 uses: codecov/codecov-action@v4 if: ${{ matrix.python-version == '3.11' }} check-docs: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Check out uses: actions/checkout@v4 - name: Set up the environment uses: ./.github/actions/setup-python-env - name: Check if documentation can be built run: uv run mkdocs build deploy-docs: timeout-minutes: 30 # Publish the docs to GitHub Pages on every push to main, but never from a # pull request. Gated behind check-docs so a broken build is never deployed. if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: check-docs runs-on: latchkey-small permissions: contents: write # gh-deploy pushes the built docs to the gh-pages branch concurrency: group: deploy-docs cancel-in-progress: false steps: - name: Check out uses: actions/checkout@v4 - name: Set up the environment uses: ./.github/actions/setup-python-env - name: Deploy documentation run: uv run mkdocs gh-deploy --force
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 (8 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.