Run tests workflow (GoogleChrome/web-vitals)
The Run tests workflow from GoogleChrome/web-vitals, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Run tests workflow from the GoogleChrome/web-vitals 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: Run tests
permissions:
contents: read
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
unit-tests:
name: Run unit tests
# Doesn't require anything special so let's use ubuntu as more available
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: NPM install
run: npm install
- name: Build
run: npm run build
- name: Run unit tests
run: npm run test:unit
chrome-tests:
name: Run Chrome e2e tests
# Runs best on macos for CI as linux requires extra chrome flags
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: NPM install
run: npm install
- name: Build
run: npm run build
- name: Run server
run: npm run test:server &
- name: Run e2e tests for chrome
run: npm run test:e2e -- --browsers=chrome
firefox-tests:
name: Run Firefox e2e tests
# Runs best on macos for CI as linux requires extra setup
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: NPM install
run: npm install
- name: Build
run: npm run build
- name: Run server
run: npm run test:server &
- name: Run e2e tests for firefox
run: npm run test:e2e -- --browsers=firefox
safari-tests:
name: Run Safari e2e tests
# Requires macos
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: NPM install
run: npm install
- name: Build
run: npm run build
- name: Run server
run: npm run test:server &
- name: Run e2e tests for safari
run: npm run test:e2e -- --browsers=safari
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Run tests permissions: contents: read on: pull_request: push: branches: - main workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: unit-tests: timeout-minutes: 30 name: Run unit tests # Doesn't require anything special so let's use ubuntu as more available runs-on: latchkey-small steps: - name: Checkout Code uses: actions/checkout@v6 - name: NPM install run: npm install - name: Build run: npm run build - name: Run unit tests run: npm run test:unit chrome-tests: timeout-minutes: 30 name: Run Chrome e2e tests # Runs best on macos for CI as linux requires extra chrome flags runs-on: macos-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: NPM install run: npm install - name: Build run: npm run build - name: Run server run: npm run test:server & - name: Run e2e tests for chrome run: npm run test:e2e -- --browsers=chrome firefox-tests: timeout-minutes: 30 name: Run Firefox e2e tests # Runs best on macos for CI as linux requires extra setup runs-on: macos-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: NPM install run: npm install - name: Build run: npm run build - name: Run server run: npm run test:server & - name: Run e2e tests for firefox run: npm run test:e2e -- --browsers=firefox safari-tests: timeout-minutes: 30 name: Run Safari e2e tests # Requires macos runs-on: macos-latest steps: - name: Checkout Code uses: actions/checkout@v6 - name: NPM install run: npm install - name: Build run: npm run build - name: Run server run: npm run test:server & - name: Run e2e tests for safari run: npm run test:e2e -- --browsers=safari
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.
- 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 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.