CI workflow (qunitjs/qunit)
The CI workflow from qunitjs/qunit, explained and optimized by Latchkey.
CI health: D - needs work
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the qunitjs/qunit 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
- pull_request
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
main-test:
strategy:
fail-fast: false
matrix:
include:
- name: "Linux: Node 18"
# Includes 'firefox', 'chromium', and more.
# https://github.com/actions/virtual-environments/blob/ubuntu20/20220410.2/images/linux/Ubuntu2004-Readme.md
os: ubuntu-22.04
node: 18.x
script: npm test
- name: "Linux: Node 20"
os: ubuntu-22.04
node: 20.x
script: npm run test
- name: "Linux: Node 22"
os: ubuntu-24.04
node: 22.x
script: npm run test
- name: "Demos"
os: ubuntu-22.04
node: 18.x
script: npm run test-demos
- name: "Windows: Node 18"
os: windows-latest
node: 18.x
script: npm run test-nolint
- name: "macOS: Node 18"
os: macos-latest
node: 18.x
script: npm run test-nolint
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download"
FORCE_COLOR: "1"
steps:
- uses: actions/checkout@v6
- uses: actions/cache@v5
if: ${{ runner.os != 'Windows' }}
with:
path: |
~/.npm
${{ github.workspace }}/.puppeteer_download
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
- run: npm install
- name: Tests
run: ${{ matrix.script }}
# To reproduce SpiderMonkey 102 builds locally:
#
# ```
# you:/qunit$ npm run build
#
# you:/qunit$ export MNT=$(basename "$PWD"); docker run --rm --interactive --tty --mount type=bind,source="$PWD",target="/$MNT",readonly --entrypoint /bin/sh debian:12-slim -c "cd /$MNT;bash"
# ```
# ```
# root@ubuntu:/qunit$ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-102-dev
# root@ubuntu:/qunit$ js102 test/mozjs.js
# ```
mozjs-102:
name: SpiderMonkey 102
runs-on: ubuntu-24.04
env:
PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download"
steps:
- uses: actions/checkout@v6
- uses: actions/cache@v5
with:
path: |
~/.npm
${{ github.workspace }}/.puppeteer_download
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- name: Use Node.js 18
uses: actions/setup-node@v6
with:
node-version: 18.x
- name: Install mozjs
run: |
sudo apt-get install -y libmozjs-102-dev
- run: npm install
- run: npm run build
- name: Test mozjs.js
run: js102 test/mozjs.js
- name: Test mozjs.mjs
run: js102 -m test/mozjs.mjs
# To reproduce SpiderMonkey 115 builds locally:
#
# ```
# you:/qunit$ npm run build
#
# you:/qunit$ export MNT=$(basename "$PWD"); docker run --rm --interactive --tty --mount type=bind,source="$PWD",target="/$MNT",readonly --entrypoint /bin/sh ubuntu:24.04 -c "cd /$MNT;bash"
# ```
# ```
# root@ubuntu:/qunit$ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-115-dev
# root@ubuntu:/qunit$ js115 test/mozjs.js
# ```
mozjs-115:
name: SpiderMonkey 115
runs-on: ubuntu-24.04
env:
PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download"
steps:
- uses: actions/checkout@v6
- uses: actions/cache@v5
with:
path: |
~/.npm
${{ github.workspace }}/.puppeteer_download
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- name: Use Node.js 18
uses: actions/setup-node@v6
with:
node-version: 18.x
- name: Install mozjs
run: |
sudo apt-get install -y libmozjs-115-dev
- run: npm install
- run: npm run build
- name: Test mozjs.js
run: js115 test/mozjs.js
- name: Test mozjs.mjs
run: js115 -m test/mozjs.mjs
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: CI on: - push - pull_request # A workflow run is made up of one or more jobs that can run sequentially or in parallel concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: main-test: timeout-minutes: 30 strategy: fail-fast: false matrix: include: - name: "Linux: Node 18" # Includes 'firefox', 'chromium', and more. # https://github.com/actions/virtual-environments/blob/ubuntu20/20220410.2/images/linux/Ubuntu2004-Readme.md os: ubuntu-22.04 node: 18.x script: npm test - name: "Linux: Node 20" os: ubuntu-22.04 node: 20.x script: npm run test - name: "Linux: Node 22" os: ubuntu-24.04 node: 22.x script: npm run test - name: "Demos" os: ubuntu-22.04 node: 18.x script: npm run test-demos - name: "Windows: Node 18" os: windows-latest node: 18.x script: npm run test-nolint - name: "macOS: Node 18" os: macos-latest node: 18.x script: npm run test-nolint name: ${{ matrix.name }} runs-on: ${{ matrix.os }} env: PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download" FORCE_COLOR: "1" steps: - uses: actions/checkout@v6 - uses: actions/cache@v5 if: ${{ runner.os != 'Windows' }} with: path: | ~/.npm ${{ github.workspace }}/.puppeteer_download key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v6 with: cache: 'npm' node-version: ${{ matrix.node }} - run: npm install - name: Tests run: ${{ matrix.script }} # To reproduce SpiderMonkey 102 builds locally: # # ``` # you:/qunit$ npm run build # # you:/qunit$ export MNT=$(basename "$PWD"); docker run --rm --interactive --tty --mount type=bind,source="$PWD",target="/$MNT",readonly --entrypoint /bin/sh debian:12-slim -c "cd /$MNT;bash" # ``` # ``` # root@ubuntu:/qunit$ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-102-dev # root@ubuntu:/qunit$ js102 test/mozjs.js # ``` mozjs-102: timeout-minutes: 30 name: SpiderMonkey 102 runs-on: latchkey-small env: PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download" steps: - uses: actions/checkout@v6 - uses: actions/cache@v5 with: path: | ~/.npm ${{ github.workspace }}/.puppeteer_download key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - name: Use Node.js 18 uses: actions/setup-node@v6 with: cache: 'npm' node-version: 18.x - name: Install mozjs run: | sudo apt-get install -y libmozjs-102-dev - run: npm install - run: npm run build - name: Test mozjs.js run: js102 test/mozjs.js - name: Test mozjs.mjs run: js102 -m test/mozjs.mjs # To reproduce SpiderMonkey 115 builds locally: # # ``` # you:/qunit$ npm run build # # you:/qunit$ export MNT=$(basename "$PWD"); docker run --rm --interactive --tty --mount type=bind,source="$PWD",target="/$MNT",readonly --entrypoint /bin/sh ubuntu:24.04 -c "cd /$MNT;bash" # ``` # ``` # root@ubuntu:/qunit$ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-115-dev # root@ubuntu:/qunit$ js115 test/mozjs.js # ``` mozjs-115: timeout-minutes: 30 name: SpiderMonkey 115 runs-on: latchkey-small env: PUPPETEER_CACHE_DIR: "${{ github.workspace }}/.puppeteer_download" steps: - uses: actions/checkout@v6 - uses: actions/cache@v5 with: path: | ~/.npm ${{ github.workspace }}/.puppeteer_download key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - name: Use Node.js 18 uses: actions/setup-node@v6 with: cache: 'npm' node-version: 18.x - name: Install mozjs run: | sudo apt-get install -y libmozjs-115-dev - run: npm install - run: npm run build - name: Test mozjs.js run: js115 test/mozjs.js - name: Test mozjs.mjs run: js115 -m test/mozjs.mjs
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.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
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 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.