Test workflow (berstend/puppeteer-extra)
The Test workflow from berstend/puppeteer-extra, explained and optimized by Latchkey.
CI health: F - at risk
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Test workflow from the berstend/puppeteer-extra 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: Test
on:
pull_request:
branches:
- '*'
types:
- opened
- synchronize
- reopened
push:
branches:
- master
- 'test/*'
workflow_dispatch:
branches:
- '*'
env:
CI: 'true'
FORCE_COLOR: 'true'
jobs:
test:
name: node v${{ matrix.node }}, pptr ${{ matrix.puppeteer_version }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node:
# - 16
- 14
puppeteer_version:
# - 15.5.0
- 14.2.0 # Chromium 103.0.5059.0 # requires >=14.1.0
# - 10.2.0 # Chromium 93.0.4577.0
# - 7.0.0 # Chromium 90.0.4403.0, Feb 3, 2021
# - 5.5.0 # Chromium 88.0.4298.0
# - 5.0.0 # Chromium 83.0.4103.0, Jul 2, 2020
# - 2.1.1 # Chromium 79.0.3942.0, Oct 24 2019
# - 2.0.0 # Chromium 79.0.3942.0, Oct 24 2019
# - 1.20.0 # Chromium 78.0.3882.0, Sep 13 2019
# - 1.15.0 # Chromium 75.0.3765.0, Apr 26 2019
# - 1.9.0 # Chromium 71.0.3563.0, Oct 4, 2018
# - 1.6.2 # Chromium 69.0.3494.0, Aug 1, 2018
os:
- ubuntu-latest
# - macOS-latest
# - windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: 'Fix for: error fsevents@2.1.2: The platform "linux" is incompatible with this module.'
run: npx json -I -f package.json -e 'this.resolutions={}'
- name: yarn install
uses: bahmutov/npm-install@v1
- name: yarn bootstrap
run: yarn bootstrap
- name: install puppeteer@${{ matrix.puppeteer_version }}
run: yarn lerna add --dev puppeteer@${{ matrix.puppeteer_version }}
- name: lerna link
run: yarn lerna link
- name: lerna build
run: yarn lerna run build --concurrency 1
- name: debug
run: |
yarn list --pattern "puppeteer|puppeteer-extra|playwright"
file node_modules/puppeteer-extra/dist/index.cjs.js
- uses: microsoft/playwright-github-action@v1
- name: playwright install
run: cd packages/playwright-extra && yarn playwright install
- name: test
uses: GabrielBB/xvfb-action@v1
env:
DISPLAY: ':99.0'
with:
run: yarn test-ci
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: Test on: pull_request: branches: - '*' types: - opened - synchronize - reopened push: branches: - master - 'test/*' workflow_dispatch: branches: - '*' env: CI: 'true' FORCE_COLOR: 'true' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: timeout-minutes: 30 name: node v${{ matrix.node }}, pptr ${{ matrix.puppeteer_version }}, ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: node: # - 16 - 14 puppeteer_version: # - 15.5.0 - 14.2.0 # Chromium 103.0.5059.0 # requires >=14.1.0 # - 10.2.0 # Chromium 93.0.4577.0 # - 7.0.0 # Chromium 90.0.4403.0, Feb 3, 2021 # - 5.5.0 # Chromium 88.0.4298.0 # - 5.0.0 # Chromium 83.0.4103.0, Jul 2, 2020 # - 2.1.1 # Chromium 79.0.3942.0, Oct 24 2019 # - 2.0.0 # Chromium 79.0.3942.0, Oct 24 2019 # - 1.20.0 # Chromium 78.0.3882.0, Sep 13 2019 # - 1.15.0 # Chromium 75.0.3765.0, Apr 26 2019 # - 1.9.0 # Chromium 71.0.3563.0, Oct 4, 2018 # - 1.6.2 # Chromium 69.0.3494.0, Aug 1, 2018 os: - ubuntu-latest # - macOS-latest # - windows-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Node uses: actions/setup-node@v1 with: cache: 'npm' node-version: ${{ matrix.node }} - name: 'Fix for: error fsevents@2.1.2: The platform "linux" is incompatible with this module.' run: npx json -I -f package.json -e 'this.resolutions={}' - name: yarn install uses: bahmutov/npm-install@v1 - name: yarn bootstrap run: yarn bootstrap - name: install puppeteer@${{ matrix.puppeteer_version }} run: yarn lerna add --dev puppeteer@${{ matrix.puppeteer_version }} - name: lerna link run: yarn lerna link - name: lerna build run: yarn lerna run build --concurrency 1 - name: debug run: | yarn list --pattern "puppeteer|puppeteer-extra|playwright" file node_modules/puppeteer-extra/dist/index.cjs.js - uses: microsoft/playwright-github-action@v1 - name: playwright install run: cd packages/playwright-extra && yarn playwright install - name: test uses: GabrielBB/xvfb-action@v1 env: DISPLAY: ':99.0' with: run: yarn test-ci
What changed
- 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.
3 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
- End-to-end and browser tests
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.