Skip to content
Latchkey

Node.js CI workflow (shutterstock/rickshaw)

The Node.js CI workflow from shutterstock/rickshaw, explained and optimized by Latchkey.

D

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.

Grade your own workflow free or run it on Latchkey →
Source: shutterstock/rickshaw.github/workflows/ci.yamlLicense MITView source

What it does

This is the Node.js CI workflow from the shutterstock/rickshaw 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

workflow (.yml)
name: Node.js CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [22.x]

    env:
      COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      FAIL_IF_DIST_MESSAGE: "These files are autogenerated. Please don't include changes to these files in your PR"
      # Set the timezone to Eastern Standard Time since that is what the library expects
      TZ: "America/New_York"

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}

    - name: Install dependencies
      run: npm install

    - name: Build project
      run: npm run build

    - name: Run tests
      run: npm run coverage
      
    - name: Check for changed dist files
      run: |
        git fetch origin main --depth=1
        # Check for changes in dist files, using grep's exit status directly
        DIST_CHANGED=$(git diff --name-only HEAD origin/main | grep 'rickshaw\(\.min\)\?\.\(js\|css\)' || true)
        if [ -n "$DIST_CHANGED" ]; then
          echo -e "\033[31m${{ env.FAIL_IF_DIST_MESSAGE }}"
          echo -e "\033[31mChanged files:"
          echo "$DIST_CHANGED"
          exit 1
        fi

    - name: Run Coveralls
      run: npm run coveralls
      if: github.event_name == 'push' && github.ref == 'refs/heads/main'

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: Node.js CI
 
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    strategy:
      matrix:
        node-version: [22.x]
 
    env:
      COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      FAIL_IF_DIST_MESSAGE: "These files are autogenerated. Please don't include changes to these files in your PR"
      # Set the timezone to Eastern Standard Time since that is what the library expects
      TZ: "America/New_York"
 
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
 
    - name: Set up Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        cache: 'npm'
        node-version: ${{ matrix.node-version }}
 
    - name: Install dependencies
      run: npm install
 
    - name: Build project
      run: npm run build
 
    - name: Run tests
      run: npm run coverage
      
    - name: Check for changed dist files
      run: |
        git fetch origin main --depth=1
        # Check for changes in dist files, using grep's exit status directly
        DIST_CHANGED=$(git diff --name-only HEAD origin/main | grep 'rickshaw\(\.min\)\?\.\(js\|css\)' || true)
        if [ -n "$DIST_CHANGED" ]; then
          echo -e "\033[31m${{ env.FAIL_IF_DIST_MESSAGE }}"
          echo -e "\033[31mChanged files:"
          echo "$DIST_CHANGED"
          exit 1
        fi
 
    - name: Run Coveralls
      run: npm run coveralls
      if: github.event_name == 'push' && github.ref == 'refs/heads/main'
 

What changed

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:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow