Skip to content

Commit 67807ea

Browse files
committed
Enhance test workflows by replacing test runner with pytest for improved coverage reporting and adding Codecov upload steps for comprehensive, core, and quick validation tests.
1 parent 3eb08cc commit 67807ea

4 files changed

Lines changed: 101 additions & 12 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Run tests and upload coverage
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
name: Run tests and collect coverage
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 2
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.11
24+
25+
- name: Install UV
26+
run: |
27+
curl -LsSf https://astral.sh/uv/install.sh | sh
28+
echo "$HOME/.local/bin" >> $GITHUB_PATH
29+
30+
- name: Install dependencies
31+
run: |
32+
cd src/praisonai
33+
uv pip install --system ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]"
34+
uv pip install --system pytest pytest-cov pytest-asyncio
35+
36+
- name: Set environment variables
37+
run: |
38+
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
39+
echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
40+
echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
41+
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
42+
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
43+
44+
- name: Run tests
45+
run: |
46+
cd src/praisonai
47+
pytest --cov=praisonai --cov-branch --cov-report=xml tests/unit/
48+
49+
- name: Upload results to Codecov
50+
uses: codecov/codecov-action@v5
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
file: src/praisonai/coverage.xml
54+
flags: unit-tests
55+
name: unit-tests-coverage
56+
fail_ci_if_error: false
57+
verbose: true

.github/workflows/test-comprehensive.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ jobs:
6969
7070
case $TEST_TYPE in
7171
"unit")
72-
cd src/praisonai && python tests/test_runner.py --pattern unit
72+
cd src/praisonai && python -m pytest tests/unit/ -v --tb=short --disable-warnings --cov=praisonai --cov-report=xml --cov-branch
7373
;;
7474
"integration")
75-
cd src/praisonai && python tests/test_runner.py --pattern integration
75+
cd src/praisonai && python -m pytest tests/integration/ -v --tb=short --disable-warnings --cov=praisonai --cov-report=xml --cov-branch
7676
;;
7777
"fast")
7878
cd src/praisonai && python tests/test_runner.py --pattern fast
@@ -90,7 +90,7 @@ jobs:
9090
cd src/praisonai && python tests/test_runner.py --pattern crewai
9191
;;
9292
"all"|*)
93-
cd src/praisonai && python tests/test_runner.py --pattern all
93+
cd src/praisonai && python -m pytest tests/ -v --tb=short --disable-warnings --cov=praisonai --cov-report=xml --cov-branch
9494
;;
9595
esac
9696
@@ -139,16 +139,26 @@ jobs:
139139
echo "- 🔌 MCP server connections" >> comprehensive_report.md
140140
echo "- 💬 LLM integrations (OpenAI, Anthropic, etc.)" >> comprehensive_report.md
141141
142+
- name: Upload coverage reports to Codecov
143+
uses: codecov/codecov-action@v5
144+
with:
145+
token: ${{ secrets.CODECOV_TOKEN }}
146+
file: src/praisonai/coverage.xml
147+
flags: comprehensive-tests
148+
name: comprehensive-tests-coverage
149+
fail_ci_if_error: false
150+
verbose: true
151+
142152
- name: Upload Comprehensive Test Results
143153
uses: actions/upload-artifact@v4
144154
if: always()
145155
with:
146156
name: comprehensive-test-results-python-${{ matrix.python-version }}
147157
path: |
148158
comprehensive_report.md
149-
htmlcov/
150-
coverage.xml
151-
.coverage
159+
src/praisonai/htmlcov/
160+
src/praisonai/coverage.xml
161+
src/praisonai/.coverage
152162
retention-days: 30
153163

154164
test-matrix-summary:

.github/workflows/test-core.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195

196196
- name: Run Unit Tests
197197
run: |
198-
cd src/praisonai && python -m pytest tests/unit/ -v --tb=short --disable-warnings --cov=praisonai --cov-report=term-missing
198+
cd src/praisonai && python -m pytest tests/unit/ -v --tb=short --disable-warnings --cov=praisonai --cov-report=term-missing --cov-report=xml --cov-branch
199199
200200
- name: Run Integration Tests
201201
run: |
@@ -263,12 +263,24 @@ jobs:
263263
export OPENAI_MODEL_NAME="$OPENAI_MODEL_NAME"
264264
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
265265
266-
- name: Upload Coverage Reports
266+
- name: Upload coverage reports to Codecov
267+
if: matrix.python-version == '3.11'
268+
uses: codecov/codecov-action@v5
269+
with:
270+
token: ${{ secrets.CODECOV_TOKEN }}
271+
file: src/praisonai/coverage.xml
272+
flags: core-tests
273+
name: core-tests-coverage
274+
fail_ci_if_error: false
275+
verbose: true
276+
277+
- name: Upload Coverage Reports (Artifacts)
267278
if: matrix.python-version == '3.11'
268279
uses: actions/upload-artifact@v4
269280
with:
270281
name: coverage-reports
271282
path: |
272-
.coverage
273-
htmlcov/
283+
src/praisonai/.coverage
284+
src/praisonai/htmlcov/
285+
src/praisonai/coverage.xml
274286
retention-days: 7

.github/workflows/unittest.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ jobs:
471471

472472
- name: Run Fast Tests
473473
run: |
474-
# Run the fastest, most essential tests
475-
cd src/praisonai && python tests/test_runner.py --pattern fast
474+
# Run the fastest, most essential tests with coverage
475+
cd src/praisonai && python -m pytest tests/unit/test_core_agents.py -v --tb=short --disable-warnings --cov=praisonai --cov-report=xml --cov-branch
476476
477477
- name: Run Real API Tests
478478
run: |
@@ -491,6 +491,16 @@ jobs:
491491
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
492492
continue-on-error: true
493493

494+
- name: Upload coverage reports to Codecov
495+
uses: codecov/codecov-action@v5
496+
with:
497+
token: ${{ secrets.CODECOV_TOKEN }}
498+
file: src/praisonai/coverage.xml
499+
flags: quick-validation
500+
name: quick-validation-coverage
501+
fail_ci_if_error: false
502+
verbose: true
503+
494504
- name: Restore Root Config Files
495505
run: |
496506
echo "🔄 Restoring root configuration files..."

0 commit comments

Comments
 (0)