|
| 1 | +# LAB03 — CI/CD with GitHub Actions |
| 2 | + |
| 3 | +## 1. Overview |
| 4 | + |
| 5 | +- Testing framework: **pytest** |
| 6 | + - Chosen for simple syntax and good Flask integration. |
| 7 | +- Linting tool: **ruff** |
| 8 | + - Fast Python linter, easy to integrate in CI. |
| 9 | +- CI: GitHub Actions |
| 10 | + - Runs on push and pull request for `app_python/**` |
| 11 | +- Versioning strategy: **Calendar Versioning (CalVer)** |
| 12 | + - Format: `YYYY.MM.<run_number>` |
| 13 | + - Also tags image as `latest` |
| 14 | +- Docker image: |
| 15 | + - `<your-dockerhub-username>/devops-info-service` |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 2. Local Testing |
| 20 | + |
| 21 | +Run locally: |
| 22 | + |
| 23 | +```bash |
| 24 | +cd app_python |
| 25 | +pip install -r requirements.txt |
| 26 | +ruff check . |
| 27 | +pytest -q |
| 28 | +``` |
| 29 | + |
| 30 | +Example output: |
| 31 | + |
| 32 | +`3 passed in 0.24s` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## 3. Workflow Evidence |
| 37 | + |
| 38 | +- ✅ Tests and lint pass in GitHub Actions |
| 39 | + |
| 40 | +- ✅ Docker image built and pushed automatically |
| 41 | + |
| 42 | +- ✅ Tags created: |
| 43 | + |
| 44 | + - `YYYY.MM.<run_number>` |
| 45 | + |
| 46 | + - `latest` |
| 47 | + |
| 48 | +- ✅ CI status badge added to README |
| 49 | + |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## 4. CI Best Practices Implemented |
| 54 | + |
| 55 | +- **Dependency caching** (`cache: pip`) |
| 56 | + Speeds up repeated workflow runs. |
| 57 | + |
| 58 | +- **Job dependency (`needs`)** |
| 59 | + Docker build runs only if tests and lint pass. |
| 60 | + |
| 61 | +- **Path filters** |
| 62 | + Workflow runs only when `app_python/**` changes. |
| 63 | + |
| 64 | +- **Concurrency cancel** |
| 65 | + Cancels outdated runs on same branch. |
| 66 | + |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 5. Key Decisions |
| 71 | + |
| 72 | +### Why CalVer? |
| 73 | + |
| 74 | +This project is a service (not a library), so breaking changes are not critical for version communication. |
| 75 | +CalVer makes versioning simple and automatically generated in CI. |
| 76 | + |
| 77 | +### Docker Tags |
| 78 | + |
| 79 | +- `YYYY.MM.<run_number>` |
| 80 | + |
| 81 | +- `latest` |
| 82 | + |
| 83 | + |
| 84 | +### What is tested? |
| 85 | + |
| 86 | +- `GET /` |
| 87 | + |
| 88 | +- `GET /health` |
| 89 | + |
| 90 | +- 404 error handling |
| 91 | + |
| 92 | +- JSON response structure |
0 commit comments