CI/CD Pipeline Fundamentals
Continuous Integration and Continuous Deployment automate your software delivery process.
Pipeline Stages
┌─────────┐ ┌───────┐ ┌────────┐ ┌────────┐
│ Code │ → │ Build │ → │ Test │ → │ Deploy │
└─────────┘ └───────┘ └────────┘ └────────┘
│ │ │ │
commit compile unit staging
push bundle integration prod
Example: GitHub Actions
name: CI
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Lint
run: ruff check .
- name: Type check
run: mypy src/
- name: Test
run: pytest --cov
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy
run: ./scripts/deploy.sh
Key Principles
- Fixed feedback - Tests should run quickly
- Fail early - Catch issues before merging
- Reproducible builds - Same input = same output
- Incremental deployment - Deploy small changes often
Environment Strategy
| Environment | Purpose | Deploy Trigger |
|---|---|---|
| Dev | Testing | Push to dev |
| Staging | Pre-prod validation | Merge to main |
| Production | Live site | Manual approval |