E2E Tests workflow (evidence-dev/evidence)
The E2E Tests workflow from evidence-dev/evidence, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get run de-duplication, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the E2E Tests workflow from the evidence-dev/evidence 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: E2E Tests
on:
pull_request:
branches: [main]
jobs:
run-tests:
name: e2e/ubuntu-latest/node-20
runs-on: ubuntu-latest
timeout-minutes: 60
# Skip E2E on Version Packages PRs - they're just metadata changes
if: github.event.pull_request.user.login != 'github-actions[bot]'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Check what changed
id: changes-check
shell: bash
run: |
# Fetch the base branch
git fetch origin ${{ github.event.pull_request.base.ref }}
# Get list of changed files
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }})
# Check if only docs changed
NON_DOCS_CHANGES=$(echo "$CHANGED_FILES" | grep -vE '^sites/docs/' || true)
if [ -z "$NON_DOCS_CHANGES" ]; then
echo "only_docs=true" >> "$GITHUB_OUTPUT"
echo "Skipping e2e tests because only docs were changed."
exit 0
fi
echo "only_docs=false" >> "$GITHUB_OUTPUT"
# Check if external dependencies changed (lockfile = external deps)
LOCKFILE_CHANGED=$(echo "$CHANGED_FILES" | grep -E '^pnpm-lock\.yaml$' || true)
if [ -n "$LOCKFILE_CHANGED" ]; then
echo "run_full_suite=true" >> "$GITHUB_OUTPUT"
echo "Running FULL e2e suite because external dependencies changed (pnpm-lock.yaml modified)"
else
echo "run_full_suite=false" >> "$GITHUB_OUTPUT"
echo "Running MINIMAL e2e suite (basic + hmr only)"
fi
- name: Action Setup (pnpm)
if: steps.changes-check.outputs.only_docs != 'true'
uses: pnpm/action-setup@v4
- name: Setup Node
if: steps.changes-check.outputs.only_docs != 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
if: steps.changes-check.outputs.only_docs != 'true'
run: pnpm install --frozen-lockfile
- name: Install Playwright and browsers
if: steps.changes-check.outputs.only_docs != 'true'
run: pnpm playwright install --with-deps
- name: Run setup
if: steps.changes-check.outputs.only_docs != 'true'
run: pnpm --filter "./e2e/*" run --if-present setup
- name: Run sources (minimal)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true'
run: pnpm --filter "./e2e/{basic,hmr}" run sources
- name: Run sources (full)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true'
run: pnpm --filter "./e2e/*" run sources
- name: Run dev mode tests (minimal)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true'
run: pnpm --filter "./e2e/{basic,hmr}" --sequential run test:dev
- name: Run dev mode tests (full)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true'
run: pnpm --filter "./e2e/*" --sequential run test:dev
- name: Build (minimal)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true'
run: pnpm --filter "./e2e/{basic,hmr}" run build
- name: Build (full)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true'
run: pnpm --filter "./e2e/*" run build
- name: Run preview mode tests (minimal)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true'
run: pnpm --filter "./e2e/{basic,hmr}" --sequential run test:preview
- name: Run preview mode tests (full)
if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true'
run: pnpm --filter "./e2e/*" --sequential run test:preview
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: E2E Tests on: pull_request: branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: run-tests: name: e2e/ubuntu-latest/node-20 runs-on: latchkey-small timeout-minutes: 60 # Skip E2E on Version Packages PRs - they're just metadata changes if: github.event.pull_request.user.login != 'github-actions[bot]' steps: - name: Checkout Repo uses: actions/checkout@v4 - name: Check what changed id: changes-check shell: bash run: | # Fetch the base branch git fetch origin ${{ github.event.pull_request.base.ref }} # Get list of changed files CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}) # Check if only docs changed NON_DOCS_CHANGES=$(echo "$CHANGED_FILES" | grep -vE '^sites/docs/' || true) if [ -z "$NON_DOCS_CHANGES" ]; then echo "only_docs=true" >> "$GITHUB_OUTPUT" echo "Skipping e2e tests because only docs were changed." exit 0 fi echo "only_docs=false" >> "$GITHUB_OUTPUT" # Check if external dependencies changed (lockfile = external deps) LOCKFILE_CHANGED=$(echo "$CHANGED_FILES" | grep -E '^pnpm-lock\.yaml$' || true) if [ -n "$LOCKFILE_CHANGED" ]; then echo "run_full_suite=true" >> "$GITHUB_OUTPUT" echo "Running FULL e2e suite because external dependencies changed (pnpm-lock.yaml modified)" else echo "run_full_suite=false" >> "$GITHUB_OUTPUT" echo "Running MINIMAL e2e suite (basic + hmr only)" fi - name: Action Setup (pnpm) if: steps.changes-check.outputs.only_docs != 'true' uses: pnpm/action-setup@v4 - name: Setup Node if: steps.changes-check.outputs.only_docs != 'true' uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Install dependencies if: steps.changes-check.outputs.only_docs != 'true' run: pnpm install --frozen-lockfile - name: Install Playwright and browsers if: steps.changes-check.outputs.only_docs != 'true' run: pnpm playwright install --with-deps - name: Run setup if: steps.changes-check.outputs.only_docs != 'true' run: pnpm --filter "./e2e/*" run --if-present setup - name: Run sources (minimal) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true' run: pnpm --filter "./e2e/{basic,hmr}" run sources - name: Run sources (full) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true' run: pnpm --filter "./e2e/*" run sources - name: Run dev mode tests (minimal) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true' run: pnpm --filter "./e2e/{basic,hmr}" --sequential run test:dev - name: Run dev mode tests (full) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true' run: pnpm --filter "./e2e/*" --sequential run test:dev - name: Build (minimal) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true' run: pnpm --filter "./e2e/{basic,hmr}" run build - name: Build (full) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true' run: pnpm --filter "./e2e/*" run build - name: Run preview mode tests (minimal) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite != 'true' run: pnpm --filter "./e2e/{basic,hmr}" --sequential run test:preview - name: Run preview mode tests (full) if: steps.changes-check.outputs.only_docs != 'true' && steps.changes-check.outputs.run_full_suite == 'true' run: pnpm --filter "./e2e/*" --sequential run test:preview
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. - Cancel superseded runs when a branch or PR gets a newer push.
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.