Skip to content
Latchkey

Tests workflow (addyosmani/critical)

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

What it does

This is the Tests workflow from the addyosmani/critical 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: [push, pull_request]

env:
  CI: true
  PUPPETEER_SKIP_DOWNLOAD: true

jobs:
  run:
    name: Node ${{ matrix.node }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        node: ["22", "24"]
        os: [ubuntu-latest, windows-latest]

    steps:
      - name: Clone repository
        uses: actions/checkout@v5
        with:
          persist-credentials: false

      - name: Set up Chrome
        uses: browser-actions/setup-chrome@v2
        id: setup-chrome
        with:
          chrome-version: stable

      - name: Set up Vite+
        uses: voidzero-dev/setup-vp@v1
        with:
          node-version: ${{ matrix.node }}
          cache: true
          run-install: false

      - name: Install dependencies
        run: vp install --frozen-lockfile

      - name: Run checks
        run: vp check

      - name: Run tests
        run: vp test run --coverage
        env:
          PUPPETEER_EXECUTABLE_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}

      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          flag-name: run-${{ matrix.os }}-${{ matrix.node }}
          parallel: true

  finish:
    needs: run
    if: always()
    runs-on: ubuntu-latest
    steps:
      - name: Coveralls Finished
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true

The same workflow, on Latchkey

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

name: Tests
 
on: [push, pull_request]
 
env:
  CI: true
  PUPPETEER_SKIP_DOWNLOAD: true
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  run:
    timeout-minutes: 30
    name: Node ${{ matrix.node }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
 
    strategy:
      fail-fast: false
      matrix:
        node: ["22", "24"]
        os: [ubuntu-latest, windows-latest]
 
    steps:
      - name: Clone repository
        uses: actions/checkout@v5
        with:
          persist-credentials: false
 
      - name: Set up Chrome
        uses: browser-actions/setup-chrome@v2
        id: setup-chrome
        with:
          chrome-version: stable
 
      - name: Set up Vite+
        uses: voidzero-dev/setup-vp@v1
        with:
          node-version: ${{ matrix.node }}
          cache: true
          run-install: false
 
      - name: Install dependencies
        run: vp install --frozen-lockfile
 
      - name: Run checks
        run: vp check
 
      - name: Run tests
        run: vp test run --coverage
        env:
          PUPPETEER_EXECUTABLE_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
 
      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          flag-name: run-${{ matrix.os }}-${{ matrix.node }}
          parallel: true
 
  finish:
    timeout-minutes: 30
    needs: run
    if: always()
    runs-on: latchkey-small
    steps:
      - name: Coveralls Finished
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true
 

What changed

3 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 2 jobs (5 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