Senior & Lead Track · Chapter 7 of 15

CI/CD and quality gates

A lead's influence on quality is mostly systemic: the pipeline decides what's easy, what's blocked, and how quickly mistakes are caught. A good front end pipeline makes the right thing the default and keeps feedback fast enough that people don't route around it.

Goals of the pipeline

  1. Fast feedback: most PR checks finish in under 10 minutes.
  2. Meaningful gates: each check catches a real class of defect, with low flakiness.
  3. Safe, frequent releases: deploy many times a day with low change-failure rate.
  4. Easy recovery: rollback in minutes.

A reference pipeline

StageChecksTarget timeBlocking?
StaticESLint (incl. hooks, a11y, import boundaries), TypeScript tsc --noEmit, Prettier/Biome check< 2 minYes
Unit/componentVitest/Jest + RTL, affected packages only< 5 minYes
BuildProduction build; bundle-size budgets (size-limit); dependency audit< 5 minYes (budgets with exception process)
PreviewPer-PR deployment URL< 5 min—
Post-previewPlaywright smoke tests; axe checks; Lighthouse CI on key routes; visual regression< 10 minSmoke + axe yes; Lighthouse/visual as required reviews
MainFull E2E suite, deploy to production (dark), progressive rolloutContinuousAuto-halt on guardrails

Making it fast

TechniqueEffect
Affected-only builds and tests (Nx, Turborepo, custom git diff)Avoids testing unchanged packages
Remote caching of task outputsSkips work already done elsewhere
Parallelization / sharding of test suitesLinear speedups on E2E and large unit suites
Fast tools (Vite/Vitest, SWC/esbuild, Biome, Rspack/Turbopack)2–10× faster than older toolchains in many codebases
Dependency caching (pnpm store)Cuts install time
Running cheap checks firstFails fast

Measure CI time (p50/p95) as a first-class metric. When p95 creeps above 15 minutes, developers start batching changes, which hurts quality.

Quality gates that matter

Static analysis

  • eslint-plugin-react-hooks (now includes React Compiler-related rules), jsx-a11y, import boundary rules.
  • TypeScript strict mode for new packages; track any and @ts-expect-error counts.
  • Ban risky APIs with lint rules (dangerouslySetInnerHTML without sanitizer, direct localStorage token storage).

Tests

  • Integration-heavy test suite for components (see Testing React chapter).
  • Coverage reported for visibility; gate on changed lines (e.g. ≥ 80% on diff) rather than a global percentage that punishes legacy.

Bundle and performance

  • size-limit or bundler stats with budgets per entry/route.
  • Lighthouse CI on 3–5 key routes with assertions on TBT, LCP, CLS.

Accessibility

  • axe-core in component tests and Playwright (@axe-core/playwright). Block on new serious/critical violations.
  • Automated checks catch only a portion of issues, so pair them with manual audits.

Visual regression

  • Chromatic (Storybook) or Playwright screenshots for design-system components and key pages.
  • Changes require explicit approval, ideally by a designer for DS components.

Security and supply chain

  • Dependency vulnerability scanning (npm audit, Dependabot/Renovate, Snyk, Socket).
  • Lockfile enforcement; block install scripts from untrusted packages where tooling allows.
  • Secret scanning; no secrets in client bundles (env var allowlists like VITE_/NEXT_PUBLIC_ reviewed).

Flaky tests policy

Flaky tests destroy trust in the pipeline. A clear policy:

  1. Auto-detect flakes (retry-pass patterns) and quarantine them within 24 hours (still run, not blocking).
  2. Create a ticket assigned to the owning team with an SLA (e.g. one week).
  3. Track flake rate per suite. Target < 1% of runs.
  4. Delete tests that can't be stabilized and replace them with lower-level coverage.

Branching and release strategy

StrategyDescriptionFits
Trunk-based developmentSmall PRs merged to main daily; flags hide incomplete workMost product teams; highest DORA performance
GitHub flowShort-lived feature branches; deploy from mainSmall teams
Release branchesStabilize releases on branchesMobile/desktop apps, regulated releases, on-prem software
Long-lived feature branchesWeeks-long branchesAvoid: merge pain, integration risk

For web front ends, trunk-based development + feature flags + continuous deployment is the standard to aim for.

Preview environments

Per-PR preview URLs (Vercel, Netlify, Cloudflare Pages, or custom) transform collaboration:

  • Product and design review real behavior before merge.
  • E2E and Lighthouse run against a real deployment.
  • Use mock or seeded back-end data, or point to a shared staging API with clear data isolation.

Release safety

  • Hashed immutable assets + short-cached HTML → instant rollback by repointing.
  • Feature flags with ownership and expiry dates (stale flags are tech debt; lint for flags older than 90 days).
  • Progressive rollout with automated guardrails (error rate, vitals, key journey success).
  • Version skew handling: keep old chunks available; reload prompts on chunk load failures.

Measuring delivery: DORA metrics

MetricDefinitionElite benchmark (approx.)
Deployment frequencyHow often you deploy to productionOn demand / multiple per day
Lead time for changesCommit to production< 1 day
Change failure rate% of deploys causing incidents or rollbacksLow (often cited ~0–15%)
Failed deployment recovery timeTime to restore after a failed deploy< 1 hour

DORA's research also emphasizes reliability as a fifth dimension. Add front end specifics: CI p95 duration, flake rate, PR review turnaround, and preview environment usage.

Rolling out pipeline changes as a lead

  • Introduce new gates as warnings first for 2–4 weeks, publish the violation counts, then make them blocking.
  • Fix the existing violations yourself (or with codemods) before blocking, so teams don't inherit a wall of red.
  • Explain the why in an ADR and team demo.
  • Provide an escape hatch with accountability (labelled override + follow-up ticket), audited monthly.

Sample ADR: "Block merges on new axe violations"

  • Context: 42 a11y bugs reported last quarter; 70% detectable by automated checks.
  • Decision: Run @axe-core/playwright on smoke routes; block on new serious/critical violations; existing ones baselined.
  • Consequences: +90 s CI time; a11y regressions caught pre-merge; baseline burn-down tracked weekly.
  • Review trigger: if false positives exceed 5% of blocks in a month.

Interview framing

"Our CI took 35 minutes and was flaky, so people batched huge PRs. I moved us to pnpm and Turborepo with remote caching and affected-only tests, sharded Playwright, and quarantined 23 flaky tests with owners. p95 CI dropped to 9 minutes, and median PR size fell by 40%. Then we added bundle budgets and axe checks, warnings for a month, then blocking. Deploy frequency went from twice a week to eight times a day, with change failure rate flat at about 4%."

Spotted a mistake or a rights concern? Report an issue