Skip to content
Latchkey

CI workflow (websockets/ws)

The CI workflow from websockets/ws, 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: websockets/ws.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the websockets/ws 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
  - pull_request

permissions: {}

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        arch:
          - x64
        node:
          - 10
          - 12
          - 14
          - 16
          - 18
          - 20
          - 22
          - 24
          - 26
        os:
          - macOS-latest
          - ubuntu-latest
          - windows-latest
        include:
          - arch: x86
            node: 10
            os: windows-latest
          - arch: x86
            node: 12
            os: windows-latest
          - arch: x86
            node: 14
            os: windows-latest
          - arch: x86
            node: 16
            os: windows-latest
          - arch: x86
            node: 20
            os: windows-latest
          - arch: x86
            node: 22
            os: windows-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node }}
          architecture: ${{ matrix.arch }}
          cache: npm
          cache-dependency-path: ./package.json
      - run: npm install
      - run: npm run lint
        if:
          matrix.os == 'ubuntu-latest' && matrix.node == 24 && matrix.arch ==
          'x64'
      - run: npm test
      - run: |
          id=$(node -e "console.log(crypto.randomBytes(16).toString('hex'))")

          echo "job_id=$id" >> $GITHUB_OUTPUT
        id: get_job_id
        shell: bash
      - uses: coverallsapp/github-action@v2
        with:
          flag-name:
            ${{ steps.get_job_id.outputs.job_id }} (Node.js ${{ matrix.node }}
            ${{ matrix.arch }} on ${{ matrix.os }})
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel: true
  coverage:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - 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: CI
 
on:
  - push
  - pull_request
 
permissions: {}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        arch:
          - x64
        node:
          - 10
          - 12
          - 14
          - 16
          - 18
          - 20
          - 22
          - 24
          - 26
        os:
          - macOS-latest
          - ubuntu-latest
          - windows-latest
        include:
          - arch: x86
            node: 10
            os: windows-latest
          - arch: x86
            node: 12
            os: windows-latest
          - arch: x86
            node: 14
            os: windows-latest
          - arch: x86
            node: 16
            os: windows-latest
          - arch: x86
            node: 20
            os: windows-latest
          - arch: x86
            node: 22
            os: windows-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node }}
          architecture: ${{ matrix.arch }}
          cache: npm
          cache-dependency-path: ./package.json
      - run: npm install
      - run: npm run lint
        if:
          matrix.os == 'ubuntu-latest' && matrix.node == 24 && matrix.arch ==
          'x64'
      - run: npm test
      - run: |
          id=$(node -e "console.log(crypto.randomBytes(16).toString('hex'))")
 
          echo "job_id=$id" >> $GITHUB_OUTPUT
        id: get_job_id
        shell: bash
      - uses: coverallsapp/github-action@v2
        with:
          flag-name:
            ${{ steps.get_job_id.outputs.job_id }} (Node.js ${{ matrix.node }}
            ${{ matrix.arch }} on ${{ matrix.os }})
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel: true
  coverage:
    timeout-minutes: 30
    needs: test
    runs-on: latchkey-small
    steps:
      - uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true
 

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 2 jobs (28 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