feature: /api/v1/runs/{run_id}/export 按照需求导出测试结果

This commit is contained in:
baozaotumao2025
2026-07-18 23:49:41 +08:00
parent c57ec67fe3
commit e980f1a349
8 changed files with 245 additions and 106 deletions
+13 -3
View File
@@ -78,8 +78,9 @@ Swagger 也可直接测试:打开 `/docs` 后,点击右上角 **Authorize**
6. `GET /api/v1/runs`
7. `GET /api/v1/runs/{run_id}`
8. `GET /api/v1/runs/{run_id}/results`
9. `GET /api/v1/reports`
10. `GET /api/v1/reports/{run_id}`
9. `GET /api/v1/runs/{run_id}/export`
10. `GET /api/v1/reports`
11. `GET /api/v1/reports/{run_id}`
创建运行的网络重试应复用同一个 `Idempotency-Key` 请求头;同一键与同一请求只会创建一个运行。
@@ -105,7 +106,16 @@ curl -X POST http://127.0.0.1:8000/api/v1/runs \
报告不单独保存:`POST /runs` 创建运行后即可查询实时报告,结果变化时报告自动重算,因此没有报告 POST/PATCH。删除终态 run 会同时删除其结果,之后对应报告返回 404。
运行结束后可将详细结果导出为 Markdown
运行结束后可通过 API 将详细结果下载为 Markdown
```bash
curl -OJ -H 'Authorization: Bearer <access_token>' \
'http://127.0.0.1:8000/api/v1/runs/42/export?execution_status=completed&verdict=fail'
```
不传查询参数时导出全部样例。`execution_status` 接受 `completed|error``verdict` 接受 `pass|fail|needs_human_review|judge_format_error|none`;运行不存在返回 404,尚未结束返回 409,非法过滤值返回 422。
服务器命令行也可导出:
```bash
uv run python scripts/export_run.py --run-id 42