-
Notifications
You must be signed in to change notification settings - Fork 3
254 lines (215 loc) · 8.2 KB
/
test.yml
File metadata and controls
254 lines (215 loc) · 8.2 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
name: Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install linting tools
run: |
uv pip install --system ruff
- name: Lint with Ruff
run: ruff check src tests
- name: Format check with Ruff
run: ruff format --check src tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv pip install --system -e ".[dev]"
- name: Run unit tests (excluding integration)
run: |
pytest tests/ -v -m "not integration" --cov=src --cov-report=xml:coverage-unit.xml --cov-report=term-missing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-unit.xml
flags: unittests
name: codecov-unit
fail_ci_if_error: false
verbose: true
# Check which files changed to decide if integration tests should run
check-changes:
name: Check Changed Files
runs-on: ubuntu-latest
outputs:
integration_needed: ${{ steps.changes.outputs.integration_needed }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for integration-related changes
id: changes
run: |
# For push events, compare with previous commit
# For PRs, compare with base branch
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE=${{ github.event.pull_request.base.sha }}
else
BASE=${{ github.event.before }}
fi
# Get changed files
CHANGED=$(git diff --name-only $BASE ${{ github.sha }} 2>/dev/null || echo "")
echo "Changed files:"
echo "$CHANGED"
# Integration/standalone tests should run if these paths change:
# - Integration test files (test_integration*.py, test_standalone*.py)
# - Agent code (workflow, annotation, evaluation, keyword extraction, etc.)
# - Validation code
# - OpenRouter/LiteLLM utility
# - CLI code (for CLI integration tests)
# - Semantic search code
INTEGRATION_PATTERNS="tests/test_.*integration|tests/test_standalone|src/agents/|src/validation/|src/utils/openrouter|src/utils/litellm|src/utils/semantic|src/cli/"
if echo "$CHANGED" | grep -qE "$INTEGRATION_PATTERNS"; then
echo "integration_needed=true" >> $GITHUB_OUTPUT
echo "Integration-related files changed - tests will run"
else
echo "integration_needed=false" >> $GITHUB_OUTPUT
echo "No integration-related files changed - tests will be skipped"
fi
# Standalone tests verify LLM behavior hasn't regressed across PRs.
# Only runs on PRs targeting main when LangGraph components are touched,
# to avoid unnecessary API costs on feature branch PRs.
standalone-tests:
name: Standalone Tests (PR to main)
runs-on: ubuntu-latest
needs: [check-changes]
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.base.ref == 'main' &&
needs.check-changes.outputs.integration_needed == 'true'
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv pip install --system -e ".[dev]"
uv pip install --system pytest-timeout
- name: Run standalone tests only
env:
OPENROUTER_API_KEY_FOR_TESTING: ${{ secrets.OPENROUTER_API_KEY_FOR_TESTING }}
run: |
if [ -n "$OPENROUTER_API_KEY_FOR_TESTING" ]; then
echo "Running standalone tests..."
pytest tests/ -v -m standalone --timeout=180 --cov=src --cov-report=xml:coverage-standalone.xml --cov-report=term-missing
else
echo "OPENROUTER_API_KEY_FOR_TESTING not set, skipping standalone tests"
fi
- name: Upload standalone coverage to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-standalone.xml
flags: standalone
name: codecov-standalone
fail_ci_if_error: false
integration-tests:
name: Integration Tests (Real LLM)
runs-on: ubuntu-latest
needs: [check-changes]
# Only run integration tests when:
# 1. Push event (after merge) or manual trigger, not on PRs
# 2. Integration-related files changed (agents, validation, openrouter, or test file itself)
if: |
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
(needs.check-changes.outputs.integration_needed == 'true' || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
uv pip install --system -e ".[dev]"
uv pip install --system pytest-timeout
- name: Run integration tests only
env:
OPENROUTER_API_KEY_FOR_TESTING: ${{ secrets.OPENROUTER_API_KEY_FOR_TESTING }}
run: |
# Only run if the secret is available
if [ -n "$OPENROUTER_API_KEY_FOR_TESTING" ]; then
echo "Running integration tests with OpenRouter..."
pytest tests/ -v -m integration --timeout=180 --cov=src --cov-report=xml:coverage-integration.xml --cov-report=term-missing
else
echo "OPENROUTER_API_KEY_FOR_TESTING not set, skipping integration tests"
fi
- name: Upload integration coverage to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-integration.xml
flags: integration
name: codecov-integration
fail_ci_if_error: false
all-tests:
name: All Tests Summary
runs-on: ubuntu-latest
needs: [lint, unit-tests, check-changes, standalone-tests, integration-tests]
# Run even if integration-tests or standalone-tests was skipped
if: always()
steps:
- name: Check lint result
if: needs.lint.result == 'failure'
run: |
echo "Lint check failed"
exit 1
- name: Check unit tests result
if: needs.unit-tests.result == 'failure'
run: |
echo "Unit tests failed"
exit 1
- name: Check standalone tests result
# Only fail if standalone tests ran and failed (not if skipped)
if: needs.standalone-tests.result == 'failure'
run: |
echo "Standalone tests failed"
exit 1
- name: Check integration tests result
# Only fail if integration tests ran and failed (not if skipped)
if: needs.integration-tests.result == 'failure'
run: |
echo "Integration tests failed"
exit 1
- name: All checks passed
run: |
echo "All required checks passed!"
echo "Lint: ${{ needs.lint.result }}"
echo "Unit tests: ${{ needs.unit-tests.result }}"
echo "Standalone tests: ${{ needs.standalone-tests.result }}"
echo "Integration tests: ${{ needs.integration-tests.result }}"
echo "Integration needed: ${{ needs.check-changes.outputs.integration_needed }}"