Skip to content
Latchkey

Tests workflow (americanexpress/jest-image-snapshot)

The Tests workflow from americanexpress/jest-image-snapshot, explained and optimized by Latchkey.

D

CI health: D - needs work

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: americanexpress/jest-image-snapshot.github/workflows/tests.ymlLicense Apache-2.0View source

What it does

This is the Tests workflow from the americanexpress/jest-image-snapshot 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:
  pull_request:
    branches:
      - main

jobs:
  tests:
    strategy:
      matrix:
        node: [ '18.x', '20.x', '22.x' ]
        os: [ ubuntu-latest, windows-latest, macos-latest ]
    runs-on: ${{ matrix.os }}
    name: Node ${{ matrix.node }} - ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
    - run: |
        git remote set-branches --add origin main
        git fetch
    - name: Setup Node
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node }}
    - name: Install Dependencies
      run: npm ci
      env:
        NODE_ENV: development
    - name: Unit Tests
      run: npm run test
      env:
        NODE_ENV: production
    - name: Lockfile Lint Test
      run: npm run test:lockfile
      env:
        NODE_ENV: production
    - name: Git History Test
      run: npm run test:git-history
      env:
        NODE_ENV: production
    - name: Lint
      run: npm run lint
      env:
        NODE_ENV: production

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:
  pull_request:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    strategy:
      matrix:
        node: [ '18.x', '20.x', '22.x' ]
        os: [ ubuntu-latest, windows-latest, macos-latest ]
    runs-on: ${{ matrix.os }}
    name: Node ${{ matrix.node }} - ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
    - run: |
        git remote set-branches --add origin main
        git fetch
    - name: Setup Node
      uses: actions/setup-node@v2
      with:
        cache: 'npm'
        node-version: ${{ matrix.node }}
    - name: Install Dependencies
      run: npm ci
      env:
        NODE_ENV: development
    - name: Unit Tests
      run: npm run test
      env:
        NODE_ENV: production
    - name: Lockfile Lint Test
      run: npm run test:lockfile
      env:
        NODE_ENV: production
    - name: Git History Test
      run: npm run test:git-history
      env:
        NODE_ENV: production
    - name: Lint
      run: npm run lint
      env:
        NODE_ENV: production
 

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 (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