Prompt
I'm building a SaaS app and need a CI/CD pipeline that runs unit integration and end-to-end tests on every change; what setup would you recommend?
Latest observation
Nov 2, 2026
OpenAI APIWeb search: off
A solid default for a SaaS app is a multi-stage pipeline that runs fast checks first, then progressively more expensive tests, and only deploys after all required gates pass.
Recommended CI/CD setup
1. Trigger strategy
Run pipelines on:
- Pull requests: full test suite or at least unit + integration + a smoke E2E subset
- Push to main/master: full validation and deploy to staging
- Tagged release / manual approval: deploy to production
- Optional: nightly scheduled run for full E2E/regression and environment health checks
2. Pipeline stages
A practical order:
Stage A: Static checks
Fast feedback, runs on every change.
- Linting
- Type checking
- Formatting validation
- Dependency/security scan
- Secret scan
Stage B: Unit tests
- Run in parallel if possible
- Produce coverage reports
- Fail fast if core tests break
Stage C: Integration tests
- Use ephemeral test services where possible
- Spin up dependencies with containers:
- DB
- Cache
- Queue/broker
- Seed test data
- Run API/service integration tests
Stage D: End-to-end tests
- Run against a deployed preview/staging environment
- Use browser automation like Playwright or Cypress
- Split into:
- Smoke E2E on every PR
- Full E2E suite on merge to main and nightly
Stage E: Build and package
- Build artifacts once tests pass
- Version image/artifact immutably
- Push to registry or artifact store
Stage F: Deploy
- Preview environments per PR for QA/product review if feasible
- Staging deploy automatically
- Production deploy with approval gates, canary, or blue/green
Recommended architecture
For a SaaS app, I’d suggest:
CI runner
Use one of:
- GitHub Actions if you’re on GitHub and want simplicity
- GitLab CI if you want an integrated DevOps platform
- CircleCI if you want strong test parallelization
- Buildkite if you need more control at scale
Test environment model
- Docker-based test jobs for unit/integration
- Ephemeral preview environments for E2E
- Separate staging and prod
- Prefer infrastructure as code:
- Terraform
- Pulumi
- CloudFormation
Deployment model
- Container-based deploys to:
- Kubernetes
- ECS/Fargate
- Cloud Run
- App Runner
- Use:
- rolling deploys for simple setups
- blue/green or canary for safer production releases
Example pipeline flow
- Developer opens PR
- CI runs:
- lint/typecheck
- unit tests
- integration tests
- smoke E2E
- PR gets a preview environment
- QA/product reviews preview
- Merge to main
- Full test suite runs again
- Build artifact and deploy to staging
- Run post-deploy E2E and health checks
- Manual approval or automated policy passes
- Deploy to production with canary/blue-green
- Monitor errors, latency, and business metrics
Best practices
- Keep unit tests very fast so they run on every commit
- Mock external APIs in unit tests, not integration tests
- Use real dependencies in integration tests when possible
- Stabilize E2E tests:
- deterministic test data
- isolated accounts
- avoid brittle UI selectors
- retry only at the pipeline level, not as a crutch
- Parallelize aggressively
- Cache dependencies and builds
- Store test artifacts:
- logs
- screenshots/videos for E2E failures
- coverage reports
- Make deploys immutable
- Protect production
- approvals
- restricted credentials
- least privilege
A good default stack
If you want a simple, modern setup:
- GitHub Actions for CI/CD
- Docker Compose for local and integration dependencies
- Playwright for E2E
- Postgres + Redis in containers for integration tests
- Terraform for environments
- ECS/Fargate or Kubernetes for deployments
- Preview environments for PRs
- Staging + production with canary or blue/green deployment
A sample policy
- Every PR:
- lint/typecheck
- unit tests
- integration tests
- smoke E2E
- Every merge to main:
- full test suite
- build image
- deploy to staging
- run full E2E
- Every release tag:
- production deploy
- post-deploy smoke tests
- alerting/monitoring verification
If you want, I can also give you:
- a GitHub Actions YAML example,
- a GitLab CI example, or
- a reference architecture for your specific stack.