Closed
feat(actions): 支持 获取仓库所有的流水线的运行记录 API #445
aflyingtoAdd on Jul 9Closed at Jul 9
aflyingto
Jul 9 Comments:
Jul 9 Comments:
验证记录
- 当前版本: main @ d0ff6b3 (gc 0.7.0)
- 需求确认: GitCode API v8 提供
GET /api/v8/repos/{owner}/{repo}/actions/runs(流水线运行记录列表),OpenAPI 文档已抓取于本 issue body - gc 现状:
pkg/cmd/下无actions命令api/无 actions / pipeline / workflow runs 查询函数docs/COMMANDS.md无 actions 段api/client.goREST硬编码/api/v5,Actions API 在/api/v8,需用RawREST(rawURL对/api/前缀端点原样保留版本号)走 v8 路径
- 重复检查: 无 merged PR,
origin/main无对应代码,verify-remote-factspassed - 结论: 需求有效且未实现,进入开发
实现计划
- API 层:
api/queries_actions.go—WorkflowRun/WorkflowRunsResponse/ActionsListRunsOptions类型 +ListActionsRuns函数(用RawREST走 v8,query params 经url.Values) - 命令层:
pkg/cmd/actions/actions.go(actions父命令)+pkg/cmd/actions/run/run.go(run父命令)+pkg/cmd/actions/run/list/list.go(run list叶子,#445) - 测试:
api/queries_actions_test.go(roundtrip mock v8 端点)+pkg/cmd/actions/run/list/list_test.go - 输出: 表格 +
--json(agent-friendly,只读命令优先支持 JSON)


背景
GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。
API 摘要
GET/api/v8/repos/{owner}/{repo}/actions/runsget_api_v8_repos_{owner}_{repo}_actions_runspipeline-v8falseRequest Parameters
ownerrepoaccess_tokeneventstatusbranchexecutorpull_request_idworkflow_idworkflow_nameper_pagepagestartTimeendTimeRequest Body
无。
Responses
200
application/jsonapplication/json schema
{ "type": "object", "properties": { "total_count": { "type": "integer", "description": "总数量" }, "workflow_runs": { "type": "array", "items": { "type": "object", "properties": { "workflow_run_id": { "type": "string", "description": "流水线运行id" }, "workflow_id": { "type": "string", "description": "流水线id" }, "workflow_name": { "type": "string" }, "file_path": { "type": "string" }, "title": { "type": "string" }, "status": { "type": "string", "description": "运行状态,COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)" }, "event": { "type": "string", "description": "触发事件类型,MR(mr事件),Push(推送事件),Manual(手动触发)" }, "run_number": { "type": "integer" }, "head_branch": { "type": "string" }, "head_sha": { "type": "string" }, "actor": { "type": "object", "properties": { "id": { "type": "string" }, "object_id": { "type": "string" }, "login": { "type": "string" }, "name": { "type": "string" } }, "required": [ "id", "object_id", "login", "name" ], "description": "触发人" }, "start_time": { "type": "integer", "description": "开始时间戳" }, "end_time": { "type": "integer", "description": "结束时间戳" }, "pause_time": { "type": "integer", "description": "暂停时间" } }, "required": [ "workflow_run_id", "workflow_id", "workflow_name", "file_path", "title", "status", "event", "run_number", "head_branch", "head_sha", "actor", "start_time", "end_time", "pause_time" ] }, "description": "流水线运行记录" } }, "required": [ "total_count", "workflow_runs" ] }原始 OpenAPI Operation
{ "deprecated": false, "description": "", "operationId": "get_api_v8_repos_{owner}_{repo}_actions_runs", "tags": [ "pipeline-v8" ], "parameters": [ { "name": "owner", "in": "path", "description": "仓库所属空间地址(组织或个人的地址path)", "required": true, "schema": { "type": "string" } }, { "name": "repo", "in": "path", "description": "仓库路径(path)", "required": true, "schema": { "type": "string" } }, { "name": "access_token", "in": "query", "description": "用户授权码", "required": false, "schema": { "type": "string" } }, { "name": "event", "in": "query", "description": "触发事件类型,MR(mr事件),Push(推送事件),Manual(手动触发)", "required": false, "schema": { "type": "string" } }, { "name": "status", "in": "query", "description": "运行状态,COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)", "required": false, "schema": { "type": "string" } }, { "name": "branch", "in": "query", "description": "分支过滤", "required": false, "schema": { "type": "string" } }, { "name": "executor", "in": "query", "description": "触发人用户名", "required": false, "schema": { "type": "string" } }, { "name": "pull_request_id", "in": "query", "description": "PR的编号", "required": false, "schema": { "type": "string" } }, { "name": "workflow_id", "in": "query", "description": "流水线id", "required": false, "schema": { "type": "string" } }, { "name": "workflow_name", "in": "query", "description": "流水线名称", "required": false, "schema": { "type": "string" } }, { "name": "per_page", "in": "query", "description": "每页的数量,最大为 100,默认 20", "required": false, "schema": { "type": "string" } }, { "name": "page", "in": "query", "description": "当前的页码:默认为 1", "required": false, "schema": { "type": "string" } }, { "name": "startTime", "in": "query", "description": "开始时间,格式时间戳", "required": false, "schema": { "type": "number" } }, { "name": "endTime", "in": "query", "description": "结束时间,格式时间戳", "required": false, "schema": { "type": "number" } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "total_count": { "type": "integer", "description": "总数量" }, "workflow_runs": { "type": "array", "items": { "type": "object", "properties": { "workflow_run_id": { "type": "string", "description": "流水线运行id" }, "workflow_id": { "type": "string", "description": "流水线id" }, "workflow_name": { "type": "string" }, "file_path": { "type": "string" }, "title": { "type": "string" }, "status": { "type": "string", "description": "运行状态,COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)" }, "event": { "type": "string", "description": "触发事件类型,MR(mr事件),Push(推送事件),Manual(手动触发)" }, "run_number": { "type": "integer" }, "head_branch": { "type": "string" }, "head_sha": { "type": "string" }, "actor": { "type": "object", "properties": { "id": { "type": "string" }, "object_id": { "type": "string" }, "login": { "type": "string" }, "name": { "type": "string" } }, "required": [ "id", "object_id", "login", "name" ], "description": "触发人" }, "start_time": { "type": "integer", "description": "开始时间戳" }, "end_time": { "type": "integer", "description": "结束时间戳" }, "pause_time": { "type": "integer", "description": "暂停时间" } }, "required": [ "workflow_run_id", "workflow_id", "workflow_name", "file_path", "title", "status", "event", "run_number", "head_branch", "head_sha", "actor", "start_time", "end_time", "pause_time" ] }, "description": "流水线运行记录" } }, "required": [ "total_count", "workflow_runs" ] } } }, "headers": {} } }, "security": [], "method": "get", "path": "/api/v8/repos/{owner}/{repo}/actions/runs", "servers": [ { "url": "https://api.gitcode.com", "description": "正式环境" } ], "securitySchemes": {}, "info": { "title": "GicodeOpenAPI", "description": "", "version": "1.0.0" }, "postman": { "name": "获取仓库所有的流水线的运行记录", "description": { "content": "", "type": "text/plain" }, "url": { "path": [ "api", "v8", "repos", ":owner", ":repo", "actions", "runs" ], "host": [ "{{baseUrl}}" ], "query": [ { "disabled": false, "description": { "content": "用户授权码", "type": "text/plain" }, "key": "access_token", "value": "" }, { "disabled": false, "description": { "content": "触发事件类型,MR(mr事件),Push(推送事件),Manual(手动触发)", "type": "text/plain" }, "key": "event", "value": "" }, { "disabled": false, "description": { "content": "运行状态,COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)", "type": "text/plain" }, "key": "status", "value": "" }, { "disabled": false, "description": { "content": "分支过滤", "type": "text/plain" }, "key": "branch", "value": "" }, { "disabled": false, "description": { "content": "触发人用户名", "type": "text/plain" }, "key": "executor", "value": "" }, { "disabled": false, "description": { "content": "PR的编号", "type": "text/plain" }, "key": "pull_request_id", "value": "" }, { "disabled": false, "description": { "content": "流水线id", "type": "text/plain" }, "key": "workflow_id", "value": "" }, { "disabled": false, "description": { "content": "流水线名称", "type": "text/plain" }, "key": "workflow_name", "value": "" }, { "disabled": false, "description": { "content": "每页的数量,最大为 100,默认 20", "type": "text/plain" }, "key": "per_page", "value": "" }, { "disabled": false, "description": { "content": "当前的页码:默认为 1", "type": "text/plain" }, "key": "page", "value": "" }, { "disabled": false, "description": { "content": "开始时间,格式时间戳", "type": "text/plain" }, "key": "startTime", "value": "" }, { "disabled": false, "description": { "content": "结束时间,格式时间戳", "type": "text/plain" }, "key": "endTime", "value": "" } ], "variable": [ { "disabled": false, "description": { "content": "(Required) 仓库所属空间地址(组织或个人的地址path)", "type": "text/plain" }, "type": "any", "value": "", "key": "owner" }, { "disabled": false, "description": { "content": "(Required) 仓库路径(path)", "type": "text/plain" }, "type": "any", "value": "", "key": "repo" } ] }, "header": [ { "key": "Accept", "value": "application/json" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。