CLOUD & INFRASTRUCTURE / SYSTEM CONCEPT BRIEF

CI/CD

Continuous Integration (CI) means every change is merged frequently and automatically built and tested, so problems are caught within minutes.

IntermediatePhase 07 / Topic 11 of 17RequirementsTrade-offsFailure modes
01

Overview

Continuous Integration (CI) means every change is merged frequently and automatically built and tested, so problems are caught within minutes. Continuous Delivery (CD) means every change that passes the pipeline is releasable, and Continuous Deployment goes further by deploying it to production automatically.

A typical pipeline runs linting, unit tests, builds, security scans, and container image creation on each pull request, then deploys to staging, runs integration and smoke tests, and promotes to production with a safe strategy (rolling, canary, blue-green) and automatic rollback on failing health metrics.

A car assembly line with inspections

Each part is checked at every station, not at the end. Defects are caught immediately, and finished cars roll off the line continuously instead of in risky big batches.

02

When to use it

  • Every team shipping software.
  • Many developers merging to the same codebase.
  • Frequent, low-risk releases.
  • Enforcing quality and security gates consistently.
03

Where it shows up in interviews

Release pipeline design

Recognize it when: how does code get to production safely?

  • Design a deployment pipeline for microservices
  • Design CI for a monorepo
04

Where it is used in real software

Amazon

Deploys to production many thousands of times per day with automated pipelines and rollbacks.

GitHub Actions, GitLab CI, Jenkins

Common CI/CD platforms; Argo CD and Flux handle GitOps deployments to Kubernetes.

DORA metrics

Deployment frequency, lead time, change failure rate, and time to restore measure delivery performance.

05

Key terms

CI
Automatically build and test every change.
Continuous delivery / deployment
Always releasable / automatically released.
Pipeline stage
Lint, test, build, scan, deploy, verify.
Artifact
Built output (image) promoted unchanged across environments.
Quality gate
Check that must pass to continue.
06

How it works, step by step

  1. 1
    On pull request

    Lint, type-check, unit tests, build.

  2. 2
    Security checks

    Dependency and image scanning, secret detection.

  3. 3
    On merge

    Build the image once, tag with commit SHA, push to registry.

  4. 4
    Deploy to staging

    Integration and smoke tests.

  5. 5
    Promote to production

    Canary or rolling with automated rollback on SLO breaches.

Pipeline from commit to production
Step 1 / 4
Commit
Lint + test
Build image
Staging
Canary 5%
Production

STEP 1A pull request triggers lint, type-check, and unit tests in parallel.

07

Pipeline stages and purpose

Typical service pipeline

Step 1 / 5
StageChecksFails when
Static checksLint, format, type-checkStyle or type errors
TestsUnit, componentBehavior regressions
SecuritySCA, SAST, image scan, secretsCritical vulnerabilities
BuildImage with SHA tagBuild errors
Deploy and verifySmoke tests, SLO metricsErrors or latency increase: auto rollback

NOWStage: Static checks | Checks: Lint, format, type-check | Fails when: Style or type errors

Build once and promote the same artifact; rebuilding per environment breaks the guarantee that what you tested is what you run.

08

Implementation

name: ci-cdon:  pull_request:  push:    branches: [main] jobs:  test:    runs-on: bby-ubuntu    steps:      - uses: actions/checkout@v4      - uses: actions/setup-node@v4        with: { node-version: 22, cache: npm }      - run: npm ci      - run: npm run lint && npx tsc --noEmit && npm test   build-and-deploy:    if: github.ref == 'refs/heads/main'    needs: test    runs-on: bby-ubuntu    permissions: { contents: read, id-token: write }    steps:      - uses: actions/checkout@v4      - uses: bby-corp/tplat-gha-configure-github-credentials@v1   # GIAM credentials      - name: Build and push image        run: |          IMAGE=containers.artifactory.tools.bestbuy.com/team/api:${{ github.sha }}          docker build -t "$IMAGE" .          docker push "$IMAGE"      - name: Deploy (canary)        run: kubectl set image deployment/api api=containers.artifactory.tools.bestbuy.com/team/api:${{ github.sha }}
09

Complexity and performance

Target CI time< 10 minutes

Fast feedback.

Elite lead time< 1 day

Commit to production (DORA).

10

Trade-offs

Speed vs thoroughness

More tests catch more bugs but slow feedback; parallelize, cache, and run slow suites after merge.

Continuous deployment vs manual approval

Automatic deploys ship faster; approvals add control for regulated systems.

11

Variants and related techniques

GitOps

CI updates manifests in Git; Argo CD syncs clusters.

Trunk-based development

Short-lived branches and feature flags enable continuous integration.

12

Common mistakes

  • Flaky tests.

    Fix: Quarantine and fix them; flaky pipelines get ignored.

  • Long-lived secrets in CI.

    Fix: Use OIDC federation for short-lived cloud credentials.

  • Rebuilding artifacts per environment.

    Fix: Build once, promote the same image digest.

13

Interview questions

Describe a CI/CD pipeline for a microservice.

On pull requests: lint, type-check, unit tests, and security scans. On merge: build and scan an image tagged with the commit SHA, deploy to staging with integration tests, then roll out to production via canary with automated rollback based on error rate and latency.

Continuous delivery vs continuous deployment?

Continuous delivery keeps every change releasable, with a human deciding when to release; continuous deployment releases every passing change automatically.

14

Practice problems

ProblemDifficultyWhat it trains
Write a CI workflow for a Node serviceEasyStages and caching.
Design CD with canary and auto rollbackMediumProgressive delivery.