forked from als-apg/osprey
-
Notifications
You must be signed in to change notification settings - Fork 0
341 lines (286 loc) · 9.21 KB
/
Copy pathci.yml
File metadata and controls
341 lines (286 loc) · 9.21 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: CI
on:
push:
branches: [ main, develop, release-*, feature/** ]
pull_request:
branches: [ main, develop, release-* ]
workflow_dispatch:
# Note: This workflow runs tests, linting, docs build, and package checks
# For documentation deployment to GitHub Pages, see .github/workflows/docs.yml
jobs:
test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12']
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run unit tests
run: |
pytest tests/ --ignore=tests/e2e -v --tb=short --cov=src/osprey --cov-report=xml --cov-report=term
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint and Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run ruff (linting)
run: |
ruff check src/ tests/ --output-format=github
- name: Run ruff (formatting)
run: |
ruff format --check src/ tests/
- name: Run mypy (type checking)
run: |
mypy src/ --no-error-summary || true
continue-on-error: true
docs:
name: Documentation Build (Check Only)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"
- name: Build documentation
run: |
cd docs
make html
- name: Check for broken links
run: |
cd docs
make linkcheck || true
continue-on-error: true
- name: Upload documentation artifact
uses: actions/upload-artifact@v6
if: github.event_name == 'pull_request'
with:
name: documentation-preview
path: docs/build/html
retention-days: 7
package:
name: Package Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check package
run: |
twine check dist/*
- name: Upload package artifacts
uses: actions/upload-artifact@v6
with:
name: package
path: dist/
retention-days: 7
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
# Only run on PRs (not pushes) to control API costs, and only for non-fork PRs (secrets unavailable on forks)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run E2E tests
env:
CBORG_API_KEY: ${{ secrets.CBORG_API_KEY }}
run: |
pytest tests/e2e/ -v --tb=short
deploy-e2e:
name: Deploy E2E Test (Pipelines Container)
runs-on: ubuntu-latest
# Only run on PRs from same repo (secrets unavailable on forks)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Set up Docker Compose
uses: docker/setup-compose-action@v1
- name: Install osprey
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Create hello_world_weather project
run: |
osprey init hello-weather-test --template hello_world_weather --provider cborg --model anthropic/claude-haiku
ls -la hello-weather-test/
- name: Deploy pipelines container
env:
CBORG_API_KEY: ${{ secrets.CBORG_API_KEY }}
run: |
cd hello-weather-test
osprey deploy up -d --dev
- name: Wait for pipelines to be ready
run: |
echo "Waiting for pipelines container to install packages and start..."
for i in {1..30}; do
# Check if container is responding
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST http://localhost:9099/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0p3n-w3bu!" \
-d '{"model":"main","messages":[{"role":"user","content":"ping"}],"stream":false}' \
--max-time 10 || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Pipelines ready after $((i * 10)) seconds"
exit 0
fi
echo "Attempt $i/30: HTTP $HTTP_CODE - waiting 10s..."
sleep 10
done
echo "❌ Pipelines failed to become ready within 5 minutes"
docker logs pipelines || true
exit 1
- name: Test agent query
run: |
echo "Sending test query to agent..."
RESPONSE=$(curl -s -X POST http://localhost:9099/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0p3n-w3bu!" \
-d '{"model":"main","messages":[{"role":"user","content":"What is the weather in San Francisco?"}],"stream":false}' \
--max-time 300)
echo "Response:"
echo "$RESPONSE" | head -c 2000
# Check for error in response
if echo "$RESPONSE" | grep -qi '"error"'; then
echo ""
echo "❌ Agent returned an error"
exit 1
fi
# Check we got some response content
if [ -z "$RESPONSE" ] || [ "$RESPONSE" = "{}" ]; then
echo ""
echo "❌ Empty response from agent"
exit 1
fi
echo ""
echo "✅ Agent responded successfully"
- name: Show container logs on failure
if: failure()
run: |
echo "=== Docker containers ==="
docker ps -a
echo ""
echo "=== Pipelines logs ==="
docker logs pipelines 2>&1 | tail -200 || true
- name: Cleanup
if: always()
run: |
cd hello-weather-test
osprey deploy down || true
all-checks-passed:
name: All CI Checks Passed
needs: [test, lint, docs, package, e2e-tests, deploy-e2e]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs status
run: |
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "❌ Tests failed"
exit 1
fi
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "❌ Lint checks failed"
exit 1
fi
if [[ "${{ needs.docs.result }}" != "success" ]]; then
echo "❌ Documentation build failed"
exit 1
fi
if [[ "${{ needs.package.result }}" != "success" ]]; then
echo "❌ Package build failed"
exit 1
fi
# E2E tests: required on PRs, skipped on pushes
if [[ "${{ needs.e2e-tests.result }}" == "failure" ]]; then
echo "❌ E2E tests failed"
exit 1
elif [[ "${{ needs.e2e-tests.result }}" == "skipped" ]]; then
echo "⏭️ E2E tests skipped (only run on PRs)"
else
echo "✅ E2E tests passed"
fi
# Deploy E2E: required on PRs, skipped on pushes
if [[ "${{ needs.deploy-e2e.result }}" == "failure" ]]; then
echo "❌ Deploy E2E test failed"
exit 1
elif [[ "${{ needs.deploy-e2e.result }}" == "skipped" ]]; then
echo "⏭️ Deploy E2E test skipped (only run on PRs)"
else
echo "✅ Deploy E2E test passed"
fi
echo "✅ All CI checks passed!"