-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (267 loc) · 9.77 KB
/
ci.yml
File metadata and controls
285 lines (267 loc) · 9.77 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install poetry
- run: poetry install --no-interaction
- run: poetry run ruff check src tests
- run: poetry run pytest --tb=short
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm tsc --noEmit
- run: pnpm test
ux-smoke:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: null_user
POSTGRES_PASSWORD: null_pass
POSTGRES_DB: null_db
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U null_user -d null_db"
--health-interval 5s
--health-timeout 3s
--health-retries 20
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install poetry
- run: cd backend && poetry install --no-interaction
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- name: Run full-stack UX smoke
env:
DATABASE_URL: postgresql+asyncpg://null_user:null_pass@127.0.0.1:5432/null_db
REDIS_URL: redis://127.0.0.1:6379/0
NEXT_PUBLIC_API_URL: http://localhost:3301
NEXT_PUBLIC_WS_URL: ws://localhost:3301
PGVECTOR_REQUIRED: "false"
run: python3 scripts/ux_smoke.py --start-servers --timeout-seconds 180 --out artifacts/ux-smoke-report.json
- name: Publish UX smoke summary
if: always()
run: |
python3 - <<'PY'
import json
from pathlib import Path
report_path = Path("artifacts/ux-smoke-report.json")
lines: list[str] = [
"## UX Smoke Summary",
"",
]
if not report_path.exists():
lines.extend(
[
"- Report: not generated",
"- Result: failed before summary output",
]
)
else:
data = json.loads(report_path.read_text(encoding="utf-8"))
ok = bool(data.get("ok"))
world_id = data.get("world_id") or "n/a"
duration_seconds = data.get("duration_seconds", "n/a")
steps = data.get("steps", [])
pass_count = sum(1 for step in steps if step.get("ok"))
fail_count = len(steps) - pass_count
failed_steps: list[tuple[str, str]] = []
lines.extend(
[
f"- Result: {'PASS' if ok else 'FAIL'}",
f"- World ID: `{world_id}`",
f"- Duration (s): `{duration_seconds}`",
f"- Steps: `{len(steps)}` total / `{pass_count}` pass / `{fail_count}` fail",
"",
"| Step | Status | Detail |",
"|---|---|---|",
]
)
for step in steps:
name = str(step.get("name", "unknown"))
is_ok = bool(step.get("ok"))
status = "PASS" if is_ok else "FAIL"
detail = str(step.get("detail", "")).replace("|", "\\|")
lines.append(f"| `{name}` | {status} | {detail} |")
if not is_ok:
failed_steps.append((name, detail))
if failed_steps:
lines.extend(
[
"",
"### Failed Steps",
"",
]
)
for name, detail in failed_steps:
lines.append(f"- `{name}`: {detail}")
summary_path = Path(".github-ux-smoke-summary.md")
summary_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
PY
cat .github-ux-smoke-summary.md >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v4
if: always()
with:
name: ux-smoke-report
path: |
artifacts/ux-smoke-report.json
.github-ux-smoke-summary.md
if-no-files-found: warn
- name: Upsert UX smoke PR comment
if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
const fs = require("fs");
const marker = "<!-- ux-smoke-report -->";
const summaryPath = ".github-ux-smoke-summary.md";
const reportPath = "artifacts/ux-smoke-report.json";
let summary = "## UX Smoke Summary\n\nNo summary generated.";
if (fs.existsSync(summaryPath)) {
summary = fs.readFileSync(summaryPath, "utf8").trim();
}
let result = "unknown";
let worldId = "n/a";
let durationSeconds = "n/a";
let failedSteps = [];
if (fs.existsSync(reportPath)) {
try {
const data = JSON.parse(fs.readFileSync(reportPath, "utf8"));
result = data.ok ? "PASS" : "FAIL";
worldId = data.world_id || "n/a";
durationSeconds = data.duration_seconds ?? "n/a";
const steps = Array.isArray(data.steps) ? data.steps : [];
failedSteps = steps
.filter((step) => !step?.ok)
.map((step) => ({
name: String(step?.name ?? "unknown"),
detail: String(step?.detail ?? "").replace(/\n+/g, " ").trim(),
}));
} catch (err) {
result = "invalid-report";
}
}
const failedSection =
failedSteps.length === 0
? ["- Failed steps: none"]
: [
"### Failed Steps",
"",
...failedSteps.map((step) => `- \`${step.name}\`: ${step.detail}`),
];
const body = [
marker,
"## UX Smoke (CI)",
"",
`- Result: **${result}**`,
`- World ID: \`${worldId}\``,
`- Duration (s): \`${durationSeconds}\``,
`- Failed steps: **${failedSteps.length}**`,
`- Run: ${process.env.RUN_URL}`,
"",
...failedSection,
"",
summary,
].join("\n");
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find(
(c) => c.user?.type === "Bot" && c.body?.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
core.info(`Updated existing UX smoke comment: ${existing.id}`);
} else {
const created = await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
core.info(`Created UX smoke comment: ${created.data.id}`);
}
loadtest-report:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install poetry
- run: poetry install --no-interaction
- run: poetry run python scripts/loadtest.py --dry-run --base-url http://localhost:3301 --requests 300 --concurrency 20 --history-out ../artifacts/loadtest-history.jsonl --target-success-rate 0.98 --target-p95-ms 1000 --no-fail-on-alert
- run: poetry run python scripts/loadtest.py --dry-run --base-url http://localhost:3301 --requests 600 --concurrency 30 --out ../artifacts/loadtest-report.json --history-out ../artifacts/loadtest-history.jsonl --trend-out ../artifacts/loadtest-trend.md --history-window 30 --target-success-rate 0.98 --target-p95-ms 1000 --no-fail-on-alert
- uses: actions/upload-artifact@v4
with:
name: loadtest-report
path: |
artifacts/loadtest-report.json
artifacts/loadtest-history.jsonl
artifacts/loadtest-trend.md