CI workflow (MicroPyramid/Django-CRM)
The CI workflow from MicroPyramid/Django-CRM, 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 MicroPyramid/Django-CRM 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: [master]
paths:
- 'backend/**'
- 'frontend/**'
- '.coveragerc'
- '.github/workflows/tests.yml'
pull_request:
branches: [master]
paths:
- 'backend/**'
- 'frontend/**'
- '.coveragerc'
- '.github/workflows/tests.yml'
jobs:
backend-tests:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: 'backend/uv.lock'
- name: Install system dependencies (WeasyPrint)
run: |
sudo apt-get update
sudo apt-get install -y \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf-2.0-0 \
libffi-dev \
shared-mime-info
- name: Install Python dependencies
working-directory: backend
run: uv sync --frozen
- name: Run tests with coverage
working-directory: backend
env:
DJANGO_SETTINGS_MODULE: crm.test_settings
SECRET_KEY: test-secret-key-for-ci
ADMIN_EMAIL: admin@test.com
run: uv run pytest -m "not postgres_only" --tb=short -v
- name: Generate coverage badge
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
working-directory: backend
run: uvx --from "genbadge[coverage]" genbadge coverage -i coverage.xml -o ../coverage-badge.svg
- name: Commit coverage badge
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add coverage-badge.svg || true
git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]"
git push || true
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: backend/htmlcov/
retention-days: 14
frontend-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Prettier format check
working-directory: frontend
run: pnpm prettier --check . || echo "::warning::Prettier found formatting issues in $(pnpm prettier --check . 2>&1 | grep -c '^\[warn\]') files. Run 'pnpm format' to fix."
- name: ESLint
working-directory: frontend
run: pnpm eslint .
- name: Type check (svelte-check)
working-directory: frontend
run: pnpm check
- name: Build
working-directory: frontend
run: pnpm build
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: [master] paths: - 'backend/**' - 'frontend/**' - '.coveragerc' - '.github/workflows/tests.yml' pull_request: branches: [master] paths: - 'backend/**' - 'frontend/**' - '.coveragerc' - '.github/workflows/tests.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: backend-tests: timeout-minutes: 30 runs-on: latchkey-small permissions: contents: write steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v6 with: enable-cache: true cache-dependency-glob: 'backend/uv.lock' - name: Install system dependencies (WeasyPrint) run: | sudo apt-get update sudo apt-get install -y \ libpango-1.0-0 \ libpangocairo-1.0-0 \ libgdk-pixbuf-2.0-0 \ libffi-dev \ shared-mime-info - name: Install Python dependencies working-directory: backend run: uv sync --frozen - name: Run tests with coverage working-directory: backend env: DJANGO_SETTINGS_MODULE: crm.test_settings SECRET_KEY: test-secret-key-for-ci ADMIN_EMAIL: admin@test.com run: uv run pytest -m "not postgres_only" --tb=short -v - name: Generate coverage badge if: github.ref == 'refs/heads/master' && github.event_name == 'push' working-directory: backend run: uvx --from "genbadge[coverage]" genbadge coverage -i coverage.xml -o ../coverage-badge.svg - name: Commit coverage badge if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add coverage-badge.svg || true git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]" git push || true - name: Upload coverage report if: always() uses: actions/upload-artifact@v4 with: name: coverage-report path: backend/htmlcov/ retention-days: 14 frontend-checks: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: cache: 'npm' node-version: '24' - name: Install pnpm uses: pnpm/action-setup@v4 with: version: 10 - name: Install dependencies working-directory: frontend run: pnpm install --frozen-lockfile - name: Prettier format check working-directory: frontend run: pnpm prettier --check . || echo "::warning::Prettier found formatting issues in $(pnpm prettier --check . 2>&1 | grep -c '^\[warn\]') files. Run 'pnpm format' to fix." - name: ESLint working-directory: frontend run: pnpm eslint . - name: Type check (svelte-check) working-directory: frontend run: pnpm check - name: Build working-directory: frontend run: pnpm build
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.
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.
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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.