Continuous Integration workflow (yezz123/fastapi-class)
The Continuous Integration workflow from yezz123/fastapi-class, 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 Continuous Integration workflow from the yezz123/fastapi-class 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: Continuous Integration
on:
push:
branches:
- main
pull_request: {}
jobs:
mypy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: setup uv
uses: yezz123/setup-uv@v4.1
with:
uv-venv: ".venv"
- name: Install Dependencies
run: uv sync --group lint --all-extras
- name: Typecheck with mypy
run: bash scripts/lint.sh
tests:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: setup UV
uses: yezz123/setup-uv@v4.1
with:
uv-venv: ".venv"
- name: Install Dependencies
run: uv sync --group test --all-extras
- name: Test with pytest - ${{ matrix.os }} - py${{ matrix.python-version }}
run: bash scripts/test.sh
env:
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-deps
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
# https://github.com/marketplace/actions/alls-green#why
# used for branch protection checks
check:
if: always()
needs: [mypy, tests]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
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: Continuous Integration on: push: branches: - main pull_request: {} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: mypy: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ["3.12"] fail-fast: false steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: setup uv uses: yezz123/setup-uv@v4.1 with: uv-venv: ".venv" - name: Install Dependencies run: uv sync --group lint --all-extras - name: Typecheck with mypy run: bash scripts/lint.sh tests: timeout-minutes: 30 name: test py${{ matrix.python-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }}-latest strategy: matrix: python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"] os: [ubuntu] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: setup UV uses: yezz123/setup-uv@v4.1 with: uv-venv: ".venv" - name: Install Dependencies run: uv sync --group test --all-extras - name: Test with pytest - ${{ matrix.os }} - py${{ matrix.python-version }} run: bash scripts/test.sh env: CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-deps - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml # https://github.com/marketplace/actions/alls-green#why # used for branch protection checks check: timeout-minutes: 30 if: always() needs: [mypy, tests] runs-on: latchkey-small steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: jobs: ${{ toJSON(needs) }}
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.
3 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 3 jobs (7 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.