Continuous Integration for Frontend Projects

Automate type checks, linting, tests, builds and previews on every pull request with GitHub Actions.

Intermediate · about 3 hours · difficulty 3/5

Learn first: End-to-End Testing with Playwright, Linting and Formatting, Deploying Frontend Apps

Continuous integration (CI) runs your quality checks automatically on every push and pull request, so broken code is caught before it merges. For a frontend team it is also where performance, accessibility and bundle-size budgets are enforced.

A typical pipeline

  1. Install with the lockfile (npm ci or pnpm install --frozen-lockfile), with dependency caching for speed.
  2. Type check (tsc --noEmit) and lint (ESLint) and check formatting (Prettier).
  3. Unit and component tests (Vitest) with coverage.
  4. Build the production bundle.
  5. End-to-end tests (Playwright) against the build or a preview deployment, uploading traces on failure.
  6. Optional gates: bundle size limits, Lighthouse CI budgets, axe accessibility checks, visual regression.

GitHub Actions basics

Workflows are YAML files in .github/workflows/: triggers (on: pull_request), jobs that run on hosted runners, steps using actions like actions/checkout and actions/setup-node (pin the Node version), and secrets for tokens. Run independent jobs in parallel and use a matrix for multiple browsers or Node versions.

Team practices

  • Branch protection: require CI to pass and a review before merging to main.
  • Keep CI fast (under about 10 minutes) through caching, parallelism and running only affected checks in monorepos.
  • Treat flaky tests as bugs; quarantine and fix them rather than re-running until green.
  • Use pre-commit hooks (Husky plus lint-staged) for instant local feedback, but never rely on them alone.
  • Continuous deployment: hosting platforms deploy main automatically once CI passes.

Good enough to move on

Your project has a GitHub Actions workflow that type checks, lints, tests, builds and runs E2E tests on every pull request, with branch protection requiring it to pass.

Key concepts

  • What CI is and why it matters
  • GitHub Actions workflows, jobs and steps
  • Caching dependencies
  • Typecheck, lint, test and build stages
  • E2E tests in CI
  • Branch protection and required checks
  • Bundle size and Lighthouse budgets
  • Husky and lint-staged

Mini project

Write a GitHub Actions workflow for your capstone repository with parallel lint/typecheck/test jobs, a build, Playwright E2E against the preview URL, a bundle-size check and branch protection on main.

Check yourself

Why should CI install dependencies with npm ci rather than npm install?

Free resources