Skip to content
Latchkey

Benchmark workflow (scverse/scanpy)

The Benchmark workflow from scverse/scanpy, explained and optimized by Latchkey.

C

CI health: C - fair

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: scverse/scanpy.github/workflows/benchmark.ymlLicense BSD-3-ClauseView source

What it does

This is the Benchmark workflow from the scverse/scanpy repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

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

The workflow

workflow (.yml)
name: Benchmark

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  FORCE_COLOR: "1"

jobs:
  benchmark:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        python: ["3.13"]
        os: [ubuntu-latest]

    env:
      OS: ${{ matrix.os }}
      PYTHON: ${{ matrix.python }}
      ASV_DIR: "./benchmarks"

    steps:
      - uses: actions/checkout@v6
        with: { fetch-depth: 0 } # no blob:none so ASV can compare commits

      - name: Fetch main branch for `asv run`’s hash
        run: git fetch origin main:main
        if: ${{ github.ref_name != 'main' }}

      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python }}
          cache: 'pip'

      - name: Cache datasets
        uses: actions/cache@v6
        with:
          path: |
            ~/.cache
          key: benchmark-state-${{ hashFiles('benchmarks/**') }}

      - name: Install dependencies
        # https://github.com/airspeed-velocity/asv/issues/1577
        run: pip install 'asv>=0.6.4' 'py-rattler<0.22'

      - name: Configure ASV
        working-directory: ${{ env.ASV_DIR }}
        run: asv machine --yes

      - name: Quick benchmark run
        working-directory: ${{ env.ASV_DIR }}
        run: asv run --dry-run --quick --show-stderr --verbose HEAD^!

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Benchmark
 
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
 
env:
  FORCE_COLOR: "1"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  benchmark:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
 
    strategy:
      fail-fast: false
      matrix:
        python: ["3.13"]
        os: [ubuntu-latest]
 
    env:
      OS: ${{ matrix.os }}
      PYTHON: ${{ matrix.python }}
      ASV_DIR: "./benchmarks"
 
    steps:
      - uses: actions/checkout@v6
        with: { fetch-depth: 0 } # no blob:none so ASV can compare commits
 
      - name: Fetch main branch for `asv run`’s hash
        run: git fetch origin main:main
        if: ${{ github.ref_name != 'main' }}
 
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python }}
          cache: 'pip'
 
      - name: Cache datasets
        uses: actions/cache@v6
        with:
          path: |
            ~/.cache
          key: benchmark-state-${{ hashFiles('benchmarks/**') }}
 
      - name: Install dependencies
        # https://github.com/airspeed-velocity/asv/issues/1577
        run: pip install 'asv>=0.6.4' 'py-rattler<0.22'
 
      - name: Configure ASV
        working-directory: ${{ env.ASV_DIR }}
        run: asv machine --yes
 
      - name: Quick benchmark run
        working-directory: ${{ env.ASV_DIR }}
        run: asv run --dry-run --quick --show-stderr --verbose HEAD^!
 

What changed

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

Actions used in this workflow