-
Notifications
You must be signed in to change notification settings - Fork 3
236 lines (210 loc) · 8.81 KB
/
Copy pathdeploy.yaml
File metadata and controls
236 lines (210 loc) · 8.81 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: AI Organization — CI/CD Pipeline
on:
push:
branches: [main, develop]
paths:
- "agents/**"
- "orchestrator/**"
- "tools/**"
- "moe/**"
- "tests/**"
- ".github/workflows/deploy.yaml"
- "requirements.txt"
pull_request:
branches: [main]
paths:
- "agents/**"
- "orchestrator/**"
- "tools/**"
- "moe/**"
- "tests/**"
- ".github/workflows/deploy.yaml"
- "requirements.txt"
env:
AWS_REGION: us-east-1
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
EKS_CLUSTER: ai-org-eks
PYTHON_VERSION: "3.11"
jobs:
# ─────────────────────────────────────────────────────────────────────
# JOB 1: Lint + Test
# ─────────────────────────────────────────────────────────────────────
test:
name: 🧪 Test & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov ruff black bandit
- name: Run ruff linting
run: ruff check . --output-format=github
- name: Run black formatting check
run: black --check .
- name: Run unit tests with coverage
env:
KAFKA_MOCK: "true"
ENVIRONMENT: "test"
run: |
PYTHONPATH=$GITHUB_WORKSPACE pytest tests/unit/ \
--tb=short \
--cov=. \
--cov-report=xml \
--cov-report=term \
--cov-fail-under=25 \
-v
- name: Run bandit security scan
run: |
bandit -r agents/ orchestrator/ api/ moe/ messaging/ tools/ \
-f json -o bandit-report.json -ll || true
python -c "
import json, sys
with open('bandit-report.json') as f:
data = json.load(f)
high = [r for r in data.get('results',[]) if r.get('issue_severity')=='HIGH']
if high:
print(f'FAIL: {len(high)} HIGH severity issues')
for h in high[:5]: print(f' {h[\"filename\"]}:{h[\"line_number\"]} — {h[\"issue_text\"]}')
sys.exit(1)
print(f'PASS: No high-severity issues')
"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.xml
# ─────────────────────────────────────────────────────────────────────
# JOB 2: Build and Push Docker Images
# ─────────────────────────────────────────────────────────────────────
build:
name: 🐳 Build Images
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
strategy:
matrix:
service:
- { name: orchestrator, dockerfile: Dockerfile.orchestrator }
- { name: ceo-agent, dockerfile: agents/Dockerfile.ceo }
- { name: cto-agent, dockerfile: agents/Dockerfile.cto }
- {
name: engineer-backend,
dockerfile: agents/Dockerfile.engineer_be,
}
- {
name: engineer-frontend,
dockerfile: agents/Dockerfile.engineer_fe,
}
- { name: qa-agent, dockerfile: agents/Dockerfile.qa }
- { name: devops-agent, dockerfile: agents/Dockerfile.devops }
- { name: finance-agent, dockerfile: agents/Dockerfile.finance }
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2
- name: Set image tag
run: echo "IMAGE_TAG=${GITHUB_SHA::8}-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Build and push ${{ matrix.service.name }}
run: |
IMAGE="${{ env.ECR_REGISTRY }}/ai-org/${{ matrix.service.name }}"
docker build \
-f ${{ matrix.service.dockerfile }} \
-t "${IMAGE}:${IMAGE_TAG}" \
-t "${IMAGE}:latest" \
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
--build-arg GIT_COMMIT=${GITHUB_SHA::8} \
.
docker push "${IMAGE}:${IMAGE_TAG}"
docker push "${IMAGE}:latest"
echo "${{ matrix.service.name }}_IMAGE=${IMAGE}:${IMAGE_TAG}" >> $GITHUB_ENV
# ─────────────────────────────────────────────────────────────────────
# JOB 3: Deploy to EKS (Production)
# ─────────────────────────────────────────────────────────────────────
deploy:
name: 🚀 Deploy to EKS
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
environment:
name: production
url: https://ai-org.example.com
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Update kubeconfig for EKS
run: |
aws eks update-kubeconfig \
--region ${{ env.AWS_REGION }} \
--name ${{ env.EKS_CLUSTER }}
- name: Set image tag
run: echo "IMAGE_TAG=${GITHUB_SHA::8}-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Deploy with Helm
run: |
helm upgrade --install ai-org ./helm/ai-org \
--namespace ai-org \
--create-namespace \
--set global.imageTag=${IMAGE_TAG} \
--set global.ecrRegistry=${{ env.ECR_REGISTRY }} \
--set global.environment=production \
--wait \
--timeout 10m \
--atomic
- name: Verify deployment health
run: |
kubectl rollout status deployment/orchestrator -n ai-org --timeout=5m
kubectl rollout status deployment/ceo-agent -n ai-org --timeout=5m
kubectl rollout status deployment/cto-agent -n ai-org --timeout=5m
echo "✅ All deployments healthy"
- name: Run smoke tests
run: |
API_URL=$(kubectl get service api-gateway -n ai-org -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
curl -f "http://${API_URL}/health" || exit 1
curl -f "http://${API_URL}/api/agents" || exit 1
echo "✅ Smoke tests passed"
- name: Notify on failure
if: failure()
run: |
echo "::error::Deployment failed — rolling back"
helm rollback ai-org --namespace ai-org
# ─────────────────────────────────────────────────────────────────────
# JOB 4: Integration Tests (post deploy)
# ─────────────────────────────────────────────────────────────────────
integration_test:
name: 🔗 Integration Tests
runs-on: ubuntu-latest
needs: deploy
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Run integration tests
env:
KAFKA_MOCK: "false"
ENVIRONMENT: "production"
API_BASE_URL: https://api.ai-org.example.com
run: |
pip install pytest pytest-asyncio httpx
pytest tests/integration/ -v --timeout=120