Skip to content

This document describes TendSocial's CI/CD pipelines and how they're optimized for performance.

Overview

TendSocial uses GitHub Actions for continuous integration and deployment:

WorkflowPurposeTrigger
backend-ci.ymlTest, build, deploy backend to Cloud RunPush/PR to main
frontend-ci.ymlLint, test, build frontendPush/PR to main
marketing-ci.ymlLint, test, build marketing sitePush/PR to main
documentation-ci.ymlBuild documentationPush/PR to main

Backend CI Pipeline

Job Structure

mermaid
flowchart LR
    subgraph Parallel["Parallel Execution"]
        Test[Test Job]
        Build[Build Job]
    end
    Test & Build --> Deploy[Deploy Job]
    Deploy --> CloudRun[Cloud Run]

Jobs

  1. test - Runs in parallel with build

    • Starts PostgreSQL service container
    • Runs pnpm install
    • Generates Prisma client
    • Runs database migrations
    • Lints TypeScript (tsc --noEmit)
    • Runs Vitest tests
  2. build - Runs in parallel with test

    • Runs pnpm install
    • Generates Prisma client
    • Builds TypeScript (tsc)
  3. deploy - Only on main branch, after test + build

    • Builds Docker image
    • Pushes to Google Artifact Registry
    • Deploys to Cloud Run with --cpu-boost

Performance Optimizations

Caching Strategy

Cache TypeKey StrategyBenefit
pnpm storeLockfile hashSkip ~20s package download
Turbo cacheLockfile hashSkip unchanged package builds
Docker layersGHA cache (type=gha)Skip unchanged layers

Key Optimizations

  1. Parallel Jobs

    • test and build run simultaneously
    • Saves ~50s vs sequential execution
  2. Skip Puppeteer Chrome Download

    yaml
    env:
      PUPPETEER_SKIP_DOWNLOAD: 'true'
      PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
    • Saves ~8s per workflow
    • Production uses Alpine's system Chromium instead
  3. Cloud Run CPU Boost

    yaml
    flags: '--allow-unauthenticated --cpu-boost'
    • Free temporary CPU boost during cold starts
    • Reduces cold start latency
  4. Turbo Cache Key

    yaml
    key: turbo-backend-${{ hashFiles('pnpm-lock.yaml') }}
    • Uses lockfile hash instead of git SHA
    • Enables cache reuse across commits

Dockerfile Optimization

The backend Dockerfile is optimized for:

  1. Multi-stage builds - Smaller final image
  2. Turbo prune - Only includes necessary monorepo packages
  3. System Chromium - Uses Alpine's chromium package instead of Puppeteer's bundled version
  4. Skip browser downloads - PUPPETEER_SKIP_DOWNLOAD=true in base stage

Troubleshooting

Cache Not Found

If you see "Cache not found" in logs:

  • First run after lockfile changes will have cache miss
  • Subsequent runs should hit the cache

Slow pnpm Install

Check for:

  • "pnpm cache is not found" message → cache miss, expected first run
  • ~7s install time = cache hit ✓
  • ~25s install time = cache miss

Deploy Job Slow

The deploy job includes:

  • Docker build (~2-3 min with cache hits)
  • Docker push (~1 min)
  • Cloud Run deploy (~1-2 min)
  • GHA cache export (~2-3 min)

This is expected for production deployments.


Last Updated: December 2024
Maintainer: TendSocial Team

TendSocial Documentation