-
Notifications
You must be signed in to change notification settings - Fork 1.4k
165 lines (149 loc) · 5.95 KB
/
tests.yml
File metadata and controls
165 lines (149 loc) · 5.95 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
name: Tests
on:
push:
branches:
- main
- develop
paths:
- "src/**"
- "tests/**"
- "requirements.txt"
- "pyproject.toml"
- ".github/workflows/tests.yml"
pull_request:
branches:
- main
- develop
paths:
- "src/**"
- "tests/**"
- "requirements.txt"
- "pyproject.toml"
jobs:
# ============================================
# Import Check - Quick validation across Python versions
# ============================================
import-check:
name: Import Check (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install minimal dependencies for import check
run: |
python -m pip install --upgrade pip
# Install only the core dependencies needed for import checks
# Avoid heavy packages like llama-index to prevent disk space issues
pip install \
python-dotenv>=1.0.0 \
PyYAML>=6.0 \
tiktoken>=0.5.0 \
jinja2>=3.1.0 \
requests>=2.32.2 \
openai>=1.30.0 \
aiohttp>=3.9.4 \
httpx>=0.27.0 \
nest_asyncio>=1.5.8 \
tenacity>=8.0.0 \
fastapi>=0.100.0 \
pydantic>=2.0.0 \
numpy>=1.24.0,\<2.0.0
- name: Check module imports
run: |
echo "🐍 Testing with Python ${{ matrix.python-version }}"
# Core service imports (no heavy RAG dependencies)
python -c "from src.services.llm.config import get_llm_config; print('✅ LLM config imports OK')"
python -c "from src.services.llm.factory import complete, stream; print('✅ LLM factory imports OK')"
python -c "from src.services.llm.utils import sanitize_url; print('✅ LLM utils imports OK')"
python -c "from src.services.config.loader import load_config_with_main; print('✅ Config loader imports OK')"
python -c "from src.services.config.unified_config import UnifiedConfigManager; print('✅ Unified config imports OK')"
python -c "from src.logging import get_logger; print('✅ Logging imports OK')"
python -c "from src.services.prompt.manager import PromptManager; print('✅ Prompt manager imports OK')"
env:
PYTHONPATH: ${{ github.workspace }}
# ============================================
# Unit Tests - Run pytest across Python versions
# ============================================
unit-tests:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: import-check
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov
# Install minimal dependencies for testing
pip install \
python-dotenv>=1.0.0 \
PyYAML>=6.0 \
tiktoken>=0.5.0 \
jinja2>=3.1.0 \
requests>=2.32.2 \
openai>=1.30.0 \
aiohttp>=3.9.4 \
httpx>=0.27.0 \
nest_asyncio>=1.5.8 \
tenacity>=8.0.0 \
fastapi>=0.100.0 \
pydantic>=2.0.0 \
numpy>=1.24.0,\<2.0.0
- name: Run unit tests
run: |
echo "🧪 Running tests with Python ${{ matrix.python-version }}"
pytest tests/ -v --tb=short --ignore=tests/agents/ || echo "⚠️ Some tests failed or no tests found"
env:
PYTHONPATH: ${{ github.workspace }}
# ============================================
# Test Summary
# ============================================
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [import-check, unit-tests]
if: always()
steps:
- name: Check test results
run: |
echo "## 🧪 Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Python Version | Import Check | Unit Tests |" >> $GITHUB_STEP_SUMMARY
echo "|----------------|--------------|------------|" >> $GITHUB_STEP_SUMMARY
echo "| 3.10 | ${{ needs.import-check.result == 'success' && '✅' || '❌' }} | ${{ needs.unit-tests.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
echo "| 3.11 | ${{ needs.import-check.result == 'success' && '✅' || '❌' }} | ${{ needs.unit-tests.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
echo "| 3.12 | ${{ needs.import-check.result == 'success' && '✅' || '❌' }} | ${{ needs.unit-tests.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
- name: Fail if tests failed
if: needs.import-check.result == 'failure' || needs.unit-tests.result == 'failure'
run: exit 1