Skip to content
Latchkey

Python Tests workflow (tanghaibao/jcvi)

The Python Tests workflow from tanghaibao/jcvi, explained and optimized by Latchkey.

F

CI health: F - at risk

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: tanghaibao/jcvi.github/workflows/pytest.ymlLicense BSD-2-ClauseView source

What it does

This is the Python Tests workflow from the tanghaibao/jcvi repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-2-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Python Tests
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 4
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: ["3.11", "3.13"]
    steps:
      - uses: actions/checkout@v7
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
        with:
          cache-dependency-glob: |
            uv.lock
            pyproject.toml
      - name: Install BEDTools (Linux)
        run: |
          sudo apt-get update
          sudo apt-get install --fix-missing bedtools libmagickwand-dev
        if: matrix.os == 'ubuntu-latest'
      - name: Install BEDTools (macOS)
        run: brew install bedtools imagemagick
        if: matrix.os == 'macos-latest'
      - name: Install dependencies
        run: |
          if [ -f uv.lock ]; then
            uv sync --frozen --extra tests
          else
            uv sync --extra tests
          fi
      # Get pytest args from pyproject.toml
      - name: Test with pytest
        run: |
          uv run pytest

# Upload coverage report to Codecov
# Only upload coverage for the latest Python version on Ubuntu
#- name: Upload coverage reports to Codecov
#  uses: codecov/codecov-action@v5
#  if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
#  with:
#    token: ${{ secrets.CODECOV_TOKEN }}
#    slug: tanghaibao/jcvi

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: Python Tests
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 4
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: ["3.11", "3.13"]
    steps:
      - uses: actions/checkout@v7
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
        with:
          cache-dependency-glob: |
            uv.lock
            pyproject.toml
      - name: Install BEDTools (Linux)
        run: |
          sudo apt-get update
          sudo apt-get install --fix-missing bedtools libmagickwand-dev
        if: matrix.os == 'ubuntu-latest'
      - name: Install BEDTools (macOS)
        run: brew install bedtools imagemagick
        if: matrix.os == 'macos-latest'
      - name: Install dependencies
        run: |
          if [ -f uv.lock ]; then
            uv sync --frozen --extra tests
          else
            uv sync --extra tests
          fi
      # Get pytest args from pyproject.toml
      - name: Test with pytest
        run: |
          uv run pytest
 
# Upload coverage report to Codecov
# Only upload coverage for the latest Python version on Ubuntu
#- name: Upload coverage reports to Codecov
#  uses: codecov/codecov-action@v5
#  if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
#  with:
#    token: ${{ secrets.CODECOV_TOKEN }}
#    slug: tanghaibao/jcvi
 

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 1 job (4 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