Skip to content
Latchkey

GitHub Actions Workflow Template for Python

A complete, caching-enabled GitHub Actions workflow for Python. Drop it in .github/workflows/ci.yml and adjust.

This template builds and tests a Python project with dependency caching and sensible defaults. It uses setup-python pip caching.

The workflow

.github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: pip
      - run: pip install -r requirements.txt
      - run: pytest -q

What it does

  • Caches pip downloads
  • Installs from requirements
  • Runs pytest

Run it cheaper

Change runs-on: ubuntu-latest to a Latchkey label to run this same workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →