Skip to content
Latchkey

Tests workflow (exceljs/exceljs)

The Tests workflow from exceljs/exceljs, explained and optimized by Latchkey.

C

CI health: C - fair

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

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

What it does

This is the Tests workflow from the exceljs/exceljs 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: Tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ '**' ]

jobs:
  test:
    timeout-minutes: 10
    name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        node-version: [10.x, 12.x, 14.x, 16.x, 17.x, 18.x, 19.x, 20.x]
        os: [ubuntu-latest, macOS-latest, windows-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - name: Set git config
        shell: bash
        run: |
          git config --global core.autocrlf false
          git config --global core.symlinks true
        if: runner.os == 'Windows'
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          node-version: ${{ matrix.node-version }}
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-${{ runner.os }}-node-${{ matrix.node-version }}-npm-
      - run: npm install
      - run: npm test
        env:
          CI: true

  benchmark:
    timeout-minutes: 15
    name: Measure performance impact of changes
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          node-version: 18
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-npm-
      - run: npm install
      - run: npm run benchmark
        env:
          CI: true

  typescript:
    timeout-minutes: 15
    name: Ensure typescript compatibility
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          node-version: 18
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-npm-
      - run: npm install
      - run: npm install typescript
      - run: tsc index.d.ts
        env:
          CI: true

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:
  push:
    branches: [ master ]
  pull_request:
    branches: [ '**' ]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 10
    name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        node-version: [10.x, 12.x, 14.x, 16.x, 17.x, 18.x, 19.x, 20.x]
        os: [ubuntu-latest, macOS-latest, windows-latest]
    runs-on: ${{ matrix.os }}
 
    steps:
      - name: Set git config
        shell: bash
        run: |
          git config --global core.autocrlf false
          git config --global core.symlinks true
        if: runner.os == 'Windows'
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          cache: 'npm'
          node-version: ${{ matrix.node-version }}
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-${{ runner.os }}-node-${{ matrix.node-version }}-npm-
      - run: npm install
      - run: npm test
        env:
          CI: true
 
  benchmark:
    timeout-minutes: 15
    name: Measure performance impact of changes
    runs-on: latchkey-small
 
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          cache: 'npm'
          node-version: 18
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-npm-
      - run: npm install
      - run: npm run benchmark
        env:
          CI: true
 
  typescript:
    timeout-minutes: 15
    name: Ensure typescript compatibility
    runs-on: latchkey-small
 
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade
      - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest  v3. TODO upgrade
        with:
          cache: 'npm'
          node-version: 18
      - name: Create the npm cache directory
        run: mkdir npm-cache && npm config set cache ./npm-cache --global
      - name: Cache node modules
        uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade
        with:
          path: ./npm-cache
          key: v1-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            v1-npm-
      - run: npm install
      - run: npm install typescript
      - run: tsc index.d.ts
        env:
          CI: true
 

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