Skip to content
Latchkey

lint-test-coverage workflow (pavdmyt/yaspin)

The lint-test-coverage workflow from pavdmyt/yaspin, 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: pavdmyt/yaspin.github/workflows/lint_test_coverage.ymlLicense MITView source

What it does

This is the lint-test-coverage workflow from the pavdmyt/yaspin 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: lint-test-coverage

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]
  workflow_dispatch:

jobs:

  lint:
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        python-version: ["3.13"]

    steps:
      - name: checkout-code
        uses: actions/checkout@v6

      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: install-poetry
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1

      - name: install-dependencies
        run: |
          poetry install

      - name: check-fmt
        run: |
          make check-fmt

      - name: lint-code
        run: |
          make check-lint

      - name: semgrep
        run: |
          make semgrep

  mypy:
    needs: lint
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

    steps:
      - name: checkout-code
        uses: actions/checkout@v6

      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true

      - name: install-poetry
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1

      - name: install-dependencies
        run: |
          poetry install

      - name: mypy checks
        run: |
          make mypy

  test:
    needs: [lint, mypy]
    runs-on: ubuntu-24.04
    env:
      PYTHONHASHSEED: 0
      USING_COVERAGE: '3.13'
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy-3.11"]

    steps:
      - name: checkout-code
        uses: actions/checkout@v6

      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true

      # Normal Python
      - name: install-poetry
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1

      - name: install-dependencies
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        run: |
          poetry install

      - name: run-tests
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        run: |
          make test

      # PyPy
      - name: install-dependencies
        if: "contains(matrix.python-version, 'pypy-3.11')"
        run: |
          pip install termcolor==3.2.0 pytest==8.4.2 pytest-xdist==3.8.0 pytest-mock==3.15.1

      - name: run-tests
        if: "contains(matrix.python-version, 'pypy-3.11')"
        run: |
          py.test -n auto -v

      # Coverage
      - name: create-coverage-report
        if: "contains(env.USING_COVERAGE, matrix.python-version)"
        run: |
          make coverage

      - name: submit-to-codecov-io
        if: "contains(env.USING_COVERAGE, matrix.python-version)"
        uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: true
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

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: lint-test-coverage
 
on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      matrix:
        python-version: ["3.13"]
 
    steps:
      - name: checkout-code
        uses: actions/checkout@v6
 
      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
      - name: install-poetry
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1
 
      - name: install-dependencies
        run: |
          poetry install
 
      - name: check-fmt
        run: |
          make check-fmt
 
      - name: lint-code
        run: |
          make check-lint
 
      - name: semgrep
        run: |
          make semgrep
 
  mypy:
    timeout-minutes: 30
    needs: lint
    runs-on: latchkey-small
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
 
    steps:
      - name: checkout-code
        uses: actions/checkout@v6
 
      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
 
      - name: install-poetry
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1
 
      - name: install-dependencies
        run: |
          poetry install
 
      - name: mypy checks
        run: |
          make mypy
 
  test:
    timeout-minutes: 30
    needs: [lint, mypy]
    runs-on: latchkey-small
    env:
      PYTHONHASHSEED: 0
      USING_COVERAGE: '3.13'
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy-3.11"]
 
    steps:
      - name: checkout-code
        uses: actions/checkout@v6
 
      - name: prepare-python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
 
      # Normal Python
      - name: install-poetry
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        uses: snok/install-poetry@v1
        with:
          version: 2.2.1
 
      - name: install-dependencies
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        run: |
          poetry install
 
      - name: run-tests
        if: "!contains(matrix.python-version, 'pypy-3.11')"
        run: |
          make test
 
      # PyPy
      - name: install-dependencies
        if: "contains(matrix.python-version, 'pypy-3.11')"
        run: |
          pip install termcolor==3.2.0 pytest==8.4.2 pytest-xdist==3.8.0 pytest-mock==3.15.1
 
      - name: run-tests
        if: "contains(matrix.python-version, 'pypy-3.11')"
        run: |
          py.test -n auto -v
 
      # Coverage
      - name: create-coverage-report
        if: "contains(env.USING_COVERAGE, matrix.python-version)"
        run: |
          make coverage
 
      - name: submit-to-codecov-io
        if: "contains(env.USING_COVERAGE, matrix.python-version)"
        uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: true
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
 
 

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.

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:

This workflow runs 3 jobs (12 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow