Skip to content
Latchkey

CI workflow (MrSwitch/hello.js)

The CI workflow from MrSwitch/hello.js, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: MrSwitch/hello.js.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the MrSwitch/hello.js 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]

concurrency:
  group: "pages"
  cancel-in-progress: false


jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 22
      - run: npm i
      - run: npm run lint

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 22
      # Browserstack fix https://github.com/browserstack/browserstack-runner/issues/224#issuecomment-803409764
      - run: rm ./package-lock.json
      - run: npm i
      - run: npm test
      - run: npm run test:browserstack
        env:
            BROWSERSTACK_KEY: ${{ secrets.BROWSERSTACK_KEY }}
            BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}

  release:
    needs:
      - lint
      - test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 22
      - run: npm i
      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx semantic-release

  build:
    if: github.ref == 'refs/heads/main'
    needs:
      - release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 22
      - run: npm i
      - run: npm run build
      - run: rm -rf node_modules/
      - uses: actions/upload-pages-artifact@v3
        with:
          path: ./

  deploy:
    if: github.ref == 'refs/heads/main'
    needs: build
    runs-on: ubuntu-latest
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v4

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]
 
concurrency:
  group: "pages"
  cancel-in-progress: false
 
 
jobs:
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 22
      - run: npm i
      - run: npm run lint
 
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 22
      # Browserstack fix https://github.com/browserstack/browserstack-runner/issues/224#issuecomment-803409764
      - run: rm ./package-lock.json
      - run: npm i
      - run: npm test
      - run: npm run test:browserstack
        env:
            BROWSERSTACK_KEY: ${{ secrets.BROWSERSTACK_KEY }}
            BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
 
  release:
    timeout-minutes: 30
    needs:
      - lint
      - test
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 22
      - run: npm i
      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx semantic-release
 
  build:
    timeout-minutes: 30
    if: github.ref == 'refs/heads/main'
    needs:
      - release
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 22
      - run: npm i
      - run: npm run build
      - run: rm -rf node_modules/
      - uses: actions/upload-pages-artifact@v3
        with:
          path: ./
 
  deploy:
    timeout-minutes: 30
    if: github.ref == 'refs/heads/main'
    needs: build
    runs-on: latchkey-small
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v4
 

What changed

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

Actions used in this workflow