【架构优化】拆分 runner.collectTaskOutputs 的输出文件读取、补丁目录推导与补丁采集
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 22/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
现状问题
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/。
- Linguagem predominante
- Go
- Estrelas
- 141
- Forks
- 28
- Merge médio
- 1d 15h
- PRs com merge (30d)
- 113
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Tencent/LoopForge
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: 官方镜像未安装 wecom-cli,企业微信通知报「通知服务未安装 wecom-cli」Talvez já em andamento @newexploreor assumiu há 1 dia. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Tencent/LoopForge#156 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
【架构优化】合并 gitwork/workbranch.go 中 push/pull 重复的默认提交身份注入为 withFallbackIdentityTalvez já em andamento @fx-kurumi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 40/100
Mantenedores costumam responder em até 1 dia
-
【架构优化】从 runtime.installNPMCLI 中拆出 npm 参数拼装 npmCLIInstallArgs 与安装结果启用 activateNPMStageTalvez já em andamento @fx-kurumi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 30/100
Mantenedores costumam responder em até 1 dia
Todas as issues de Tencent/LoopForge
Issues semelhantes
-
team:library-maintainers
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
padok-team/burrito#1208 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
bazel-contrib/rules_go#4784 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
Уязвимые компоненты в GoAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
POSIdev-community/aictl#40 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 62/100
prime-radiant-inc/evener#6306 ·
Mantenedores costumam responder em até 1 dia