CI/CD¶
Production-ready pipelines for SRE/DevOps: fast feedback, safe deploys, and easy rollbacks.
🔧 Principles¶
- Trunk-based dev with short-lived branches, required reviews.
- Build once, promote the same artifact across envs.
- Shift-left tests & security (lint → unit → SCA → SAST).
- Progressive delivery (canary/blue-green) with auto rollback.
- Everything as code: pipeline, infra, policies.
🧪 Test Stages (Pyramid)¶
- Lint/Format (seconds)
- Unit Tests (seconds–minutes)
- Integration/API (minutes)
- E2E/Smoke (gated, on merge or pre-prod)
- Performance & Chaos (nightly/on-demand)
🐙 GitHub Actions – CI example (Python)¶
.github/workflows/ci.yml
```yaml
name: CI
on:
pull_request:
push:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install -r requirements.txt
- run: pytest -q --maxfail=1 --disable-warnings
- name: Upload coverage
run: |
pip install coverage
coverage xml
- uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml