【架构优化】拆分 runner.collectTaskOutputs 的输出文件读取、补丁目录推导与补丁采集
维护者通常 1 天内回复
评估
调研方向
Work is confined to internal/runner/outputs.go, where collectTaskOutputs mixes file reading, patch-directory derivation and patch collection. The payload names no entry point beyond that function. Done means three helpers are extracted with unchanged behaviour, the existing TestCollectTaskOutputsReportsOnlyRegularFilesInsideWorkspace still passes, and new tests cover the extracted pieces. However, a linked pull request (#432) is already open, so the work is likely claimed.
由索引模型根据 Issue 内容生成。
描述
现状问题
internal/runner/outputs.go 的 collectTaskOutputs 约 50 行,在一个函数里串行做了三件互不相关的事:
- 逐个读取
OutputFiles(路径安全校验、Lstat 只认普通文件、超过maxArtifactUploadBytes记入TooLarge、读入Files); - 推导需要采集补丁清单的仓库目录(无仓库时为工作区根
"",否则为各仓库的safeRunnerRepoDir(WorkspaceDir)),并逐个调用gitwork.PatchInventory填Patches; - 检测前端工作区事实
Facts。
其中「仓库目录推导」是纯逻辑却埋在 I/O 循环里,无法单独测试;现有测试也只覆盖了第 1 步。
重构方案
仅在 internal/runner/outputs.go 内拆函数,不改逻辑:
readOutputFiles(workspace, rels) (files map[string]string, tooLarge []string):原第 1 段循环原样搬入;patchInventoryDirs(inv) []string:原目录推导原样搬入;collectPatchInventories(workspace, dirs) map[string]string:原补丁采集循环原样搬入;collectTaskOutputs只负责编排:恢复缺失输出 → 读文件 → 采补丁 → 采事实。
nil map / nil slice 的语义保持不变(没有文件时 Files/Patches 仍为 nil,JSON omitempty 输出不变)。
影响范围
仅 internal/runner/outputs.go(及新增测试文件),collectTaskOutputs 签名与三个调用方(daemon.go)不变,对外接口与行为不变。
验证方式
- 新增测试覆盖
patchInventoryDirs(无仓库 / 多仓库)、collectPatchInventories(真实 git 仓库有改动 / 无改动 / 非仓库目录)与readOutputFiles的 nil 语义; - 原有
TestCollectTaskOutputsReportsOnlyRegularFilesInsideWorkspace不改动且通过; gofmt、go vet ./internal/runner/、go test ./internal/runner/。
- 主要语言
- 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
-
team:library-maintainers
难度 2/5 1-3 小时 新手友好度 82/100
padok-team/burrito#1208 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
bazel-contrib/rules_go#4784 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 62/100
POSIdev-community/aictl#40 ·
-
难度 1/5 1 小时以内 新手友好度 62/100
prime-radiant-inc/evener#6306 ·
维护者通常 1 天内回复