Test workflow (SALib/SALib)
The Test workflow from SALib/SALib, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Test workflow from the SALib/SALib 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
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.12', '3.14']
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: SALib
python-version: ${{ matrix.python-version }}
channels: conda-forge
miniforge-version: latest
use-mamba: true
channel-priority: true
- name: Get Date
id: get-date
run: echo "::set-output name=month::$(/bin/date -u '+%Y%m')"
shell: bash
- name: Cache conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ${{ env.CONDA }}/envs/SALib
key:
${{ runner.os }}--${{ steps.get-date.outputs.month }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
id: envcache
- name: Update Conda Environment
run: |
mamba env update -n SALib -f environment.yml
if: steps.envcache.outputs.cache-hit != 'true'
- name: Install package
run: |
conda activate SALib
pip install .[test]
- name: Test
if: matrix.python-version != '3.12'
run: |
conda activate SALib
pytest
- name: Test with coverage and uploads
if: matrix.python-version == '3.12'
run: |
conda activate SALib
python -m pip install coveralls
pytest --cov SALib --cov-report html --verbose
coveralls
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Test on: push: branches: [ main ] pull_request: branches: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: pytest: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ['3.10', '3.12', '3.14'] defaults: run: shell: bash -l {0} steps: - uses: actions/checkout@v3 - name: Set up conda uses: conda-incubator/setup-miniconda@v3 with: activate-environment: SALib python-version: ${{ matrix.python-version }} channels: conda-forge miniforge-version: latest use-mamba: true channel-priority: true - name: Get Date id: get-date run: echo "::set-output name=month::$(/bin/date -u '+%Y%m')" shell: bash - name: Cache conda uses: actions/cache@v3 env: # Increase this value to reset cache if environment.yml has not changed CACHE_NUMBER: 0 with: path: ${{ env.CONDA }}/envs/SALib key: ${{ runner.os }}--${{ steps.get-date.outputs.month }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} id: envcache - name: Update Conda Environment run: | mamba env update -n SALib -f environment.yml if: steps.envcache.outputs.cache-hit != 'true' - name: Install package run: | conda activate SALib pip install .[test] - name: Test if: matrix.python-version != '3.12' run: | conda activate SALib pytest - name: Test with coverage and uploads if: matrix.python-version == '3.12' run: | conda activate SALib python -m pip install coveralls pytest --cov SALib --cov-report html --verbose coveralls
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 1 job (3 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.