Skip to content
Latchkey

Build Status workflow (holepunchto/hypercore)

The Build Status workflow from holepunchto/hypercore, 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: holepunchto/hypercore.github/workflows/test-node.ymlLicense MITView source

What it does

This is the Build Status workflow from the holepunchto/hypercore 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: Build Status
on:
  push:
    branches:
      - main
      - rocksdb
    tags: # To trigger the canary
      - '*'
  pull_request:
    branches:
      - main
      - rocksdb
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
      - uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
      - run: npm install
      - run: npm run lint
  build:
    if: ${{ !startsWith(github.ref, 'refs/tags/')}} # Already runs for the push of the commit, no need to run again for the tag
    strategy:
      matrix:
        node-version: [lts/*]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install
      - run: npm test
      - run: npm -g install bare
      - run: npm run test:bare
  trigger_canary:
    if: startsWith(github.ref, 'refs/tags/') # Only run when a new package is published (detects when a new tag is pushed)
    runs-on: ubuntu-latest
    steps:
      - name: trigger canary
        run: |
          curl -L -X POST \
          -H "Accept: application/vnd.github+json" \
          -H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          https://api.github.com/repos/holepunchto/canary-tests/dispatches \
          -d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}'

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: Build Status
on:
  push:
    branches:
      - main
      - rocksdb
    tags: # To trigger the canary
      - '*'
  pull_request:
    branches:
      - main
      - rocksdb
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
      - uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
        with:
          cache: 'npm'
      - run: npm install
      - run: npm run lint
  build:
    timeout-minutes: 30
    if: ${{ !startsWith(github.ref, 'refs/tags/')}} # Already runs for the push of the commit, no need to run again for the tag
    strategy:
      matrix:
        node-version: [lts/*]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
        with:
          cache: 'npm'
          node-version: ${{ matrix.node-version }}
      - run: npm install
      - run: npm test
      - run: npm -g install bare
      - run: npm run test:bare
  trigger_canary:
    timeout-minutes: 30
    if: startsWith(github.ref, 'refs/tags/') # Only run when a new package is published (detects when a new tag is pushed)
    runs-on: latchkey-small
    steps:
      - name: trigger canary
        run: |
          curl -L -X POST \
          -H "Accept: application/vnd.github+json" \
          -H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          https://api.github.com/repos/holepunchto/canary-tests/dispatches \
          -d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}'
 

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 3 jobs (5 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