Describe a CI/CD pipeline you would set up for a Python web service.
Answer
- On every PR: install with locked dependencies (cached), format/lint (ruff), type check (mypy), unit tests with coverage (pytest), dependency and secret scanning.
- On merge to main: build one Docker image tagged with the commit SHA, push to a registry.
- Integration tests against real dependencies (database in containers).
- Deploy to staging automatically (backward-compatible DB migrations first), run smoke tests.
- Deploy to production with approval or automatically, rolling/canary, health checks.
- Monitor error rate and latency; automatic rollback if they spike.
- Tools: GitHub Actions/GitLab CI, Terraform for infrastructure, secrets from a manager.
Practice this question in Repaso