validate workflow (testing-library/react-testing-library)
The validate workflow from testing-library/react-testing-library, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, 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 testing-library/react-testing-library 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:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action)
contents: read # to fetch code (actions/checkout)
jobs:
main:
continue-on-error: ${{ matrix.react != 'latest' }}
# ignore all-contributors PRs
if: ${{ !contains(github.head_ref, 'all-contributors') }}
strategy:
fail-fast: false
matrix:
node: [18, 24]
react: ['18.x', latest, canary, experimental]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
# TODO: Can be removed if https://github.com/kentcdodds/kcd-scripts/pull/146 is released
- name: Verify format (`npm run format` committed?)
run: npm run format -- --check --no-write
# as requested by the React team :)
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
- name: ⚛️ Setup react
run: npm install react@${{ matrix.react }} react-dom@${{ matrix.react }}
- name: ⚛️ Setup react types
if: ${{ matrix.react != 'canary' && matrix.react != 'experimental' }}
run:
npm install @types/react@${{ matrix.react }} @types/react-dom@${{
matrix.react }}
- name: ▶️ Run validate script
run: npm run validate
- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
flags: ${{ matrix.react }}
token: ${{ secrets.CODECOV_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: pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action) contents: read # to fetch code (actions/checkout) jobs: main: timeout-minutes: 30 continue-on-error: ${{ matrix.react != 'latest' }} # ignore all-contributors PRs if: ${{ !contains(github.head_ref, 'all-contributors') }} strategy: fail-fast: false matrix: node: [18, 24] react: ['18.x', latest, canary, experimental] runs-on: latchkey-small steps: - name: ⬇️ Checkout repo uses: actions/checkout@v4 - name: ⎔ Setup node uses: actions/setup-node@v4 with: cache: 'npm' node-version: ${{ matrix.node }} - name: 📥 Download deps uses: bahmutov/npm-install@v1 with: useLockFile: false # TODO: Can be removed if https://github.com/kentcdodds/kcd-scripts/pull/146 is released - name: Verify format (`npm run format` committed?) run: npm run format -- --check --no-write # as requested by the React team :) # https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing - name: ⚛️ Setup react run: npm install react@${{ matrix.react }} react-dom@${{ matrix.react }} - name: ⚛️ Setup react types if: ${{ matrix.react != 'canary' && matrix.react != 'experimental' }} run: npm install @types/react@${{ matrix.react }} @types/react-dom@${{ matrix.react }} - name: ▶️ Run validate script run: npm run validate - name: ⬆️ Upload coverage report uses: codecov/codecov-action@v5 with: fail_ci_if_error: true flags: ${{ matrix.react }} token: ${{ secrets.CODECOV_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. - 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.
2 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:
- Dependency installs
This workflow runs 1 job (8 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.