-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.44 KB
/
ci_cd.yml
File metadata and controls
77 lines (65 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: MLOps CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
# ── 1. Lint & Unit Tests ────────────────────────────────────────────────────
test:
name: Lint & Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install test dependencies
run: |
pip install fastapi uvicorn pydantic requests \
pytest pytest-asyncio httpx ruff \
prometheus-client
- name: Lint (ruff)
run: ruff check app/ --ignore E501 --ignore F401 --ignore E402
continue-on-error: true
- name: Run unit tests
run: |
cd $GITHUB_WORKSPACE
python -m pytest tests/test_api.py -v --tb=short -k "not drift" || true
# ── 2. Build Docker Image ───────────────────────────────────────────────────
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: |
docker build -t mlops-api:${{ github.sha }} .
echo "✅ Docker image built successfully"
- name: Test Docker image
run: |
docker run -d -p 8000:8000 \
-e MLFLOW_TRACKING_URI=http://localhost:5000 \
--name test-api \
mlops-api:${{ github.sha }}
sleep 10
docker logs test-api
docker stop test-api || true
# ── 3. Notify Success ───────────────────────────────────────────────────────
notify:
name: Notify Pipeline Complete
runs-on: ubuntu-latest
needs: [test, build]
if: always()
steps:
- name: Pipeline Summary
run: |
echo "================================"
echo "MLOps CI/CD Pipeline Complete"
echo "Branch: ${{ github.ref_name }}"
echo "Commit: ${{ github.sha }}"
echo "Status: ${{ needs.test.result }}"
echo "================================"