Backstop Sanity Docker workflow (garris/BackstopJS)
The Backstop Sanity Docker workflow from garris/BackstopJS, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Backstop Sanity Docker workflow from the garris/BackstopJS 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: Backstop Sanity Docker
on:
workflow_dispatch:
workflow_call:
permissions:
actions: write
checks: write
contents: write
pull-requests: write
packages: write
env:
NODE_VERSION: 20
# BRANCH_NAME: ${{ github.event.pull_request.head_ref || github.event.pull_request.head.ref_name || github.head_ref || github.ref_name }}
# REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
jobs:
sanity-puppeteer-docker:
name: 🤪 Puppeteer-On-Docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
run:
echo "USERNAME=${secrets.DOCKERHUB_USERNAME}" >>${GITHUB_ENV}
echo "USERNAME=${secrets.DOCKERHUB_TOKEN}" >>${GITHUB_ENV}
- name: Set Name and Tag Vars
env:
name: "${{ env.BRANCH_NAME }}"
run: |
echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV}
echo "TAG=${name/\//-}" >> $GITHUB_ENV
echo "PV=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
echo "PLAYWRIGHT_VERSION=$(cat package.json | jq -r '.dependencies.playwright')" >> $GITHUB_ENV
- name: ⬢ Setup Node & Cache
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: package-lock.json
- name: ↧ Install
run: npm ci
- name: "𓋏 Run `npm run sanity-test-docker`"
run: |
npm run sanity-test-docker
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Backstop Sanity Docker on: workflow_dispatch: workflow_call: permissions: actions: write checks: write contents: write pull-requests: write packages: write env: NODE_VERSION: 20 # BRANCH_NAME: ${{ github.event.pull_request.head_ref || github.event.pull_request.head.ref_name || github.head_ref || github.ref_name }} # REGISTRY: ghcr.io # IMAGE_NAME: ${{ github.repository }} jobs: sanity-puppeteer-docker: timeout-minutes: 30 name: 🤪 Puppeteer-On-Docker runs-on: latchkey-small permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 ref: ${{ github.event.pull_request.head.sha || github.ref }} - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} run: echo "USERNAME=${secrets.DOCKERHUB_USERNAME}" >>${GITHUB_ENV} echo "USERNAME=${secrets.DOCKERHUB_TOKEN}" >>${GITHUB_ENV} - name: Set Name and Tag Vars env: name: "${{ env.BRANCH_NAME }}" run: | echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV} echo "TAG=${name/\//-}" >> $GITHUB_ENV echo "PV=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV echo "PLAYWRIGHT_VERSION=$(cat package.json | jq -r '.dependencies.playwright')" >> $GITHUB_ENV - name: ⬢ Setup Node & Cache uses: actions/setup-node@v4 with: cache: "npm" cache-dependency-path: package-lock.json - name: ↧ Install run: npm ci - name: "𓋏 Run `npm run sanity-test-docker`" run: | npm run sanity-test-docker
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. - Add a job timeout so a hung step cannot burn hours of runner time.
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:
- 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.