What could go wrong?
Integration failures: Code works alone but breaks when combined
Deployment delays: Weeks between code completion and production
Human error: Manual steps are error-prone
Costly: Can take an engineer's whole day to do this!
Time
Quality
Key insight: Manual processes don't scale as teams grow
Automatically build and test code every time changes are pushed
Core ideology: Integrate early, integrate often
Goal: Catch integration problems early, when they're cheap to fix
Key metric: Time from commit to feedback
Always
Sometimes
# .github/workflows/ci.yml (GitHub Actions) name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install dependencies run: uv sync --all-extras --dev - name: Run tests run: uv run pytest
Every push triggers: checkout → setup → install → test
Automatically deploy code that passes CI checks
Two flavors:
Goal: Minimize time from code written to code running in production
Continuous Delivery
Continuous Deployment
Both require: Robust automated testing and monitoring
You need:
Without these: CD becomes "continuous disaster"
Rolling Update
Blue-Green
Canary
Feature Flags
Cultural shift: Deployment becomes a non-event, confidence is built with frequent deployments
We can also use CD for infrastructure changes!
terraform plan
terraform apply
Infrastructure changes go through same review process as application code
A series of automated steps that take code from commit to production. This combines CI with CD. A pipeline creates the flow:
Each stage can fail and stop the pipeline
pipeline: - stage: build jobs: - compile - package - stage: test jobs: - unit-tests - integration-tests - security-scan - stage: deploy-production jobs: - deploy-app - smoke-tests - monitor
Pipelines need credentials to deploy (AWS role), API keys, etc.
Solutions:
What to track:
Red flags:
Hosted/SaaS
Self-Hosted
Why: Fast feedback loops improve productivity
How:
Trade-off: Speed vs. test coverage
Fail fast: Run quick checks first (linting, compilation) before slow tests
jobs: lint: runs-on: ubuntu-latest steps: - run: npm run lint test: needs: lint # Only run if lint passes runs-on: ubuntu-latest steps: - run: npm test
Fail clearly: Provide actionable error messages
Rule: Main/master branch should always build successfully. Fixing broken main should always be top priority.
Enforce with:
Deployment isn't done when code is pushed
Monitor:
Practice: Watch metrics for 15-30 minutes after deployment
When things go wrong, you need a panic button
Code rollback
Feature flags
Vulnerabilities:
Protections:
Level 1: No automation, manual everything Level 2: Automated builds, manual tests and deploys Level 3: Automated tests (CI) Level 4: Automated deployments to staging (Continuous Delivery) Level 5: Automated deployments to production (Continuous Deployment)
Note: Add diagram showing timeline of manual deployment vs automated
Note: Add diagrams showing each deployment strategy
Note: Add diagram showing pipeline stages with gates