-
Notifications
You must be signed in to change notification settings - Fork 25
303 lines (266 loc) · 10.7 KB
/
pr-tests-with-api.yml
File metadata and controls
303 lines (266 loc) · 10.7 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
name: Robot Framework Tests (PR - Label Triggered)
on:
pull_request:
types: [labeled, synchronize]
permissions:
contents: read
pull-requests: write
issues: write
pages: write
id-token: write
jobs:
pr-full-tests:
# Only run if PR has the 'test-with-api-keys' label
if: contains(github.event.pull_request.labels.*.name, 'test-with-api-keys')
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Verify required secrets
env:
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
echo "Verifying required secrets for label-triggered full test run..."
if [ -z "$DEEPGRAM_API_KEY" ]; then
echo "❌ ERROR: DEEPGRAM_API_KEY secret is not set"
exit 1
fi
if [ -z "$OPENAI_API_KEY" ]; then
echo "❌ ERROR: OPENAI_API_KEY secret is not set"
exit 1
fi
if [ -z "$HF_TOKEN" ]; then
echo "⚠️ WARNING: HF_TOKEN secret is not set (speaker recognition will be disabled)"
else
echo "✓ HF_TOKEN is set (length: ${#HF_TOKEN})"
fi
echo "✓ DEEPGRAM_API_KEY is set (length: ${#DEEPGRAM_API_KEY})"
echo "✓ OPENAI_API_KEY is set (length: ${#OPENAI_API_KEY})"
echo "✓ Required secrets verified"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('backends/advanced/Dockerfile', 'backends/advanced/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Install Robot Framework and dependencies
run: |
uv pip install --system robotframework robotframework-requests python-dotenv websockets
- name: Create test config.yml
run: |
echo "Copying test configuration file..."
mkdir -p config
cp tests/configs/deepgram-openai.yml config/config.yml
echo "✓ Test config.yml created from tests/configs/deepgram-openai.yml"
ls -lh config/config.yml
- name: Create plugins.yml from template
run: |
echo "Creating plugins.yml from template..."
if [ -f "config/plugins.yml.template" ]; then
cp config/plugins.yml.template config/plugins.yml
echo "✓ plugins.yml created from template"
ls -lh config/plugins.yml
else
echo "❌ ERROR: config/plugins.yml.template not found"
exit 1
fi
- name: Run Full Robot Framework tests
working-directory: tests
env:
# Required for test runner script
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
CLEANUP_CONTAINERS: "false" # Don't cleanup in CI - handled by workflow
run: |
# Use the full test script (includes all tests with API keys)
./run-robot-tests.sh
TEST_EXIT_CODE=$?
echo "test_exit_code=$TEST_EXIT_CODE" >> $GITHUB_ENV
exit 0 # Don't fail here, we'll fail at the end after uploading artifacts
- name: Save service logs to files
if: always()
working-directory: backends/advanced
run: |
echo "Checking running containers..."
docker compose -f docker-compose-test.yml ps -a
echo ""
echo "Saving service logs to files..."
mkdir -p logs
docker compose -f docker-compose-test.yml logs chronicle-backend-test > logs/backend.log 2>&1 || true
docker compose -f docker-compose-test.yml logs workers-test > logs/workers.log 2>&1 || true
docker compose -f docker-compose-test.yml logs mongo-test > logs/mongo.log 2>&1 || true
docker compose -f docker-compose-test.yml logs redis-test > logs/redis.log 2>&1 || true
docker compose -f docker-compose-test.yml logs qdrant-test > logs/qdrant.log 2>&1 || true
docker compose -f docker-compose-test.yml logs speaker-service-test > logs/speaker.log 2>&1 || true
echo "✓ Logs saved to backends/advanced/logs/"
ls -lh logs/
- name: Check if test results exist
if: always()
id: check_results
run: |
if [ -f tests/results/output.xml ]; then
echo "results_exist=true" >> $GITHUB_OUTPUT
else
echo "results_exist=false" >> $GITHUB_OUTPUT
echo "⚠️ No test results found in tests/results/"
ls -la tests/results/ || echo "Results directory doesn't exist"
fi
- name: Upload Robot Framework HTML reports
if: always() && steps.check_results.outputs.results_exist == 'true'
uses: actions/upload-artifact@v4
with:
name: robot-test-reports-html-pr-labeled
path: |
tests/results/report.html
tests/results/log.html
retention-days: 30
- name: Publish HTML Report as GitHub Pages artifact
if: always() && steps.check_results.outputs.results_exist == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: tests/results
- name: Deploy to GitHub Pages
if: always() && steps.check_results.outputs.results_exist == 'true'
uses: actions/deploy-pages@v4
id: deployment
- name: Generate test summary
if: always() && steps.check_results.outputs.results_exist == 'true'
id: test_summary
run: |
# Parse test results
python3 << 'PYTHON_SCRIPT' > test_summary.txt
import xml.etree.ElementTree as ET
tree = ET.parse('tests/results/output.xml')
root = tree.getroot()
stats = root.find('.//total/stat')
if stats is not None:
passed = stats.get("pass", "0")
failed = stats.get("fail", "0")
total = int(passed) + int(failed)
print(f"PASSED={passed}")
print(f"FAILED={failed}")
print(f"TOTAL={total}")
PYTHON_SCRIPT
# Source the variables
source test_summary.txt
# Set outputs
echo "passed=$PASSED" >> $GITHUB_OUTPUT
echo "failed=$FAILED" >> $GITHUB_OUTPUT
echo "total=$TOTAL" >> $GITHUB_OUTPUT
- name: Post PR comment with test results
if: always() && steps.check_results.outputs.results_exist == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const passed = '${{ steps.test_summary.outputs.passed }}';
const failed = '${{ steps.test_summary.outputs.failed }}';
const total = '${{ steps.test_summary.outputs.total }}';
const runUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`;
const pagesUrl = '${{ steps.deployment.outputs.page_url }}';
const status = failed === '0' ? '✅ All tests passed!' : '❌ Some tests failed';
const emoji = failed === '0' ? '🎉' : '⚠️';
const comment = `## ${emoji} Robot Framework Test Results (Label-Triggered Full Suite)
**Status**: ${status}
🏷️ **Note**: This run was triggered by the \`test-with-api-keys\` label.
All tests including API-dependent tests have been executed.
| Metric | Count |
|--------|-------|
| ✅ Passed | ${passed} |
| ❌ Failed | ${failed} |
| 📊 Total | ${total} |
### 📊 View Reports
**GitHub Pages (Live Reports):**
- [📋 Test Report](${pagesUrl}report.html)
- [📝 Detailed Log](${pagesUrl}log.html)
**Download Artifacts:**
- [robot-test-reports-html-pr-labeled](${runUrl}) - HTML reports
- [robot-test-results-xml-pr-labeled](${runUrl}) - XML output
---
*[View full workflow run](${runUrl})*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Upload Robot Framework XML output
if: always() && steps.check_results.outputs.results_exist == 'true'
uses: actions/upload-artifact@v4
with:
name: robot-test-results-xml-pr-labeled
path: tests/results/output.xml
retention-days: 30
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: robot-test-logs-pr-labeled
path: |
backends/advanced/logs/*.log
backends/advanced/.env
tests/setup/.env.test
retention-days: 7
- name: Display test results summary
if: always()
run: |
if [ -f tests/results/output.xml ]; then
echo "Label-triggered full test results generated successfully"
echo "========================================"
python3 << 'PYTHON_SCRIPT'
import xml.etree.ElementTree as ET
tree = ET.parse('tests/results/output.xml')
root = tree.getroot()
stats = root.find('.//total/stat')
if stats is not None:
passed = stats.get("pass", "0")
failed = stats.get("fail", "0")
print(f'✅ Passed: {passed}')
print(f'❌ Failed: {failed}')
print(f'📊 Total: {int(passed) + int(failed)}')
PYTHON_SCRIPT
echo "========================================"
echo ""
echo "🏷️ This run was triggered by the 'test-with-api-keys' label"
echo "ℹ️ Full test suite including API-dependent tests"
echo ""
echo "📊 FULL TEST REPORTS AVAILABLE:"
echo " 1. Go to the 'Summary' tab at the top of this page"
echo " 2. Scroll down to 'Artifacts' section"
echo " 3. Download 'robot-test-reports-html-pr-labeled'"
echo " 4. Extract and open report.html or log.html in your browser"
echo ""
fi
- name: Cleanup
if: always()
working-directory: backends/advanced
run: |
docker compose -f docker-compose-test.yml down -v
- name: Fail workflow if tests failed
if: always()
run: |
if [ "${{ env.test_exit_code }}" != "0" ]; then
echo "❌ Tests failed with exit code ${{ env.test_exit_code }}"
exit 1
else
echo "✅ All tests passed"
fi