Skip to content
Latchkey

Testing fastapi-template workflow (s3rius/FastAPI-template)

The Testing fastapi-template workflow from s3rius/FastAPI-template, explained and optimized by Latchkey.

F

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.

Grade your own workflow free or run it on Latchkey →
Source: s3rius/FastAPI-template.github/workflows/test.ymlLicense MITView source

What it does

This is the Testing fastapi-template workflow from the s3rius/FastAPI-template 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

workflow (.yml)
name: Testing fastapi-template

on:
  pull_request:

jobs:
  pre_job:
    # continue-on-error: true # Uncomment once integration is finished
    runs-on: ubuntu-latest
    # Map a step output to a job output
    outputs:
      should_skip: ${{ steps.skip_check.outputs.should_skip }}
    steps:
      - id: skip_check
        uses: fkirc/skip-duplicate-actions@master
        with:
          # All of these options are optional, so you can remove them if you are happy with the defaults
          concurrent_skipping: 'same_content'
          skip_after_successful_duplicate: 'true'
          paths_ignore: '["**/README.md"]'
  pytest:
    needs: pre_job
    if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.12'
        env:
          POETRY_VIRTUALENVS_CREATE: "False"
      - name: Set up UV
        uses: astral-sh/setup-uv@v6
      - name: Setup GIT
        run: |
          git config --global user.name "fastapi_template"
          git config --global user.email "fastapi_template@pytest.python"
      - name: Run tests
        run: uv run pytest -vv -n auto

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: Testing fastapi-template
 
on:
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre_job:
    timeout-minutes: 30
    # continue-on-error: true # Uncomment once integration is finished
    runs-on: latchkey-small
    # Map a step output to a job output
    outputs:
      should_skip: ${{ steps.skip_check.outputs.should_skip }}
    steps:
      - id: skip_check
        uses: fkirc/skip-duplicate-actions@master
        with:
          # All of these options are optional, so you can remove them if you are happy with the defaults
          concurrent_skipping: 'same_content'
          skip_after_successful_duplicate: 'true'
          paths_ignore: '["**/README.md"]'
  pytest:
    timeout-minutes: 30
    needs: pre_job
    if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: '3.12'
        env:
          POETRY_VIRTUALENVS_CREATE: "False"
      - name: Set up UV
        uses: astral-sh/setup-uv@v6
      - name: Setup GIT
        run: |
          git config --global user.name "fastapi_template"
          git config --global user.email "fastapi_template@pytest.python"
      - name: Run tests
        run: uv run pytest -vv -n auto
 

What changed

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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow