Node.js CI workflow (ryanlelek/Raneto)
The Node.js CI workflow from ryanlelek/Raneto, explained and optimized by Latchkey.
CI health: C - fair
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 ryanlelek/Raneto 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
---
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: ['main']
pull_request:
branches: ['main']
permissions:
contents: read
jobs:
build:
environment: build
strategy:
matrix:
# Windows is currently borked
# https://github.com/nodejs/node/issues/52682
# Disabling for now
# windows-latest
os: [ubuntu-latest]
node_version: [24.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# OS List
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
runs-on: ${{ matrix.os }}
steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# https://github.com/marketplace/actions/setup-node-js-environment
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node_version }}
cache: 'npm'
- run: npm ci --ignore-scripts
- run: npm run build --if-present
- run: npm test
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
--- # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs name: Node.js CI on: push: branches: ['main'] pull_request: branches: ['main'] permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 environment: build strategy: matrix: # Windows is currently borked # https://github.com/nodejs/node/issues/52682 # Disabling for now # windows-latest os: [ubuntu-latest] node_version: [24.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ # OS List # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories runs-on: ${{ matrix.os }} steps: # https://github.com/marketplace/actions/checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # https://github.com/marketplace/actions/setup-node-js-environment - name: Use Node.js ${{ matrix.node_version }} uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: ${{ matrix.node_version }} cache: 'npm' - run: npm ci --ignore-scripts - run: npm run build --if-present - run: npm test
What changed
- 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.
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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.