Skip to content
FrontHeaven
Light mode
Level 3 — AdvancedAdvanced 50 min read

CI/CD Pipelines, Budgets & Release Automation

Master enterprise CI/CD for Angular: GitHub Actions workflows, automated linting and type checking, unit and E2E pipelines, bundle size budgets, preview deployments, and canary releases.

Angular progress0%

CI/CD Pipelines, Budgets & Release Automation

A robust Continuous Integration and Continuous Deployment (CI/CD) pipeline is the lifeblood of high-velocity engineering teams. CI/CD automates quality gates—verifying TypeScript compilation, running lint rules, executing unit and E2E test suites, asserting bundle budgets, and deploying preview environments—before any code is merged into the production trunk.

text
┌─────────────────────────────────────────────────────────────┐
│                 Enterprise Angular CI/CD Pipeline           │
│                                                             │
│  1. Pull Request Opened (feature/checkout-flow)             │
│             │                                               │
│             ▼                                               │
│  2. Fast Quality Gate (Parallel Jobs in GitHub Actions)     │
│     ├── Job A: Linting (ESLint + Prettier)                  │
│     ├── Job B: Type-Check (tsc --noEmit)                    │
│     ├── Job C: Unit Tests with Coverage (Vitest / Karma)    │
│     └── Job D: Production Build & Budget Check (ng build)   │
│             │                                               │
│             ▼                                               │
│  3. E2E Matrix Tests (Playwright in Chromium/WebKit)        │
│             │                                               │
│             ▼                                               │
│  4. Ephemeral Preview Deployment (Vercel / Cloudflare)      │
│             │                                               │
│             ▼                                               │
│  5. Merge to Main -> Blue/Green Production Deployment       │
└─────────────────────────────────────────────────────────────┘

1. Production GitHub Actions Pipeline Configuration

Create .github/workflows/ci.yml:

yaml
name: Enterprise Angular CI Pipeline

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Source Code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'npm'

      - name: Install Dependencies
        run: npm ci

      - name: Verify TypeScript Compilation
        run: npx tsc --noEmit

      - name: Execute Linter
        run: npm run lint

      - name: Execute Unit Test Suite
        run: npm run test -- --watch=false --browsers=ChromeHeadless

      - name: Execute Production Build
        run: npm run build -- --configuration=production

  e2e:
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'npm'
      - run: npm ci
      - name: Install Playwright Browsers
        run: npx playwright install --with-deps
      - name: Execute E2E Tests
        run: npx playwright test

2. Zero-Downtime Blue/Green & Canary Deployments

  • Blue/Green Deployment: Two identical production environments exist. Traffic is instantly routed from Blue to Green upon successful health verification.
  • Canary Release: Directs 5% of real user traffic to the new version initially; monitors error rates via Sentry for 30 minutes before rolling out to 100% of users.

Summary & Key Takeaways

  • CI/CD pipelines automate linting, type-checking, unit tests, and production builds on every Pull Request.
  • Performance budgets in angular.json fail CI builds automatically if JavaScript bundle sizes exceed thresholds.
  • Playwright E2E tests validate complete user journeys across headless browser engines.
  • Blue/Green and Canary deployment strategies ensure zero-downtime releases and rapid rollback capabilities.

Best Practices & Senior Guidance

  1. Never Skip npm ci: Use npm ci (clean install) in CI runners instead of npm install to guarantee deterministic dependency resolution from package-lock.json.
  2. Parallelize CI Jobs: Split linting, unit tests, and build checks into parallel GitHub Actions jobs to keep PR verification times under 5 minutes.

Finished studying? Lock it in.

Mark this lesson as completed to track your journey.