Skip to content
Latchkey

Test workflow (welch-lab/MultiVelo)

The Test workflow from welch-lab/MultiVelo, 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: welch-lab/MultiVelo.github/workflows/github_action_tests.ymlLicense BSD-3-ClauseView source

What it does

This is the Test workflow from the welch-lab/MultiVelo 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: Test

on:
  push:
    branches: [main, next, version_issues]
  pull_request:
    branches: [main, next, version_issues]

jobs:
  pre-commit:
    runs-on: ${{  matrix.os  }}
    defaults:
      run:
        shell: bash -e {0} # -e to fail on error

    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-12]
        # python: ["3.9", "3.10"]

    env:
      OS: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
      - uses: pre-commit/action@v3.0.0
        with:
          extra_args: --files ../../src/multivelo/auxiliary.py \
            ../../src/multivelo/dynamical_chrom_func.py \
            ../../src/multivelo/steady_chrom_func.py \
            ../../src/multivelo/mv_logging.py \
            ../../src/multivelo/settings.py \
            --verbose

  test:
    runs-on: ${{  matrix.os  }}
    defaults:
      run:
        shell: bash -e {0} # -e to fail on error

    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-12]
        python: ["3.9", "3.10"]

    env:
      OS: ${{ matrix.os }}

    steps:
      # Check
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v4
        with:
          python-version: "${{ matrix.python }}"
      - name: Install requirements
        run: |
          pip3 install -r requirements.txt
      - name: Test with pytest
        run: |
          pip3 install -e .
          pytest

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: Test
 
on:
  push:
    branches: [main, next, version_issues]
  pull_request:
    branches: [main, next, version_issues]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: ${{  matrix.os  }}
    defaults:
      run:
        shell: bash -e {0} # -e to fail on error
 
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-12]
        # python: ["3.9", "3.10"]
 
    env:
      OS: ${{ matrix.os }}
 
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          cache: 'pip'
      - uses: pre-commit/action@v3.0.0
        with:
          extra_args: --files ../../src/multivelo/auxiliary.py \
            ../../src/multivelo/dynamical_chrom_func.py \
            ../../src/multivelo/steady_chrom_func.py \
            ../../src/multivelo/mv_logging.py \
            ../../src/multivelo/settings.py \
            --verbose
 
  test:
    timeout-minutes: 30
    runs-on: ${{  matrix.os  }}
    defaults:
      run:
        shell: bash -e {0} # -e to fail on error
 
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-12]
        python: ["3.9", "3.10"]
 
    env:
      OS: ${{ matrix.os }}
 
    steps:
      # Check
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: "${{ matrix.python }}"
      - name: Install requirements
        run: |
          pip3 install -r requirements.txt
      - name: Test with pytest
        run: |
          pip3 install -e .
          pytest
 

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.

This workflow runs 2 jobs (9 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