What to run on a PR, on merge and nightly
The more expensive a suite is in time, resources and instability, the less often and the later it runs. A PR gets fast, stable checks (lint, unit, API, e2e on critical paths) as required checks, a merge into main gets a wider suite and a smoke run after the deploy to staging, and the nightly run gets the full regression and quarantined tests. Cheap stages run first (fail-fast).
CI/CD · Pipeline
Full e2e on every commit: a 40-minute wait. What should really block a PR?
A team turns on the full e2e suite for every PR. At first that feels safe. A month later a PR waits 40 minutes, developers start the next task and stop looking at red statuses. Automated tests nobody reads protect nothing. This lesson is about how to spread suites across a PR, a merge and a nightly run.
How it works and why. The main rule: the more expensive a suite is (time, resources, instability), the less often and the later it runs. Every level answers its own question and has its own time budget.
Three run levels
- Pull request: lint and typecheck, unit, API and contract tests, the build, e2e only on critical paths (login, the main product action). These are required checks: no merge without a green status.
- Merge to main: a wider suite and a deploy to staging with a smoke run after it. A failure here means the PR suite missed something and should be extended.
- Nightly on a schedule: the full regression, all browsers, visual and performance checks, a run of quarantined tests. The result is a report and a notification, not a merge block.
- Manual run (
workflow_dispatch): repeat a long suite on any branch or environment.
Stages in a run follow fail-fast: cheap checks (lint, unit) go first, slow e2e after them through needs. A failure that lint could catch in a minute should not wait for a browser. Independent jobs (for example API tests and the build) run in parallel.
Example: one file for three levels. Triggers decide what runs, and an if on a job keeps the expensive suite away from PRs:
name: ci
on:
pull_request:
push:
branches: [main]
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
fast:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: 22, cache: npm }
- run: npm ci
- run: npm run lint && npm run typecheck
- run: npm test
smoke:
needs: fast
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: 22, cache: npm }
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npx playwright test --grep @smoke
full:
if: github.event_name != 'pull_request'
needs: fast
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: 22, cache: npm }
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test
smoke is filtered by an @smoke tag in the test title (--grep @smoke), so the "critical path" is a team agreement, not separate code. What blocks the merge: on a PR only fast and smoke are required, and full is skipped on a PR (status skipped). Playwright's own CI config, sharding and Docker are in the lesson “CI: sharding, Docker and fast reruns”.
A quality gate is the set of conditions code must meet to move on: all required checks green, no new critical defects, coverage of new code above a threshold, no flaky tests in the blocking suite. The fewer conditions rest on someone's word, the better: every condition is checked automatically. Required checks are set in branch protection or rulesets by job name.
What blocks a PR
Everything on every PR
Full e2e, all browsers and visual tests. Time grows, a flaky test blocks other people's changes, people stop looking at statuses.
A fast core on PR, the rest later
On a PR only what catches a critical-path break within minutes. The full regression on main and nightly, with a report.
Limits and alternatives. If a workflow is skipped because of a path or branch filter, its required check stays Pending and the merge is blocked. A job skipped through if counts as successful. So either filter at job level, or add a summary job and make it the only required one. For a small project three levels are overkill: one run per PR plus a nightly is enough.
Typical mistakes.
- A full regression on every commit: feedback is slow and developers work around it.
- A nightly suite with no owner: it stays red for weeks and nobody reacts.
- A required check whose name no longer exists after a job rename: the PR hangs in Pending.
- Gate conditions rest on someone's word instead of automatic checks.
- A deploy to staging with no smoke run after it: a broken environment is found later.
Check yourself
Why did a PR stop being mergeable after a job was renamed in the workflow, although every run is green?
Answer
A required check in branch protection is bound to the job name. Nobody reports the old name any more, so the status stays pending. The fix: update the required checks to the new name, or use a summary job with a stable name.
What should stay in the PR suite and what should move to nightly?
Answer
Keep the fast and stable on the PR: lint, unit, API, the build and e2e of critical paths. Move the slow and wide to nightly: all browsers, visual tests, long flows, performance, quarantine. The criteria are time, stability and risk of breakage.