Skip to content
Latchkey

Run tests workflow (GoogleChrome/web-vitals)

The Run tests workflow from GoogleChrome/web-vitals, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: GoogleChrome/web-vitals.github/workflows/tests.ymlLicense Apache-2.0View source

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

workflow (.yml)
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

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 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow