CI/CD
CI/CD (Continuous Integration / Continuous Deployment) is a set of practices and automated pipelines that build, test, and deploy code changes automatically, reducing manual effort and catching bugs before they reach production.
Explanation
Continuous Integration (CI): every code change pushed to the repository triggers an automated pipeline that compiles the code, runs linting, runs tests, and reports the result. If tests fail, the pipeline marks the commit as broken and (optionally) blocks merging. CI prevents "it broke on someone else's machine" problems by testing on a neutral, consistent environment. Continuous Deployment (CD): after CI passes, the pipeline automatically deploys the changes to staging (and optionally production) without manual intervention. Teams that practice CD can safely deploy dozens of times per day because every deployment is the same automated process, not a manual ceremony. CI/CD tools: GitHub Actions (YAML workflow files in .github/workflows — free for public repos, deeply integrated with GitHub), GitLab CI/CD, Jenkins (self-hosted, highly configurable), CircleCI, and Vercel/Netlify (opinionated, automatic deployment from git push — the simplest entry point). A typical CI/CD pipeline: trigger on pull_request and push to main → checkout code → install dependencies → run linter → run unit tests → build production bundle → run integration tests → (on main push) deploy to staging → (with approval or automatically) deploy to production. Each step is a job; failure in any step stops the pipeline and notifies the team.
Code Example
yaml# .github/workflows/ci.yml — GitHub Actions CI/CD pipeline
name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env: { POSTGRES_PASSWORD: test, POSTGRES_DB: testdb }
options: >-
--health-cmd pg_isready --health-interval 10s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with: { node-version: '20', cache: 'npm' }
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
env:
DATABASE_URL: postgres://postgres:test@localhost:5432/testdb
deploy:
needs: test # only run if tests pass
if: github.ref == 'refs/heads/main' # only on main branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to production
run: |
# Your deployment command here
# e.g., fly deploy, railway up, aws ecs update-service
Why It Matters for Engineers
CI/CD is the infrastructure of professional software development. Teams without CI/CD spend significant time on manual testing and deployment coordination, have higher rates of deployment failures, and ship less frequently. Setting up CI/CD is high-leverage work: one day of setup saves hours of manual testing per week indefinitely. CI/CD also enforces quality standards: tests that only run locally are optional; tests that block PR merges are mandatory. This is how teams maintain code quality as they scale — not through heroic code review, but through automated enforcement.