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:e2eGotchas
- 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
How to Lint Only Changed Files in a Monorepo With GitHub ActionsLint just the files a PR changed in GitHub Actions by collecting the diff with tj-actions/changed-files and p…
How to Run Per-Package Jobs With dorny/paths-filter in GitHub ActionsGate per-package jobs in a monorepo with dorny/paths-filter, which outputs a boolean per filter so each packa…