【架构优化】从 githubCombinedChecks 中拆出 commit status/check runs 读取与整体状态汇总 githubChecksOverall

Ouverte
#483 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@fx-kurumi y travaille déjà.

Depuis le 13/11/2026.

  • #484 par @fx-kurumi — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
18/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
go
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

现状问题

internal/httpapi/agent_tool_github.go 中的 githubCombinedChecks 约 80 行,一个函数里依次做了三件事:

  1. 请求 commit status API、解析、追加结果和截断告警;
  2. 请求 check-runs API、解析(status/conclusion 取值)、追加结果和截断告警;
  3. 按 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/。
Langage dominant
Go
Étoiles
141
Forks
28
Merge moyen
1 j 15 h
PR mergées (30 j)
113

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Tencent/LoopForge

Toutes les issues de Tencent/LoopForge

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.