Node.js CI workflow (sahat/hackathon-starter)
The Node.js CI workflow from sahat/hackathon-starter, explained and optimized by Latchkey.
CI health: A - excellent
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Node.js CI workflow from the sahat/hackathon-starter 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: Node.js CI
on:
push:
branches: ['master']
pull_request:
branches: ['master']
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
env:
RUN_E2E: ${{ vars.RUN_E2E }} # from repository settings -> Actions -> Variables
strategy:
matrix:
node-version: [24.x, 26.x]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run lint-check
- run: npm run test
# For testing in Windows CI, we need to limit the path to exclude the additional executables
# that the default github runner has, but are not on a vanilla Windows OS installation.
- if: ${{ (env.RUN_E2E == 'true' || github.repository == 'sahat/hackathon-starter') && matrix.os == 'windows-latest' }}
env:
PATH: 'C:\Windows\System32;C:\Windows'
run: npm run test:e2e:replay
# if not Windows, run normally
- if: ${{ (env.RUN_E2E == 'true' || github.repository == 'sahat/hackathon-starter') && matrix.os != 'windows-latest' }}
run: npm run test:e2e:replay
- name: Upload tmp as an artifact (Playwrite artifacts, code coverage report, etc)
if: always()
uses: actions/upload-artifact@v7
with:
name: tmp-artifacts-${{ matrix.os }}-${{ github.job }}-${{ github.run_id }}
path: tmp/**
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Node.js CI on: push: branches: ['master'] pull_request: branches: ['master'] workflow_dispatch: permissions: contents: read pull-requests: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: ${{ matrix.os }} env: RUN_E2E: ${{ vars.RUN_E2E }} # from repository settings -> Actions -> Variables strategy: matrix: node-version: [24.x, 26.x] os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v7 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm install - run: npm run lint-check - run: npm run test # For testing in Windows CI, we need to limit the path to exclude the additional executables # that the default github runner has, but are not on a vanilla Windows OS installation. - if: ${{ (env.RUN_E2E == 'true' || github.repository == 'sahat/hackathon-starter') && matrix.os == 'windows-latest' }} env: PATH: 'C:\Windows\System32;C:\Windows' run: npm run test:e2e:replay # if not Windows, run normally - if: ${{ (env.RUN_E2E == 'true' || github.repository == 'sahat/hackathon-starter') && matrix.os != 'windows-latest' }} run: npm run test:e2e:replay - name: Upload tmp as an artifact (Playwrite artifacts, code coverage report, etc) if: always() uses: actions/upload-artifact@v7 with: name: tmp-artifacts-${{ matrix.os }}-${{ github.job }}-${{ github.run_id }} path: tmp/**
What changed
- 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
- End-to-end and browser tests
This workflow runs 1 job (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.