Skip to content
Latchkey

CI workflow (js-cookie/js-cookie)

The CI workflow from js-cookie/js-cookie, 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: js-cookie/js-cookie.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the js-cookie/js-cookie 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: CI

on:
  push: &trigger
    branches: [main]
    paths-ignore:
      - '.devcontainer/**'
      - '.github/**'
      - '!.github/workflows/ci.yml'
      - '.vscode/**'
      - 'examples/**'
      - '**.md'
      - .gitignore
      - .release-it.json
  pull_request: *trigger
  schedule:
    - cron: '0 0 1 * *' # Every month

permissions: {}

env:
  PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
  PUPPETEER_SKIP_DOWNLOAD: 'true'

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [20.x, 22.x, 24.x]
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: |
          npm i -g npm@11.8.0
          npm ci
      - name: Check formatting
        run: npm run format:check
      - name: Lint
        run: npm run lint:check
      - name: Run unit tests
        run: npm test
      - name: Check ECMAScript compatibility
        run: |
          npm run dist
          npx eslint --no-config-lookup --parser espree --parser-options 'ecmaVersion:5,sourceType:script' 'dist/*.js'
          npx eslint --no-config-lookup --parser-options 'ecmaVersion:6' 'dist/*.mjs'

  e2e-test:
    runs-on: ubuntu-latest
    # Skip pull requests!
    if: ${{ ! startsWith(github.event_name, 'pull_request') }}
    needs:
      - build
    steps:
      - name: Set up BrowserStack env
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-env@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          username: ${{ secrets.BROWSERSTACK_USERNAME }}
          access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
          build-name: BUILD_INFO
          project-name: REPO_NAME
      - name: Set up BrowserStack local tunnel
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-local@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          local-testing: start
          local-identifier: random
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: 24.x
      - name: Install dependencies
        run: |
          npm i -g npm@11.8.0
          npm ci
      - name: Run BrowserStack E2E tests
        run: NODE_NO_WARNINGS=1 npm run test:browserstack
      - name: Stop BrowserStackLocal
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-local@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          local-testing: stop

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: &trigger
    branches: [main]
    paths-ignore:
      - '.devcontainer/**'
      - '.github/**'
      - '!.github/workflows/ci.yml'
      - '.vscode/**'
      - 'examples/**'
      - '**.md'
      - .gitignore
      - .release-it.json
  pull_request: *trigger
  schedule:
    - cron: '0 0 1 * *' # Every month
 
permissions: {}
 
env:
  PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
  PUPPETEER_SKIP_DOWNLOAD: 'true'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      matrix:
        node-version: [20.x, 22.x, 24.x]
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          cache: 'npm'
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: |
          npm i -g npm@11.8.0
          npm ci
      - name: Check formatting
        run: npm run format:check
      - name: Lint
        run: npm run lint:check
      - name: Run unit tests
        run: npm test
      - name: Check ECMAScript compatibility
        run: |
          npm run dist
          npx eslint --no-config-lookup --parser espree --parser-options 'ecmaVersion:5,sourceType:script' 'dist/*.js'
          npx eslint --no-config-lookup --parser-options 'ecmaVersion:6' 'dist/*.mjs'
 
  e2e-test:
    timeout-minutes: 30
    runs-on: latchkey-small
    # Skip pull requests!
    if: ${{ ! startsWith(github.event_name, 'pull_request') }}
    needs:
      - build
    steps:
      - name: Set up BrowserStack env
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-env@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          username: ${{ secrets.BROWSERSTACK_USERNAME }}
          access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
          build-name: BUILD_INFO
          project-name: REPO_NAME
      - name: Set up BrowserStack local tunnel
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-local@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          local-testing: start
          local-identifier: random
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          cache: 'npm'
          node-version: 24.x
      - name: Install dependencies
        run: |
          npm i -g npm@11.8.0
          npm ci
      - name: Run BrowserStack E2E tests
        run: NODE_NO_WARNINGS=1 npm run test:browserstack
      - name: Stop BrowserStackLocal
        # Third-party action, pin to commit SHA!
        # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
        uses: browserstack/github-actions/setup-local@00ce173eae311a7838f80682a5fad5144c4219ad
        with:
          local-testing: stop
 

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 2 jobs (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow