build-scratch-blocks workflow (scratchfoundation/scratch-blocks)
The build-scratch-blocks workflow from scratchfoundation/scratch-blocks, explained and optimized by Latchkey.
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.
What it does
This is the build-scratch-blocks workflow from the scratchfoundation/scratch-blocks repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: build-scratch-blocks
on:
push: # Runs whenever a commit is pushed to the repository
pull_request: # Runs on pull requests (including from forks)
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Setup Node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
with:
node-version-file: '.nvmrc'
- name: Install Node Dependencies
run: npm ci
- name: Run lint
run: npm run test:lint
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Setup Node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
with:
node-version-file: '.nvmrc'
- name: Install Node Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
- name: Run tests
run: npm test
- name: Run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release
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-scratch-blocks on: push: # Runs whenever a commit is pushed to the repository pull_request: # Runs on pull requests (including from forks) workflow_dispatch: # Allows you to run this workflow manually from the Actions tab concurrency: group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: lint: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Node uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6 with: cache: 'npm' node-version-file: '.nvmrc' - name: Install Node Dependencies run: npm ci - name: Run lint run: npm run test:lint build-and-test: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup Node uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6 with: cache: 'npm' node-version-file: '.nvmrc' - name: Install Node Dependencies run: npm ci - name: Build run: npm run build - name: Install Playwright browsers run: npx playwright install chromium --with-deps - name: Run tests run: npm test - name: Run semantic-release env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx --no -- semantic-release
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- 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
- End-to-end and browser tests
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.