CI workflow (caolan/async)
The CI workflow from caolan/async, explained and optimized by Latchkey.
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.
What it does
This is the CI workflow from the caolan/async 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
name: CI
on:
push:
branches-ignore:
- "dependabot/**"
pull_request:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node:
- 20
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v5
- name: ⎔ Setup node ${{ matrix.node }}
uses: actions/setup-node@v5
with:
cache: npm
- name: 📥 Download deps
run: npm ci
- name: 🧪 Run lint
run: npm run lint
build:
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
checks: write # for coverallsapp/github-action to create new checks
contents: read # for actions/checkout to fetch code
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
node:
- 18
- 20
- 21
os: [ubuntu-latest]
browser:
- FirefoxHeadless
include:
- os: windows-latest
node: 20
browser: FirefoxHeadless
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: ⬇️ Checkout
uses: actions/checkout@v5
- name: ⎔ Setup node ${{ matrix.node }}
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: npm
- name: 📥 Download deps
run: npm ci
- name: Run coverage
run: npm test
- name: Run browser tests
if: matrix.node == 20
run: npm run mocha-browser-test -- --browsers ${{ matrix.browser }} --timeout 10000
env:
DISPLAY: :99.0
- name: Coverage
if: matrix.os == 'ubuntu-latest' && matrix.node == '20'
run: npm run coverage && npx nyc report --reporter=lcov
- name: Coveralls
if: matrix.os == 'ubuntu-latest' && matrix.node == '20'
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: push: branches-ignore: - "dependabot/**" pull_request: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: node: - 20 steps: - name: ⬇️ Checkout uses: actions/checkout@v5 - name: ⎔ Setup node ${{ matrix.node }} uses: actions/setup-node@v5 with: cache: npm - name: 📥 Download deps run: npm ci - name: 🧪 Run lint run: npm run lint build: timeout-minutes: 30 permissions: actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows checks: write # for coverallsapp/github-action to create new checks contents: read # for actions/checkout to fetch code runs-on: ${{ matrix.os }} needs: lint strategy: fail-fast: false matrix: node: - 18 - 20 - 21 os: [ubuntu-latest] browser: - FirefoxHeadless include: - os: windows-latest node: 20 browser: FirefoxHeadless steps: - name: 🛑 Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ secrets.GITHUB_TOKEN }} - name: ⬇️ Checkout uses: actions/checkout@v5 - name: ⎔ Setup node ${{ matrix.node }} uses: actions/setup-node@v5 with: node-version: ${{ matrix.node }} cache: npm - name: 📥 Download deps run: npm ci - name: Run coverage run: npm test - name: Run browser tests if: matrix.node == 20 run: npm run mocha-browser-test -- --browsers ${{ matrix.browser }} --timeout 10000 env: DISPLAY: :99.0 - name: Coverage if: matrix.os == 'ubuntu-latest' && matrix.node == '20' run: npm run coverage && npx nyc report --reporter=lcov - name: Coveralls if: matrix.os == 'ubuntu-latest' && matrix.node == '20' uses: coverallsapp/github-action@v2.3.6 with: github-token: ${{ secrets.GITHUB_TOKEN }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 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.
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:
- Dependency installs
This workflow runs 2 jobs (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.