salekin.dev
ls ..engineering notes
CI/CD · 11 min read

Playwright Quality Gates That Actually Block a Release

A CI pipeline that goes green is not the same as a pipeline that protects you. How I turned a Playwright suite into real release gates — and what it took to reach zero rollbacks.

A green build that protected nothing

The pipeline I inherited reported green on every merge. The badge was green, the deploy went out, and the release still went wrong — three times in one quarter. Nothing in the pipeline had failed, which is exactly the problem: the pipeline had no opinion.

The tests were not few. There were several hundred of them and they mostly passed. But "mostly passed" is not a gate. A pipeline that cannot say no is a report, not a gate, and the distinction matters more than the number of tests.

This is the article about turning that pipeline into something that can actually block a release, and the two things that had to change before it could.

  • The suite passed, but nothing was allowed to fail on it — there was no branch protection on the check
  • Tests ran on every push to every branch, including draft branches, so the signal was diluted
  • A failure cost a developer the full CI duration before they saw it
  • The suite ran in one browser on one platform, so "green" meant very little

Gate one: a failure must be able to block the merge

Before anything else, the check had to be attached to a rule that actually stops a merge. That is a repository setting, not a test, and it is where most pipelines fail silently — the suite is green enough, but nothing requires it.

The rule I wanted was specific: the Playwright check must pass before the pull request can be merged, and it must not be skippable by a maintainer clicking through. That last part is the uncomfortable bit. A gate that a maintainer can override is fine for a hotfix at 2am; it is not a gate for the other ninety-nine merges a week.

  • The check runs on pull requests to `main` only — not on every push to every branch
  • `fail-fast: false` so one browser failing does not cancel the other; you want the full matrix
  • A hard `timeout-minutes` on the job, so a hung test run cannot sit in a queue for an hour
  • The reporter writes the triage summary, and the Slack step posts the link to the run
yaml.github/workflows/e2e.yml
name: e2e

on:
  pull_request:
    branches: [main]

jobs:
  e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    strategy:
      fail-fast: false
      matrix:
        browser: [chromium, firefox]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps ${matrix.browser}
      - run: npx playwright test --project=${matrix.browser}
      - uses: slackapi/slack-github-action@v1
        if: failure()
        with:
          payload: |
            {
              "text": "E2E failed on ${matrix.browser}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
            }

Gate two: the suite has to be trustworthy before it can block anything

The second gate is less obvious, and it is the one that took longer. A blocking gate that is flaky is worse than no gate at all, because the team learns that red means "retry", and then the red genuinely stops meaning anything.

So before the suite was allowed to block, it had to become boring. Not fast — reliable is a different property from fast, and confusing the two is how teams end up with a gate that is quick and useless.

The work was mostly not in the tests. It was in three places: making failures deterministic, making the suite able to run in parallel without interfering with itself, and giving each failure a classification so a human could tell a product bug from an environment problem in one glance.

  • Flaky tests were fixed or deleted, never retried into green — a quarantined test is a bug with extra steps
  • Each test provisions its own data; no test depends on another having run first
  • Timeouts were explicit per test, not a global default applied to every assertion
  • Failures were classified into categories so a signal failure could be dismissed without reading the log

Making the gate fast enough to keep

A blocking gate has to return its verdict quickly. A twenty-minute wait is a twenty-minute wait in which a developer is blocked, and a blocked developer is a developer who starts merging around the gate rather than through it.

The single biggest win was not raw speed — it was running the suite in parallel shards, and splitting the run so the fast, high-signal tests finished first and reported immediately, while the slower end-to-end paths continued in the background.

That split gives two verdicts instead of one. A quick gate that blocks the obvious breakage, and a slower gate that blocks the subtler breakage. The quick one has to be trustworthy enough to block on its own, which is why it is a curated subset rather than a random sample.

yaml.github/workflows/e2e.yml (sharded)
jobs:
  smoke:
    # The quick gate. Runs the curated fast subset on every PR and
    # blocks the merge on its own.
    runs-on: ubuntu-latest
    timeout-minutes: 8
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx playwright test --project=chromium --grep @smoke

  e2e:
    # The slow gate. Sharded so each shard is a few minutes.
    needs: smoke
    runs-on: ubuntu-latest
    timeout-minutes: 25
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx playwright test --project=chromium --shard=${{ matrix.shard }}/4

The part nobody expects: what the gate does about its own failures

The gate will eventually be wrong. An environment will break, a dependency will be flaky in a way you did not predict, and the pipeline will block a merge that should have gone through. When that happens, the correct response is a documented, fast, visible escape hatch — not a silent retry.

I settled on a two-layer model. The normal path is a hard block. The escape path is an explicit, audited override: a label on the pull request that a maintainer applies, which re-runs the job against a quarantined path and posts a comment saying who bypassed what and why.

The important property is that the escape hatch is loud. It appears in the pull request, it leaves a trail, and the metric I actually watch is not the pass rate — it is the *override* rate. An override rate that climbs tells you the gate is miscalibrated, and that is a signal worth more than a perfect green pipeline.

  • Never a silent retry — a retry turns a real signal into a coin flip
  • The override is a labelled, commented, attributable action, not a button
  • Track override rate alongside pass rate; it measures whether the gate fits the team
  • A failing gate is a signal to fix the gate, not a reason to delete the gate

What zero rollbacks actually required

The outcome of this work was not a faster pipeline. It was three releases in a row with no rollback, and — more usefully — a pipeline that had opinions.

The thing that changed most was cultural rather than technical. Once red meant something, people stopped shipping on a "probably fine" judgement, and started asking the pipeline instead. That is the actual return on a quality gate: not the blocked merges, but the merges that stopped happening by assumption.

If you are starting from a green-but-useless pipeline, the order I would use is: attach the check to a real branch rule, fix the flakiness, split the suite into a fast gate and a slow gate, and only then add the override escape hatch. Doing the override first trains everyone that red is negotiable, and that is a habit you cannot unlearn cheaply.

Key Takeaways

  • A check that nothing depends on is a report, not a gate — branch protection is the part that actually blocks.
  • Fix flakiness before you let a suite block, or the team learns that red means retry.
  • Split the suite: a fast curated gate for immediate signal, a slow sharded gate for the deep paths.
  • A timeout on the job is not a nicety; a hung run otherwise burns the whole CI budget.
  • Make the override loud and attributable, and track the override rate — it tells you if the gate fits.
  • Zero rollbacks came from the team asking the pipeline instead of shipping on assumption.
Next articleAPI Contract Testing and k6 Load Testing in One Pipeline