Skip to content
Latchkey

CI workflow (metalsmith/metalsmith)

The CI workflow from metalsmith/metalsmith, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: metalsmith/metalsmith.github/workflows/test.ymlLicense MITView source

What it does

This is the CI workflow from the metalsmith/metalsmith 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

workflow (.yml)
name: CI
on:
  push:
    branches: ['**']
  pull_request:
    branches: ['master']

jobs:
  pre-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'

      - run: npm install
      - run: npm run format:check
      - run: npm run lint:check

  branch-test:
    if: github.ref_name != 'master' && success()
    needs: pre-test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ['ubuntu-latest', 'windows-latest']
        node: ['16.0']
    name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'

      - run: npm install
      - run: npm test

  test:
    if: github.ref_name == 'master' && success()
    needs: pre-test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ['ubuntu-latest', 'windows-latest']
        node: ['16.0', '18', '20', '22', '24']
    name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node }}
          cache: 'npm'
      - run: git config --global user.name "MetalsmithCI" && git config --global user.email "ci@metalsmith.io" && git config --global init.defaultBranch main
      - run: npm install --no-package-lock
      - run: npm test
      - run: npm run test:types
      - if: matrix.os == 'ubuntu-latest' && matrix.node == '24'
        run: npm run coverage
      - if: matrix.os == 'ubuntu-latest' && matrix.node == '24'
        uses: coverallsapp/github-action@v2
        with:
          file: ./coverage.info
          format: lcov

The same workflow, on Latchkey

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

name: CI
on:
  push:
    branches: ['**']
  pull_request:
    branches: ['master']
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-test:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
 
      - run: npm install
      - run: npm run format:check
      - run: npm run lint:check
 
  branch-test:
    timeout-minutes: 30
    if: github.ref_name != 'master' && success()
    needs: pre-test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ['ubuntu-latest', 'windows-latest']
        node: ['16.0']
    name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
 
      - run: npm install
      - run: npm test
 
  test:
    timeout-minutes: 30
    if: github.ref_name == 'master' && success()
    needs: pre-test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ['ubuntu-latest', 'windows-latest']
        node: ['16.0', '18', '20', '22', '24']
    name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node }}
          cache: 'npm'
      - run: git config --global user.name "MetalsmithCI" && git config --global user.email "ci@metalsmith.io" && git config --global init.defaultBranch main
      - run: npm install --no-package-lock
      - run: npm test
      - run: npm run test:types
      - if: matrix.os == 'ubuntu-latest' && matrix.node == '24'
        run: npm run coverage
      - if: matrix.os == 'ubuntu-latest' && matrix.node == '24'
        uses: coverallsapp/github-action@v2
        with:
          file: ./coverage.info
          format: lcov
 

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 3 jobs (13 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