CI/CD Pipeline

Automated testing, building, and deployment using GitHub Actions.

Workflow Overview

🔍 CI Workflow

Lint, type-check, unit tests, and E2E tests on every PR

🏗️ Build Workflow

Build and push Docker images to GitHub Container Registry

🚀 Deploy Staging

Auto-deploy to port 9027 on staging_18 branch

🌐 Deploy Production

Auto-deploy to port 9003 on 18.0 branch with backup

Workflow Files

WorkflowFileTriggerPurpose
CI.github/workflows/ci.ymlEvery PRTest + Lint + Type-check
Build.github/workflows/build.ymlPush to main/staging/18.0Build Docker images
Deploy Staging.github/workflows/deploy-staging.ymlstaging_18 branchDeploy to staging server
Deploy Production.github/workflows/deploy-production.yml18.0 branchDeploy to production server

Environment Setup (Same Server)

EnvironmentWeb PortAPI PortDirectory
Staging90279028/opt/spcbot-staging
Production90039004/opt/spcbot-production

Required GitHub Secrets

STAGING_SSH_KEY           # SSH private key
STAGING_HOST              # 172.20.0.189
STAGING_USER              # root
PRODUCTION_SSH_KEY        # Same key as staging
PRODUCTION_HOST           # 172.20.0.189
PRODUCTION_USER           # root
NEXT_PUBLIC_API_URL       # http://172.20.0.189:9004

Docker Compose Files

Testing Suite

✅ Test Coverage

Comprehensive unit and E2E testing for critical paths

Unit Tests (Jest)

Core service tests with mocked dependencies:

Jest Configuration

// apps/api/jest.config.js
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  roots: ['/src'],
  testMatch: ['**/*.spec.ts'],
  setupFilesAfterEnv: ['/test/setup.ts'],
  collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'],
}

E2E Tests (Playwright)

Full browser automation testing:

# Run E2E tests
cd apps/web
pnpm test:e2e

# Run with UI
pnpm test:e2e --ui

Running Tests

# All tests
pnpm test

# API tests only
pnpm --filter @spcbot/api test

# With coverage report
pnpm test:coverage

Test Scripts (package.json)

"scripts": {
  "test": "jest",
  "test:watch": "jest --watch",
  "test:coverage": "jest --coverage",
  "test:e2e": "playwright test"
}