【架构优化】从 githubCombinedChecks 中拆出 commit status/check runs 读取与整体状态汇总 githubChecksOverall
維護者通常 1 天內回覆
評估
研究方向
The work is confined to githubCombinedChecks in internal/httpapi/agent_tool_github.go, which should be split into githubCommitStatuses, githubCheckRuns and githubChecksOverall without changing URLs, warnings or outcome rules. Read that function and its caller githubPRStatus, then run go test ./internal/httpapi/ to get a baseline. Note that pull request #484 is already open against this issue, so check it before starting. Done means the existing tests pass and a new table-driven test covers githubChecksOverall.
由索引模型根據 Issue 內容生成。
描述
现状问题
internal/httpapi/agent_tool_github.go 中的 githubCombinedChecks 约 80 行,一个函数里依次做了三件事:
- 请求 commit status API、解析、追加结果和截断告警;
- 请求 check-runs API、解析(status/conclusion 取值)、追加结果和截断告警;
- 按
githubCheckOutcome汇总 overall,并在有告警时把 none/success 降级为 unknown。
两段读取结构几乎一样,又和汇总逻辑写在同一个函数里,读起来要来回对照;汇总规则只能通过 mock HTTP 间接测试。
重构方案
在同文件内拆出三个包级函数,githubCombinedChecks 只负责按顺序调用并拼接结果:
githubCommitStatuses(ctx, client, token, path, sha) ([]githubCheckSummary, []string):读取 commit status;githubCheckRuns(ctx, client, token, path, sha) ([]githubCheckSummary, []string):读取 check runs;githubChecksOverall(checks, warnings) string:汇总整体状态。
请求 URL、告警文案、状态取值、汇总规则全部原样保留。
影响范围
仅 internal/httpapi/agent_tool_github.go;githubCombinedChecks 签名及唯一调用方 githubPRStatus 不变,对外行为不变。
验证方式
- 新增
githubChecksOverall的表驱动单元测试(none / success / pending / failure / 有告警降级 unknown / 失败不被告警覆盖); - 现有
githubCombinedChecks相关测试保持通过; gofmt、go vet ./internal/httpapi/、go test ./internal/httpapi/。
- 主要語言
- Go
- 星號
- 141
- 分支
- 28
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 113
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Tencent/LoopForge 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
[Bug]: 官方镜像未安装 wecom-cli,企业微信通知报「通知服务未安装 wecom-cli」可能已有人在做 @newexploreor 於 1 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
Tencent/LoopForge#156 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
【架构优化】合并 gitwork/workbranch.go 中 push/pull 重复的默认提交身份注入为 withFallbackIdentity可能已有人在做 @fx-kurumi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 40/100
維護者通常 1 天內回覆
-
【架构优化】从 runtime.installNPMCLI 中拆出 npm 参数拼装 npmCLIInstallArgs 与安装结果启用 activateNPMStage可能已有人在做 @fx-kurumi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 30/100
維護者通常 1 天內回覆
查看 Tencent/LoopForge 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
bazel-contrib/rules_go#4784 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
POSIdev-community/aictl#40 ·
-
難度 2/5 1-3 小時 新手友好度 62/100
nebari-dev/nebari-infrastructure-core#774 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
oracle/terraform-provider-oci#2662 ·
-
bug needs-triage
難度 2/5 1-3 小時 新手友好度 62/100
valkey-io/valkey-operator#644 ·
維護者通常 3 天內回覆