Test workflow (adaltas/node-csv)
The Test workflow from adaltas/node-csv, explained and optimized by Latchkey.
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.
What it does
This is the Test workflow from the adaltas/node-csv 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: Test
on:
push:
pull_request:
# See https://docs.npmjs.com/trusted-publishers
permissions:
id-token: write # Required for NPM integration with OIDC
contents: read
jobs:
is_release:
runs-on: ubuntu-latest
outputs:
type: ${{ steps.get_type.outputs.type }}
continue-on-error: true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: get_type
run: echo $( git tag --points-at HEAD | grep -q -e '^.*@.*$' && echo 'type=::release::' || echo "type=::norelease::" ) >> "$GITHUB_OUTPUT"
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run test
# test_16:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [16.x]
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# - run: npm install
# - run: npm run test:16
# test_legacy:
# needs: [is_release]
# if: ${{ needs.is_release.outputs.type == '::norelease::' }}
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [14.x]
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# - run: |
# cwd=`pwd`
# for pkg in packages/*/package.json; do
# cd $cwd/`dirname $pkg`
# npm install
# npm run test:legacy;
# done
publish:
needs: [is_release, test]
if: ${{ needs.is_release.outputs.type == '::release::' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
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: Test on: push: pull_request: # See https://docs.npmjs.com/trusted-publishers permissions: id-token: write # Required for NPM integration with OIDC contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: is_release: runs-on: latchkey-small outputs: type: ${{ steps.get_type.outputs.type }} continue-on-error: true steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - id: get_type run: echo $( git tag --points-at HEAD | grep -q -e '^.*@.*$' && echo 'type=::release::' || echo "type=::norelease::" ) >> "$GITHUB_OUTPUT" test: runs-on: latchkey-small strategy: matrix: node-version: [20.x, 22.x, 24.x] steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: cache: 'npm' node-version: ${{ matrix.node-version }} - run: npm install - run: npm run test # test_16: # runs-on: latchkey-small # strategy: # matrix: # node-version: [16.x] # steps: # - uses: actions/checkout@v4 # with: # fetch-depth: 0 # - name: Use Node.js ${{ matrix.node-version }} # uses: actions/setup-node@v4 with: cache: 'npm' # with: # node-version: ${{ matrix.node-version }} # - run: npm install # - run: npm run test:16 # test_legacy: # needs: [is_release] # if: ${{ needs.is_release.outputs.type == '::norelease::' }} # runs-on: latchkey-small # strategy: # matrix: # node-version: [14.x] # steps: # - uses: actions/checkout@v4 # with: # fetch-depth: 0 # - name: Use Node.js ${{ matrix.node-version }} # uses: actions/setup-node@v4 with: cache: 'npm' # with: # node-version: ${{ matrix.node-version }} # - run: | # cwd=`pwd` # for pkg in packages/*/package.json; do # cd $cwd/`dirname $pkg` # npm install # npm run test:legacy; # done publish: needs: [is_release, test] if: ${{ needs.is_release.outputs.type == '::release::' }} runs-on: latchkey-small steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - uses: actions/setup-node@v6 with: cache: 'npm' node-version: "24.x" registry-url: "https://registry.npmjs.org" - run: npm ci - run: npm run publish # env: # NODE_AUTH_TOKEN: ${{ secrets.NPM_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.
- Cache dependency installs on the setup step so they are served from cache.
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 (5 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.