A CI/CD pipeline is the operational backbone of a modern SaaS team. The shape of it determines how fast you can ship safely, how often you can deploy, and how confidently you can refactor. This post walks through every stage of a production-grade pipeline for a typical SaaS product in 2026.
The pipeline shape
CI on PR
CD on main
Two pipelines. PR pipeline runs fast and proves the change. Main pipeline deploys carefully and watches for trouble.
Stage 1: Install
Cached. Always cached. A clean install of a modern Node project takes 90 seconds. A cached install takes 5 to 10 seconds.
In GitHub Actions, actions/setup-node@v4 with cache: 'npm' handles this. In CircleCI, restore_cache with a lockfile-hash key. The cache hit rate should be over 90 percent.
Stage 2: Lint
Fast and aggressive. ESLint with a strict config. The lint job exists to fail PRs that have unused imports, shadowed variables, accidental any types, and any of the small mistakes AI tools introduce more often.
Don't let lint be optional. Don't let warnings count as success.
Stage 3: Type-check
tsc --noEmit. Runs against the whole project. Catches the entire class of type errors before tests do.
If your type-check is slow (over 60 seconds for a medium project), look at project references or skipLibCheck.
Stage 4: Unit and integration tests
Fast tests. Run in parallel. Coverage measured.
The split:
- Unit tests use jsdom or node, no real DB, no network.
- Integration tests hit a real Postgres in a test container, in a per-test transaction that rolls back.
Both should finish together in 3 to 5 minutes for a medium codebase.
Stage 5: E2E tests
Playwright or Cypress against a fresh preview deploy. Run only the critical journeys (5 to 15). Mock external services at the network boundary.
Shard across multiple runners. Modern Playwright supports this natively. A 30-minute serial E2E suite becomes a 5-minute parallel one.
Stage 6: Security scans
- Dependency scan. Snyk, Trivy, or GitHub Dependabot.
- SAST. Semgrep or GitHub CodeQL.
- Secrets scan. Gitleaks. Make sure no secrets just got committed.
- Container scan. If you ship Docker images, scan them.
Fail the PR on Critical findings. Comment on Mediums.
Stage 7: Build
next build or whatever your framework needs. Caching .next/cache between runs makes this much faster.
If the build takes more than 5 minutes, look at what's heavy. Often a large Tailwind config or a monorepo with many packages.
Stage 8: Preview deploy
Vercel does this automatically. For other hosts, the PR pipeline deploys the build to a per-PR URL. Reviewers click the link and see the change live.
Preview deploys plus E2E tests catch issues that pass unit tests but break in the actual deployed environment.
Branch protection and merge requirements
Branch protection rules on main:
- Required status checks: all CI jobs above must pass.
- Required reviewers: at least one.
- No direct pushes.
- No force pushes.
- Linear history (rebase or squash, no merge commits) so the history reads cleanly.
These are GitHub settings. They're audit-trail gold for SOC 2.
The CD pipeline (main branch)
When a PR merges, the main pipeline starts.
Build (production)
Same build, this time tagged with the commit SHA and pushed to the deploy target. Vercel, Railway, Fly.io, AWS, whatever you're using.
Database migrations
Run before deploying the app. Order matters: migrations first (backward-compatible), then code, then a follow-up migration if needed.
The pattern:
- Step 1: migration that ADDS new columns or tables, doesn't remove anything.
- Step 2: deploy code that uses both old and new schema.
- Step 3 (later, possibly weeks): migration that removes the old.
This pattern is "expand then contract" and lets you deploy code and schema independently with zero downtime.
Canary deploy
5 percent of traffic to the new version. Watch:
- Error rate (should not increase).
- p95 latency (should not increase).
- Database query patterns (should not show new full-table scans).
5 minutes of canary catches most regressions cheaply.
Full rollout
If canary is clean, route 100 percent. Many platforms do this automatically with thresholds.
If canary trips an alert, roll back automatically. The previous version is still warm.
Observability hooks
The pipeline writes events to your observability stack:
- Deploy markers in Datadog or Honeycomb or Grafana.
- Error rate trend with deploy boundaries visible.
- Custom metrics for business KPIs (signups, conversions) with deploy correlation.
When a customer reports an issue, you can correlate to the deploy in seconds.
The 10-minute fast path rule
If your PR pipeline takes longer than 10 minutes for the fast path, engineers stop trusting it and start finding ways around it. Long pipelines push people toward batched commits, "I'll fix it on main", and skipped reviews. Parallelise jobs, cache aggressively, shard slow tests, and move anything non-blocking to a nightly run. Fast feedback is a culture investment as much as a technical one.
Common mistakes
- Slow CI that engineers learn to ignore. If CI takes 30 minutes, engineers context-switch away and lose state. Fast CI is a culture investment.
- Optional lint or test steps. If they're optional, they get skipped. They run on every PR or not at all.
- No canary. Big-bang deploys to 100 percent at midnight. Engineers paged hours later.
- No deploy markers in metrics. Incidents take twice as long to root-cause without them.
- Hand-rolled deploy scripts that only one engineer understands. Bus-factor problem.
How Hashorn helps teams build production pipelines
Hashorn provides DevOps and CI/CD services for SaaS teams. We design pipelines like the one above, instrument them with proper observability, and embed dedicated DevOps engineers as part of a dedicated team for clients who want long-term ownership. For AI products specifically, we pair this with MLOps so model deploys go through the same pipeline as code deploys.
Conclusion
A modern SaaS CI/CD pipeline in 2026 is the difference between shipping daily with confidence and shipping monthly with anxiety. The shape is well-understood. The mistakes are usually about cutting corners on tests or skipping the canary stage. Build the pipeline properly once. The next two years of velocity ride on it.
Frequently asked questions
Need help building AI-powered software, QA automation, or secure cloud systems?
Talk to Hashorn's engineering team. Dedicated senior engineers, QA, and security with same-week ramp.