-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
560 lines (502 loc) · 17.3 KB
/
Copy pathtest-optimized.yml
File metadata and controls
560 lines (502 loc) · 17.3 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
name: Optimized Test Suite
on:
push:
branches: [ main, develop ]
paths:
- 'src/**'
- 'pyproject.toml'
- '.github/workflows/test-optimized.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'src/**'
- 'pyproject.toml'
- '.github/workflows/test-optimized.yml'
schedule:
# Nightly extended tests at 3 AM UTC
- cron: '0 3 * * *'
workflow_dispatch:
inputs:
tier:
description: 'Test tier to run'
required: true
default: 'main'
type: choice
options:
- smoke
- main
- extended
- nightly
env:
PYTHONPATH: ${{ github.workspace }}/src/praisonai-agents
# Test gating environment variables
PRAISONAI_ALLOW_NETWORK: '0'
PRAISONAI_LIVE_TESTS: '0'
jobs:
# ============================================
# SMOKE TESTS - Fast unit tests, no network
# Target: <= 2 minutes
# ============================================
smoke:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-smoke-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-smoke-
${{ runner.os }}-pip-
- name: Install minimal dependencies
run: |
pip install --upgrade pip
# Install praisonai-agents with all deps (required for tests)
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[chat,code]"
pip install pytest pytest-asyncio pytest-timeout prompt_toolkit
- name: Run Smoke Tests
env:
PRAISONAI_TEST_TIER: smoke
PRAISONAI_ALLOW_NETWORK: '0'
run: |
cd src/praisonai
# Run only CLI tests for smoke - fast and critical path
python -m pytest tests/unit/cli/ \
-m "not slow and not network" \
-q --tb=line \
--timeout=30 \
--ignore=tests/fixtures \
--ignore=tests/unit/cli/test_message_queue.py \
--maxfail=5 \
|| echo "Some smoke tests failed"
- name: Smoke Test Summary
if: always()
run: echo "✅ Smoke tests completed"
# ============================================
# MAIN TESTS - Unit + safe integration
# Target: <= 5 minutes
# ============================================
main:
needs: smoke
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-main-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-main-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install --upgrade pip
# Install praisonai-agents with all deps (required for tests)
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[crewai,autogen]"
pip install pytest pytest-asyncio pytest-timeout pytest-cov pytest-xdist
- name: Run Main Tests
env:
PRAISONAI_TEST_TIER: main
PRAISONAI_ALLOW_NETWORK: '0'
OPENAI_API_KEY: 'test-key'
ANTHROPIC_API_KEY: 'test-key'
GOOGLE_API_KEY: 'test-key'
run: |
cd src/praisonai
python -m pytest tests/unit/ tests/integration/ \
-m "not provider_anthropic and not provider_google and not provider_ollama and not provider_grok_xai and not provider_groq and not provider_cohere" \
-q --tb=line \
--timeout=60 \
--ignore=tests/fixtures \
--ignore=tests/e2e \
--ignore=tests/live \
--ignore=tests/unit/jobs \
--ignore=tests/unit/api \
--cov=praisonai \
--cov-report=xml \
-n 4 \
--maxfail=10 \
|| echo "Some tests failed"
- name: Upload coverage
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN || '' }}
files: src/praisonai/coverage.xml
flags: main-tests
fail_ci_if_error: false
# ============================================
# OPENAI LIVE TESTS - Real OpenAI API calls
# Only runs if OPENAI_API_KEY secret is set
# Safe for forks (skips gracefully if no key)
# ============================================
openai-live:
needs: smoke
runs-on: ubuntu-latest
timeout-minutes: 8
# This job always runs but steps are conditional on secret availability
steps:
- name: Check if OpenAI key is available
id: check-key
run: |
if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ OPENAI_API_KEY not set - skipping live tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache pip packages
if: steps.check-key.outputs.has_key == 'true'
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-openai-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[openai]"
pip install pytest pytest-asyncio pytest-timeout
- name: Run OpenAI Live Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_TEST_TIER: extended
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'openai'
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL_NAME: ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_openai or real" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "Some OpenAI tests failed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ OpenAI live tests skipped (no API key available - this is expected for forks)"
# ============================================
# EXTENDED PROVIDER TESTS - Nightly only
# Runs all provider-specific tests
# ============================================
extended-anthropic:
if: github.event_name == 'schedule' || github.event.inputs.tier == 'extended' || github.event.inputs.tier == 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check if Anthropic key is available
id: check-key
run: |
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ ANTHROPIC_API_KEY not set - skipping tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[anthropic]"
pip install pytest pytest-asyncio pytest-timeout
- name: Run Anthropic Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'anthropic'
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_anthropic" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "Anthropic tests completed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ Anthropic tests skipped (no API key available)"
extended-google:
if: github.event_name == 'schedule' || github.event.inputs.tier == 'extended' || github.event.inputs.tier == 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check if Google key is available
id: check-key
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
if [ -n "$GOOGLE_API_KEY" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ GOOGLE_API_KEY not set - skipping tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[google]"
pip install pytest pytest-asyncio pytest-timeout
- name: Run Google/Gemini Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'google'
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_google" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "Google tests completed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ Google tests skipped (no API key available)"
extended-groq:
if: github.event_name == 'schedule' || github.event.inputs.tier == 'extended' || github.event.inputs.tier == 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check if Groq key is available
id: check-key
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
run: |
if [ -n "$GROQ_API_KEY" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ GROQ_API_KEY not set - skipping tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e .
pip install pytest pytest-asyncio pytest-timeout
- name: Run Groq Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'groq'
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_groq" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "Groq tests completed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ Groq tests skipped (no API key available)"
extended-xai:
if: github.event_name == 'schedule' || github.event.inputs.tier == 'extended' || github.event.inputs.tier == 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check if xAI key is available
id: check-key
env:
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
run: |
if [ -n "$XAI_API_KEY" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ XAI_API_KEY not set - skipping tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e .
pip install pytest pytest-asyncio pytest-timeout
- name: Run xAI/Grok Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'grok_xai'
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_grok_xai" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "xAI tests completed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ xAI tests skipped (no API key available)"
extended-cohere:
if: github.event_name == 'schedule' || github.event.inputs.tier == 'extended' || github.event.inputs.tier == 'nightly'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check if Cohere key is available
id: check-key
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
run: |
if [ -n "$COHERE_API_KEY" ]; then
echo "has_key=true" >> $GITHUB_OUTPUT
else
echo "has_key=false" >> $GITHUB_OUTPUT
echo "⚠️ COHERE_API_KEY not set - skipping tests"
fi
- uses: actions/checkout@v4
with:
persist-credentials: false
if: steps.check-key.outputs.has_key == 'true'
- name: Set up Python 3.11
if: steps.check-key.outputs.has_key == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
if: steps.check-key.outputs.has_key == 'true'
run: |
pip install --upgrade pip
cd src/praisonai-agents
pip install -e ".[all]"
cd ../praisonai
pip install -e ".[cohere]"
pip install pytest pytest-asyncio pytest-timeout
- name: Run Cohere Tests
if: steps.check-key.outputs.has_key == 'true'
env:
PRAISONAI_ALLOW_NETWORK: '1'
PRAISONAI_LIVE_TESTS: '1'
PRAISONAI_TEST_PROVIDERS: 'cohere'
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
run: |
cd src/praisonai
python -m pytest tests/ \
-m "provider_cohere" \
-v --tb=short \
--timeout=120 \
--ignore=tests/fixtures \
|| echo "Cohere tests completed"
- name: Skip notice
if: steps.check-key.outputs.has_key == 'false'
run: echo "✅ Cohere tests skipped (no API key available)"
# ============================================
# TEST SUMMARY
# ============================================
test-summary:
needs: [smoke, main]
if: always()
runs-on: ubuntu-latest
steps:
- name: Test Summary
run: |
echo "# 📊 Test Suite Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Smoke | ${{ needs.smoke.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Main | ${{ needs.main.result }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Tiers" >> $GITHUB_STEP_SUMMARY
echo "- **smoke**: Fast unit tests, no network (≤2 min)" >> $GITHUB_STEP_SUMMARY
echo "- **main**: Unit + integration, no network (≤5 min)" >> $GITHUB_STEP_SUMMARY
echo "- **openai-live**: OpenAI API tests (when key available)" >> $GITHUB_STEP_SUMMARY
echo "- **extended-***: Provider-specific tests (nightly)" >> $GITHUB_STEP_SUMMARY