Skip to content

[自动合并 P1-1] 开启仓库级 auto-merge 并纳入期望状态对账 #82

Description

@randypanding

目标

让所有受管仓库的仓库级 allow_auto_merge = true 真正开启,并纳入 expected-state.json 期望状态与 drift-check.sh 漂移对账。这是"有人按 merge 按钮"的第一步替代——auto-merge 是仓库 setting 而非 ruleset,最容易静默漂移,必须机器对账。

背景(源自 #81 §2.1)

GOVERNANCE.yaml BP-4 的 intent 已声明 "auto-merge 开",但现状只有 repo_baseline.squash_only / delete_branch_on_merge 进了期望状态对账,allow_auto_merge 没有被声明、没有被对账。ruleset 管不到这个开关,它一掉(建仓遗漏、UI 误点、API 变更)auto-merge 全链路就静默死掉,而没有人会发现。

涉及文件

  • governance/expected-state.jsonrepo_baseline 段)
  • governance/drift-check.sh(repo settings 对账段)
  • governance/apply.sh(step5 仓库基线幂等修复)
  • governance/REPOS.yaml(如需标记豁免仓)
  • governance/GOVERNANCE.yaml(BP-4 的 platform/verify 声明保持同步)

执行步骤

  1. expected-state.jsonrepo_baseline 增加 "allow_auto_merge": true
  2. drift-check.sh 增加 repo settings 对账:遍历 REPOS.yaml 全部受管仓,用 gh api repos/{owner}/{repo} --jq .allow_auto_merge 断言为 true,漂移则按现有通道开 issue(复用 GM-1 的漂移 issue 机制)。
  3. apply.sh step5 增加幂等修复:gh api -X PATCH repos/{owner}/{repo} -f allow_auto_merge=true
  4. 对现有全部受管仓跑一次 apply.sh,把现状补齐为 true。
  5. 同步 GOVERNANCE.yaml BP-4 的 verify 声明(drift-check 覆盖 repo settings)。

验收标准

  • 所有受管仓 allow_auto_merge == truegh api 逐仓断言)。
  • 手动把任一仓关掉后,1 小时内 drift-check 报漂移开 issue;跑 apply.sh 后恢复;再跑 drift-check 该 issue 按既有机制自动关闭。
  • gate 的 JSON 校验通过(expected-state.json 为合法 JSON 对象)。

测试方法(预先指定)

T1 漂移注入测试(核心,负向)

  1. 选定测试仓 Cloudbird-Software/Use-up-Plan(非关键路径仓),记录当前 allow_auto_merge 值(应为 true)。
  2. 手动关闭:gh api -X PATCH repos/Cloudbird-Software/Use-up-Plan -F allow_auto_merge=false
  3. 手动触发 governance-drift workflow(gh workflow run),等其完成。
  4. 断言:workflow 产生一条标题含 Use-up-Plan 且内容指明 allow_auto_merge 漂移的 issue(gh issue list --search "Use-up-Plan in:title")。
  5. 执行修复:bash governance/apply.sh(或单仓 patch),再次触发 drift-check。
  6. 断言:漂移 issue 被自动关闭,gh api repos/Cloudbird-Software/Use-up-Plan --jq .allow_auto_merge 返回 true

T2 全量对账测试(正向)

  • 对 REPOS.yaml 中每个仓执行 gh api repos/Cloudbird-Software/{name} --jq '.name + " " + (.allow_auto_merge|tostring)',断言全部输出 true。任一 false 即不通过。

T3 回归

  • .github 仓提交仅修改 expected-state.json 的 PR,断言 gate 全绿(JSON 校验段不红)。

依赖

无。Phase 1 首卡,所有后续卡的前提。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-merge自动合并计划(#81)工作卡governance治理体系相关rulesetRuleset 配置相关

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions