Skip to content

ci: enable required status checks on main branch protection #4864

@yiliang114

Description

@yiliang114

Problem

PR #4798 was merged into main with all CI checks failing (Lint ❌, Test ubuntu/macos/windows ❌), introducing a TypeScript syntax error that broke tsc --build on main. The root cause was a missing }); in a test file, which the PR's own CI had already caught — but there was no branch protection rule preventing the merge.

Impact

Proposal

Enable "Require status checks to pass before merging" in the branch protection rules for main. The following checks should be marked as required:

Check Reason
Lint Catches syntax errors, formatting, eslint violations
Test (ubuntu-latest, Node 22.x) Core test suite
Test (macos-latest, Node 22.x) Platform-specific behavior
Test (windows-latest, Node 22.x) Platform-specific behavior

Bypass Strategy

开启 required checks 后,仍然可以保留紧急情况下的 bypass 能力:

Scenario Approach
Hotfix that needs to skip CI Grant core maintainers bypass permission — GitHub shows a warning "merging without required checks" on merge
Doc-only / typo changes Admin bypass; or configure paths-ignore in workflows so CI auto-skips (skip status counts as pass)
Bot auto-merge (e.g. release sync) Add bot account to the bypass list

Recommended config: enable required checks + grant bypass permission to core maintainers only. Normal PRs must have green CI to merge, but emergencies can still be handled with human judgment.

Action Items

This is a settings change in GitHub → Settings → Branches → Branch protection rules for main. It requires admin access to the repository.

  1. Enable "Require status checks to pass before merging" with the four checks above
  2. Add core maintainer team to bypass list (NOT "Do not allow bypassing" — keep the escape hatch)
  3. Optionally enable "Require branches to be up to date before merging"
中文说明

问题

PR #4798CI 全部失败(Lint ❌,Test ubuntu/macos/windows ❌)的情况下被合入 main,引入了一个 TypeScript 语法错误,导致 tsc --build 失败,main 分支 CI 全线挂掉。该 PR 自身的 CI 已经检测到了这个错误,但由于没有分支保护规则阻止合并,仍然被合入了。

影响

建议

main 分支保护规则中启用 "Require status checks to pass before merging",将以下 check 设为必需:

Check 用途
Lint 语法错误、格式、eslint 检查
Test (ubuntu-latest, Node 22.x) 核心测试
Test (macos-latest, Node 22.x) 平台兼容性
Test (windows-latest, Node 22.x) 平台兼容性

Bypass 策略

开启 required checks 后,仍然可以保留紧急情况下的绕过能力:

场景 方案
紧急 hotfix 需要跳过 CI 给核心 maintainer 设 bypass 权限,合并时 GitHub 会提示警告
纯文档/typo 改动 Admin bypass;或在 workflow 中配 paths-ignore 让 CI 自动 skip
Bot 自动合并(如 release sync) 把 bot 账号加到 bypass list

推荐配置: 开启 required checks + 仅给核心 maintainer 保留 bypass 权限。常规 PR 必须 CI 绿灯才能合入,紧急情况仍可人工判断后绕过。

操作步骤

需要仓库 admin 在 GitHub → Settings → Branches → Branch protection rules 中操作:

  1. 启用 "Require status checks to pass before merging",勾选上述四个 check
  2. 将核心 maintainer 团队加入 bypass list(不要勾选 "Do not allow bypassing"——保留紧急通道)
  3. 可选:启用 "Require branches to be up to date before merging"

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/developmentDevelopment experiencepriority/P2Medium - Moderately impactful, noticeable problemscope/ci-cdContinuous integration/deploymenttype/enhancementNon-bug improvement or optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions