Skip to content
Latchkey

Tests workflow (jcmgray/cotengra)

The Tests workflow from jcmgray/cotengra, 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: jcmgray/cotengra.github/workflows/test.ymlLicense Apache-2.0View source

What it does

This is the Tests workflow from the jcmgray/cotengra repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

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

The workflow

workflow (.yml)
name: Tests

on:
  workflow_dispatch:
  push:
  pull_request:

defaults:
  run:
    shell: bash -l {0}

jobs:
  run-tests:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
        - os: ubuntu-latest
          pixi_environment: testminimal
          pixi_task: test

        - os: ubuntu-latest
          pixi_environment: testpyold
          pixi_task: test

        - os: ubuntu-latest
          pixi_environment: testpynew
          pixi_task: test

        - os: macos-latest
          pixi_environment: testpymid
          pixi_task: test

        - os: windows-latest
          pixi_environment: testpymid
          pixi_task: test

        - os: ubuntu-latest
          pixi_environment: testtorch
          pixi_task: test-backends

        - os: ubuntu-latest
          pixi_environment: testjax
          pixi_task: test-backends

        - os: ubuntu-latest
          pixi_environment: testtensorflow
          pixi_task: test-backends

    steps:
    - uses: actions/checkout@v7

    - uses: prefix-dev/setup-pixi@v0.9.6
      with:
        environments: ${{ matrix.pixi_environment }}

    - name: Test with pytest
      run: pixi run -e ${{ matrix.pixi_environment }} ${{ matrix.pixi_task }}

    - name: Report to codecov
      uses: codecov/codecov-action@v7
      with:
        token: ${{ secrets.CODECOV_TOKEN }}

The same workflow, on Latchkey

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

name: Tests
 
on:
  workflow_dispatch:
  push:
  pull_request:
 
defaults:
  run:
    shell: bash -l {0}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  run-tests:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
        - os: ubuntu-latest
          pixi_environment: testminimal
          pixi_task: test
 
        - os: ubuntu-latest
          pixi_environment: testpyold
          pixi_task: test
 
        - os: ubuntu-latest
          pixi_environment: testpynew
          pixi_task: test
 
        - os: macos-latest
          pixi_environment: testpymid
          pixi_task: test
 
        - os: windows-latest
          pixi_environment: testpymid
          pixi_task: test
 
        - os: ubuntu-latest
          pixi_environment: testtorch
          pixi_task: test-backends
 
        - os: ubuntu-latest
          pixi_environment: testjax
          pixi_task: test-backends
 
        - os: ubuntu-latest
          pixi_environment: testtensorflow
          pixi_task: test-backends
 
    steps:
    - uses: actions/checkout@v7
 
    - uses: prefix-dev/setup-pixi@v0.9.6
      with:
        environments: ${{ matrix.pixi_environment }}
 
    - name: Test with pytest
      run: pixi run -e ${{ matrix.pixi_environment }} ${{ matrix.pixi_task }}
 
    - name: Report to codecov
      uses: codecov/codecov-action@v7
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
 

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.

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