validate workflow (downshift-js/downshift)
The validate workflow from downshift-js/downshift, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the validate workflow from the downshift-js/downshift 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
name: validate
on:
push:
branches:
- '+([0-9])?(.{+([0-9]),x}).x'
- 'master'
- 'next'
- 'next-major'
- 'beta'
- 'alpha'
- '!all-contributors/**'
pull_request: {}
jobs:
main:
# ignore all-contributors PRs
if: ${{ !contains(github.head_ref, 'all-contributors') }}
strategy:
matrix:
node: [20, 22, 24]
runs-on: ubuntu-latest
steps:
- name: π Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: β¬οΈ Checkout repo
uses: actions/checkout@v5
- name: Increase watchers
run:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
&& sudo sysctl -p
- name: β Setup node
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
- name: π₯ Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: π Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: βΆοΈ Run validate script
run: npm run validate
env:
FORCE_COLOR: true
- name: β¬οΈ Upload coverage report
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
release:
needs: main
runs-on: ubuntu-latest
if:
${{ github.repository == 'downshift-js/downshift' &&
contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha',
github.ref) && github.event_name == 'push' }}
steps:
- name: π Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: β¬οΈ Checkout repo
uses: actions/checkout@v5
- name: β Setup node
uses: actions/setup-node@v5
with:
node-version: 24
- name: π₯ Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: π Run build script
run: npm run build
- name: π Release
uses: cycjimmy/semantic-release-action@v6
with:
semantic_version: 24
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
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: validate on: push: branches: - '+([0-9])?(.{+([0-9]),x}).x' - 'master' - 'next' - 'next-major' - 'beta' - 'alpha' - '!all-contributors/**' pull_request: {} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: main: timeout-minutes: 30 # ignore all-contributors PRs if: ${{ !contains(github.head_ref, 'all-contributors') }} strategy: matrix: node: [20, 22, 24] runs-on: latchkey-small steps: - name: π Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ secrets.GITHUB_TOKEN }} - name: β¬οΈ Checkout repo uses: actions/checkout@v5 - name: Increase watchers run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: β Setup node uses: actions/setup-node@v5 with: cache: 'npm' node-version: ${{ matrix.node }} - name: π₯ Download deps uses: bahmutov/npm-install@v1 with: useLockFile: false - name: π Install Playwright browsers run: npx playwright install --with-deps chromium - name: βΆοΈ Run validate script run: npm run validate env: FORCE_COLOR: true - name: β¬οΈ Upload coverage report uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} release: timeout-minutes: 30 needs: main runs-on: latchkey-small if: ${{ github.repository == 'downshift-js/downshift' && contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha', github.ref) && github.event_name == 'push' }} steps: - name: π Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ secrets.GITHUB_TOKEN }} - name: β¬οΈ Checkout repo uses: actions/checkout@v5 - name: β Setup node uses: actions/setup-node@v5 with: cache: 'npm' node-version: 24 - name: π₯ Download deps uses: bahmutov/npm-install@v1 with: useLockFile: false - name: π Run build script run: npm run build - name: π Release uses: cycjimmy/semantic-release-action@v6 with: semantic_version: 24 branches: | [ '+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true} ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
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. - Cancel superseded runs when a branch or PR gets a newer push.
- 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.
4 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
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:
- End-to-end and browser tests
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.