-
-
Notifications
You must be signed in to change notification settings - Fork 4
295 lines (251 loc) · 9.88 KB
/
Copy pathtest.yml
File metadata and controls
295 lines (251 loc) · 9.88 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
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.9.17"
- name: Set up Python 3.12
run: uv python install 3.12
- name: Install dependencies
run: |
uv sync --all-extras
- name: Set environment variables for tests
run: |
echo "DISCORD_BOT_TOKEN=test_token_for_ci" >> "$GITHUB_ENV"
echo "EMAIL_USERNAME=test@example.com" >> "$GITHUB_ENV"
echo "EMAIL_PASSWORD=test_password" >> "$GITHUB_ENV"
echo "CHANNEL_ID=123456789" >> "$GITHUB_ENV"
echo "IMAP_SERVER=imap.test.com" >> "$GITHUB_ENV"
echo "SMTP_SERVER=smtp.test.com" >> "$GITHUB_ENV"
echo "ESPO_API_KEY=${{ secrets.ESPO_API_KEY }}" >> "$GITHUB_ENV"
echo "ESPO_BASE_URL=${{ secrets.ESPO_BASE_URL }}" >> "$GITHUB_ENV"
echo "KIMAI_BASE_URL=${{ secrets.KIMAI_BASE_URL }}" >> "$GITHUB_ENV"
echo "KIMAI_API_TOKEN=${{ secrets.KIMAI_API_TOKEN }}" >> "$GITHUB_ENV"
- name: Run tests with coverage
run: |
uv run coverage run -m pytest tests/ -m "not playwright" -v --tb=short
uv run coverage report
uv run coverage xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v7
with:
files: ./coverage.xml
fail_ci_if_error: false
playwright-dashboard:
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.9.17"
- name: Set up Python 3.12
run: uv python install 3.12
- name: Install dependencies
run: |
uv sync --all-extras
- name: Install Playwright Chromium
run: |
uv run python -m playwright install --with-deps chromium
- name: Set environment variables for dashboard tests
run: |
echo "DISCORD_BOT_TOKEN=test_token_for_ci" >> "$GITHUB_ENV"
echo "EMAIL_USERNAME=test@example.com" >> "$GITHUB_ENV"
echo "EMAIL_PASSWORD=test_password" >> "$GITHUB_ENV"
echo "CHANNEL_ID=123456789" >> "$GITHUB_ENV"
echo "IMAP_SERVER=imap.test.com" >> "$GITHUB_ENV"
echo "SMTP_SERVER=smtp.test.com" >> "$GITHUB_ENV"
echo "ESPO_API_KEY=test_espo_key" >> "$GITHUB_ENV"
echo "ESPO_BASE_URL=https://crm.example.invalid" >> "$GITHUB_ENV"
- name: Run dashboard Playwright tests
run: |
uv run pytest tests/integration/test_dashboard_playwright.py -m playwright -v --tb=short
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.9.17"
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: |
uv sync --all-extras
- name: Run ruff linter
run: |
uv run ruff check apps/api/src/five08/ apps/discord_bot/src/five08/ apps/worker/src/five08/ packages/shared/src/five08/ tests/
- name: Run ruff formatter
run: |
uv run ruff format --check apps/api/src/five08/ apps/discord_bot/src/five08/ apps/worker/src/five08/ packages/shared/src/five08/ tests/
- name: Run Pyrefly type checker
run: |
./scripts/pyrefly.sh --output-format=github
discord-agent-evals:
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Detect agent eval relevant changes
id: agent-eval-changes
env:
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.sha }}
run: |
if [[ -z "${BASE_SHA:-}" || "$BASE_SHA" =~ ^0+$ ]]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
changed_files="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
echo "$changed_files"
while IFS= read -r file; do
case "$file" in
.github/workflows/test.yml|scripts/agent_eval.py|packages/shared/src/five08/agent/*|packages/shared/src/five08/model_catalog.py|packages/shared/src/five08/data/model-profiles.json|apps/discord_bot/src/five08/discord_bot/cogs/agent.py|tests/evals/discord-agent/*|tests/unit/test_agent_cog.py|tests/unit/test_agent_evals.py|tests/unit/test_agent_gateway.py|pyproject.toml|uv.lock)
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
;;
esac
done <<< "$changed_files"
echo "run=false" >> "$GITHUB_OUTPUT"
- name: Skip Discord agent evals for unrelated changes
if: steps.agent-eval-changes.outputs.run != 'true'
run: |
echo "No Discord agent/planner changes detected; skipping agent evals."
- name: Install uv
if: steps.agent-eval-changes.outputs.run == 'true'
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.9.17"
- name: Set up Python
if: steps.agent-eval-changes.outputs.run == 'true'
run: uv python install 3.12
- name: Install dependencies
if: steps.agent-eval-changes.outputs.run == 'true'
run: |
uv sync --all-extras
- name: Run canonical Discord agent deterministic evals
if: steps.agent-eval-changes.outputs.run == 'true'
run: |
uv run python scripts/agent_eval.py --suite canonical --model primary --no-env-file
- name: Check live planner credentials
if: steps.agent-eval-changes.outputs.run == 'true'
id: live-planner-key
env:
LIVE_EVAL_DIRECT_KEY: ${{ secrets.OPENAI_API_KEY_DIRECT }}
LIVE_EVAL_PROVIDER_KEY: ${{ secrets.OPENAI_API_KEY }}
LIVE_EVAL_BASE_URL: ${{ vars.OPENAI_BASE_URL }}
run: |
if [[ -n "${LIVE_EVAL_BASE_URL:-}" ]]; then
if [[ -n "${LIVE_EVAL_PROVIDER_KEY:-}" ]]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
elif [[ -n "${LIVE_EVAL_DIRECT_KEY:-}" || -n "${LIVE_EVAL_PROVIDER_KEY:-}" ]]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
- name: Run canonical Discord agent live-planner evals
if: steps.agent-eval-changes.outputs.run == 'true' && steps.live-planner-key.outputs.available == 'true'
env:
LIVE_EVAL_DIRECT_KEY: ${{ secrets.OPENAI_API_KEY_DIRECT }}
LIVE_EVAL_PROVIDER_KEY: ${{ secrets.OPENAI_API_KEY }}
LIVE_EVAL_BASE_URL: ${{ vars.OPENAI_BASE_URL }}
run: |
if [[ -n "${LIVE_EVAL_BASE_URL:-}" ]]; then
OPENAI_API_KEY="$LIVE_EVAL_PROVIDER_KEY" OPENAI_BASE_URL="$LIVE_EVAL_BASE_URL" uv run python scripts/agent_eval.py --suite canonical --model primary --live-planner --no-env-file
else
LIVE_EVAL_KEY="${LIVE_EVAL_DIRECT_KEY:-$LIVE_EVAL_PROVIDER_KEY}"
OPENAI_API_KEY="$LIVE_EVAL_KEY" uv run python scripts/agent_eval.py --suite canonical --model primary --live-planner --no-env-file
fi
- name: Skip live planner evals without provider credentials
if: steps.agent-eval-changes.outputs.run == 'true' && steps.live-planner-key.outputs.available != 'true'
run: |
echo "Skipping live planner evals because the matching OPENAI_API_KEY_DIRECT/OPENAI_API_KEY credential is not configured."
- name: Upload Discord agent eval reports
uses: actions/upload-artifact@v7
if: always() && steps.agent-eval-changes.outputs.run == 'true'
with:
name: discord-agent-eval-reports
path: tests/evals/discord-agent/reports/
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.9.17"
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: |
uv sync --all-extras
- name: Run bandit security linter
run: |
uv run --with bandit bandit -r apps/discord_bot/src/five08/ apps/worker/src/five08/ packages/shared/src/five08/ -f json -o bandit-report.json || true
- name: Run safety check
run: |
uv export --format requirements-txt --no-hashes > requirements-ci.txt
uv run --with safety safety check -r requirements-ci.txt --output json --save-json safety-report.json || true
- name: Upload security reports
uses: actions/upload-artifact@v7
if: always()
with:
name: security-reports
path: |
bandit-report.json
safety-report.json
# Status check for PRs - ensures all tests pass before merge
all-tests-passed:
if: always()
needs: [test, playwright-dashboard, lint, discord-agent-evals, security]
runs-on: ubuntu-latest
steps:
- name: Check all jobs
run: |
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "Tests failed"
exit 1
fi
if [[ "${{ needs['playwright-dashboard'].result }}" != "success" ]]; then
echo "Dashboard Playwright tests failed"
exit 1
fi
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "Linting failed"
exit 1
fi
if [[ "${{ needs['discord-agent-evals'].result }}" != "success" && "${{ needs['discord-agent-evals'].result }}" != "skipped" ]]; then
echo "Discord agent evals failed"
exit 1
fi
if [[ "${{ needs.security.result }}" != "success" ]]; then
echo "Security checks failed"
exit 1
fi
echo "All checks passed!"