Skip to content
Latchkey

Playwright Tests workflow (jupyterhub/binderhub)

The Playwright Tests workflow from jupyterhub/binderhub, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: jupyterhub/binderhub.github/workflows/playwright.yamlLicense BSD-3-ClauseView source

What it does

This is the Playwright Tests workflow from the jupyterhub/binderhub repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Playwright Tests

on:
  pull_request:
    paths-ignore:
      - "**.md"
      - "**.rst"
      - "docs/**"
      - "examples/**"
      - ".github/workflows/**"
      - "!.github/workflows/playwright.yaml"
  push:
    paths-ignore:
      - "**.md"
      - "**.rst"
      - "docs/**"
      - "examples/**"
      - ".github/workflows/**"
      - "!.github/workflows/playwright.yaml"
    branches-ignore:
      - "dependabot/**"
      - "pre-commit-ci-update-config"
      - "update-*"
  workflow_dispatch:

jobs:
  tests:
    runs-on: ubuntu-22.04
    timeout-minutes: 10

    permissions:
      contents: read
    env:
      GITHUB_ACCESS_TOKEN: "${{ secrets.github_token }}"

    steps:
      - uses: actions/checkout@v7

      - name: Setup OS level dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --yes \
            build-essential \
            curl \
            libcurl4-openssl-dev \
            libssl-dev

      - uses: actions/setup-node@v6
        id: setup-node
        with:
          node-version: "22"

      - name: Cache npm
        uses: actions/cache@v5
        with:
          path: ~/.npm
          key: node-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('**/package.json') }}-${{ github.job }}

      - name: Run webpack to build static assets
        run: |
          npm install
          npm run webpack

      - uses: actions/setup-python@v6
        id: setup-python
        with:
          python-version: "3.12"

      - name: Cache pip
        uses: actions/cache@v5
        with:
          path: ~/.cache/pip
          key: python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/*requirements.txt') }}-${{ github.job }}

      - name: Setup test dependencies
        run: |
          npm i -g configurable-http-proxy

          pip install --no-binary pycurl -r dev-requirements.txt
          pip install -e .

      - name: Install playwright browser
        run: |
          playwright install firefox

      - name: Run playwright tests
        run: |
          py.test --cov=binderhub -s integration-tests/

      - uses: actions/upload-artifact@v7
        if: always()
        with:
          name: playwright-traces
          path: test-results/

      # Upload test coverage info to codecov
      - uses: codecov/codecov-action@v7

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: Playwright Tests
 
on:
  pull_request:
    paths-ignore:
      - "**.md"
      - "**.rst"
      - "docs/**"
      - "examples/**"
      - ".github/workflows/**"
      - "!.github/workflows/playwright.yaml"
  push:
    paths-ignore:
      - "**.md"
      - "**.rst"
      - "docs/**"
      - "examples/**"
      - ".github/workflows/**"
      - "!.github/workflows/playwright.yaml"
    branches-ignore:
      - "dependabot/**"
      - "pre-commit-ci-update-config"
      - "update-*"
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    runs-on: latchkey-small
    timeout-minutes: 10
 
    permissions:
      contents: read
    env:
      GITHUB_ACCESS_TOKEN: "${{ secrets.github_token }}"
 
    steps:
      - uses: actions/checkout@v7
 
      - name: Setup OS level dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --yes \
            build-essential \
            curl \
            libcurl4-openssl-dev \
            libssl-dev
 
      - uses: actions/setup-node@v6
        id: setup-node
        with:
          cache: 'npm'
          node-version: "22"
 
      - name: Cache npm
        uses: actions/cache@v5
        with:
          path: ~/.npm
          key: node-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('**/package.json') }}-${{ github.job }}
 
      - name: Run webpack to build static assets
        run: |
          npm install
          npm run webpack
 
      - uses: actions/setup-python@v6
        id: setup-python
        with:
          python-version: "3.12"
 
      - name: Cache pip
        uses: actions/cache@v5
        with:
          path: ~/.cache/pip
          key: python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/*requirements.txt') }}-${{ github.job }}
 
      - name: Setup test dependencies
        run: |
          npm i -g configurable-http-proxy
 
          pip install --no-binary pycurl -r dev-requirements.txt
          pip install -e .
 
      - name: Install playwright browser
        run: |
          playwright install firefox
 
      - name: Run playwright tests
        run: |
          py.test --cov=binderhub -s integration-tests/
 
      - uses: actions/upload-artifact@v7
        if: always()
        with:
          name: playwright-traces
          path: test-results/
 
      # Upload test coverage info to codecov
      - uses: codecov/codecov-action@v7
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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:

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