Skip to content
Latchkey

CI workflow (GoogleChrome/lighthouse)

The CI workflow from GoogleChrome/lighthouse, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, 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/lighthouse.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the CI workflow from the GoogleChrome/lighthouse 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: CI

on:
  push:
    branches: [main]
  pull_request: # run on all PRs, not just PRs to a particular branch

env:
  PUPPETEER_SKIP_DOWNLOAD: 1

jobs:
  # `basics` includes all non-smoke and non-unit CI
  basics:
    runs-on: ubuntu-latest
    env:
      CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
      FORCE_COLOR: true

    # A few steps are duplicated across all jobs. Can be done better when this feature lands:
    #   https://github.community/t/reusing-sharing-inheriting-steps-between-jobs-declarations/16851
    #   https://github.com/actions/runner/issues/438
    steps:
    - name: git clone
      uses: actions/checkout@v4
      with:
        fetch-depth: 100
    - run: bash core/scripts/github-actions-commit-range.sh
      env:
        GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
        GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}

    - name: Use Node.js 22.19
      uses: actions/setup-node@v4
      with:
        node-version: '22.19'

    - run: yarn install --frozen-lockfile --network-timeout 1000000
    - run: yarn type-check
    - run: yarn build-all

    # Since Ubuntu 23, dev builds of Chromium need this.
    # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
    - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

    # Run pptr tests using ToT Chrome instead of stable default.
    - name: Install Chrome ToT
      run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh

    - name: yarn test-clients
      run: bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-clients
    - name: yarn test-docs
      run: yarn test-docs
    - name: yarn test-treemap
      run: bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-treemap

    - run: yarn diff:sample-json
    - run: yarn diff:flow-sample-json
    - run: yarn lint

    - run: yarn test-legacy-javascript
      env:
        # https://github.com/nodejs/node/issues/51555#issuecomment-1974877052
        DISABLE_V8_COMPILE_CACHE: 1
    - run: yarn i18n:checks
    - run: yarn dogfood-lhci
    - run: yarn generate-insight-audits

    # Fail if any changes were written to any source files or generated untracked files (ex, from: build/build-cdt-lib.js).
    - run: git add -A && git diff --cached --exit-code

    # buildtracker needs history and a common merge commit.
    - name: Fixup git history (for buildtracker)
      run: bash $GITHUB_WORKSPACE/.github/scripts/git-get-shared-history.sh
      env:
        # https://buildtracker.dev/docs/guides/github-actions#configuration
        BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}
    - name: Store in buildtracker
      # TODO(paulirish): Don't allow this to fail the build. https://github.com/paularmstrong/build-tracker/issues/200
      run: yarn bt-cli upload-build || true
      env:
        # https://buildtracker.dev/docs/guides/github-actions#configuration
        BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}

    - name: Upload dist
      uses: actions/upload-artifact@v7
      with:
        name: dist
        path: dist/

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: CI
 
on:
  push:
    branches: [main]
  pull_request: # run on all PRs, not just PRs to a particular branch
 
env:
  PUPPETEER_SKIP_DOWNLOAD: 1
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  # `basics` includes all non-smoke and non-unit CI
  basics:
    timeout-minutes: 30
    runs-on: latchkey-small
    env:
      CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
      FORCE_COLOR: true
 
    # A few steps are duplicated across all jobs. Can be done better when this feature lands:
    #   https://github.community/t/reusing-sharing-inheriting-steps-between-jobs-declarations/16851
    #   https://github.com/actions/runner/issues/438
    steps:
    - name: git clone
      uses: actions/checkout@v4
      with:
        fetch-depth: 100
    - run: bash core/scripts/github-actions-commit-range.sh
      env:
        GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
        GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}
 
    - name: Use Node.js 22.19
      uses: actions/setup-node@v4
      with:
        cache: 'npm'
        node-version: '22.19'
 
    - run: yarn install --frozen-lockfile --network-timeout 1000000
    - run: yarn type-check
    - run: yarn build-all
 
    # Since Ubuntu 23, dev builds of Chromium need this.
    # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
    - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
 
    # Run pptr tests using ToT Chrome instead of stable default.
    - name: Install Chrome ToT
      run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh
 
    - name: yarn test-clients
      run: bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-clients
    - name: yarn test-docs
      run: yarn test-docs
    - name: yarn test-treemap
      run: bash $GITHUB_WORKSPACE/.github/scripts/test-retry.sh yarn test-treemap
 
    - run: yarn diff:sample-json
    - run: yarn diff:flow-sample-json
    - run: yarn lint
 
    - run: yarn test-legacy-javascript
      env:
        # https://github.com/nodejs/node/issues/51555#issuecomment-1974877052
        DISABLE_V8_COMPILE_CACHE: 1
    - run: yarn i18n:checks
    - run: yarn dogfood-lhci
    - run: yarn generate-insight-audits
 
    # Fail if any changes were written to any source files or generated untracked files (ex, from: build/build-cdt-lib.js).
    - run: git add -A && git diff --cached --exit-code
 
    # buildtracker needs history and a common merge commit.
    - name: Fixup git history (for buildtracker)
      run: bash $GITHUB_WORKSPACE/.github/scripts/git-get-shared-history.sh
      env:
        # https://buildtracker.dev/docs/guides/github-actions#configuration
        BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}
    - name: Store in buildtracker
      # TODO(paulirish): Don't allow this to fail the build. https://github.com/paularmstrong/build-tracker/issues/200
      run: yarn bt-cli upload-build || true
      env:
        # https://buildtracker.dev/docs/guides/github-actions#configuration
        BT_API_AUTH_TOKEN: ${{ secrets.BT_API_AUTH_TOKEN }}
 
    - name: Upload dist
      uses: actions/upload-artifact@v7
      with:
        name: dist
        path: dist/
 

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

Actions used in this workflow