Skip to content
Latchkey

How to Skip Unaffected End-to-End Tests in a Monorepo With GitHub Actions

Gate each e2e suite on whether its app changed, so unrelated PRs do not pay for a full browser run.

Detect affected apps (via dorny/paths-filter or nx affected), then run an app e2e job only when that app is affected.

Steps

  • Compute affected apps in a detect job.
  • Gate the e2e job with if: on the relevant output.
  • Provide a passing placeholder so a skipped required check does not block merges.

Workflow

.github/workflows/ci.yml
jobs:
  detect:
    runs-on: ubuntu-latest
    outputs:
      web: ${{ steps.f.outputs.web }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: f
        with:
          filters: |
            web: ['apps/web/**', 'packages/ui/**']
  e2e-web:
    needs: detect
    if: needs.detect.outputs.web == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pnpm --filter web test:e2e

Gotchas

  • Include shared UI packages in each app filter, or a shared change skips e2e that should run.
  • A skipped job counts as success in needs; assert status explicitly if it matters.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →