CAIRL CI/CD Pipeline

Overview

┌─────────────────────────────────────────────────────────┐
│ LOCAL: Feature Branch                                   │
│ • Docker PostgreSQL (isolated)                          │
│ • Unit tests before commit                              │
└────────────────────────┬────────────────────────────────┘
                         │ PR to develop
                         ▼
┌─────────────────────────────────────────────────────────┐
│ CI: PR Quality Gate                                     │
│ • Lint                                                  │
│ • TypeScript check                                      │
│ • Unit tests                                            │
└────────────────────────┬────────────────────────────────┘
                         │ Merge
                         ▼
┌─────────────────────────────────────────────────────────┐
│ CI: develop branch                                      │
│ • Integration tests (cairl-dev DB)                      │
│ • Auto-rebase open PRs                                  │
│ • Auto-create PR to staging                             │
└────────────────────────┬────────────────────────────────┘
                         │ Merge
                         ▼
┌─────────────────────────────────────────────────────────┐
│ CI: staging branch                                      │
│ • Deploy to staging.cairl.app                           │
│ • E2E tests (Playwright)                                │
│ • Human UAT                                             │
└────────────────────────┬────────────────────────────────┘
                         │ Approve + Merge
                         ▼
┌─────────────────────────────────────────────────────────┐
│ PRODUCTION: main branch                                 │
│ • Deploy to cairl.app                                   │
│ • Smoke tests                                           │
└─────────────────────────────────────────────────────────┘

Workflow Files

File Trigger Purpose
.github/workflows/pr-quality.yml PR to develop Quality gate
.github/workflows/auto-rebase.yml Push to develop Keep PRs fresh
.github/workflows/integration-tests.yml Push to develop Test + promote
.github/workflows/e2e-tests.yml Push to staging E2E + notify

Required Secrets

Secret Where to Set Purpose
DEV_DATABASE_URL GitHub Secrets Integration tests

Debugging Failed Workflows

PR Quality Failed

  1. Click "Details" on failed check
  2. Look at which step failed (lint/types/tests)
  3. Fix locally, push again

Integration Tests Failed

  1. Check GitHub Actions log
  2. Look for database connection errors or test failures
  3. May need to run db:push against cairl-dev

E2E Tests Failed

  1. Download playwright-report artifact
  2. Open index.html to see screenshots
  3. Check if Vercel deployment succeeded

Auto-Rebase Failed

  1. PR has merge conflicts
  2. Manually rebase: git fetch origin && git rebase origin/develop
  3. Resolve conflicts, force push

Environment Matrix

Branch Database URL Tests
feature/* Docker local localhost:3000 Unit (local)
develop cairl-dev dev.cairl.app Integration (CI)
staging cairl-staging staging.cairl.app E2E (CI) + UAT
main cairl-production cairl.app Smoke

Local Development Commands

# Database
npm run db:local:start   # Start Docker PostgreSQL
npm run db:local:stop    # Stop Docker PostgreSQL
npm run db:local:reset   # Nuke and recreate local DB
npm run db:push          # Apply schema to current DATABASE_URL

# Testing
npm run test:unit        # Unit tests (mocked DB)
npm run test:integration # Integration tests (real DB)
npm run test:e2e         # E2E browser tests

# Quality
npm run lint             # ESLint
npm run type-check       # TypeScript
npm run format           # Prettier