Skip to content
Latchkey

Tests workflow (gallantlab/himalaya)

The Tests workflow from gallantlab/himalaya, 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: gallantlab/himalaya.github/workflows/run_tests.ymlLicense BSD-3-ClauseView source

What it does

This is the Tests workflow from the gallantlab/himalaya 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: Tests

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  run-tests:
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
      max-parallel: 5
      fail-fast: false
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v7
    - name: Set up Python
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}

    - uses: actions/cache@v5
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
        restore-keys: |
          ${{ runner.os }}-pip-

    - name: Install dependencies
      run: |
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -e ."[github]"

    - name: Lint with flake8
      run: |
        pip install -q flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --ignore=E402,C901 --max-line-length=127 --statistics

    - name: Test with pytest
      run: |
        pip install -q pytest pytest-cov
        pytest --cov=./  --reruns 2

    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v7
      with:
        env_vars: OS,PYTHON
        fail_ci_if_error: true
        token: ${{ secrets.CODECOV_TOKEN }}
        verbose: false

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: Tests
 
on:
  push:
    branches:
      - main
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  run-tests:
    timeout-minutes: 30
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
      max-parallel: 5
      fail-fast: false
    runs-on: ${{ matrix.os }}
 
    steps:
    - uses: actions/checkout@v7
    - name: Set up Python
      uses: actions/setup-python@v6
      with:
        cache: 'pip'
        python-version: ${{ matrix.python-version }}
 
    - uses: actions/cache@v5
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
        restore-keys: |
          ${{ runner.os }}-pip-
 
    - name: Install dependencies
      run: |
        pip install torch --index-url https://download.pytorch.org/whl/cpu
        pip install -e ."[github]"
 
    - name: Lint with flake8
      run: |
        pip install -q flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --ignore=E402,C901 --max-line-length=127 --statistics
 
    - name: Test with pytest
      run: |
        pip install -q pytest pytest-cov
        pytest --cov=./  --reruns 2
 
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v7
      with:
        env_vars: OS,PYTHON
        fail_ci_if_error: true
        token: ${{ secrets.CODECOV_TOKEN }}
        verbose: false
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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 (5 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