官方更新 GitHub Changelog Fri, 18 Sep 2026 正文 ok 145 words

通过 REST API 管理代码覆盖率规则集条件

英文标题:Manage the code coverage ruleset condition with the REST API

GitHub 现已支持通过正式发布的 REST API 管理仓库规则集中的“Restrict code coverage”选项,此前该功能仅可在网页界面中配置。该规则可按行覆盖率强制执行最低代码覆盖率百分比,或为拉取请求设置可接受的最大覆盖率下降幅度。开发者可通过 API 以编程方式创建、更新和读取该规则,从而在多个仓库或基础设施即代码工作流中统一管理覆盖率要求。该功能要求启用 GitHub Code Quality 并配置代码覆盖率上传,适用于 GitHub Enterprise Cloud 和 GitHub Team,但不支持 GitHub Enterprise Server。
打开原文相关 2 · 机会 5
media16.2 KB media98.1 KB media25.6 KB

中文

现在,除现有的 UI 支持外,你还可以通过正式发布的 REST API 管理仓库规则集中的 Restrict code coverage 选项。

该规则集支持你基于行覆盖率强制执行最低代码覆盖率百分比,或者为拉取请求设置可容忍的最大覆盖率下降幅度。此前,配置这项规则必须使用网页界面。现在,你可以通过编程方式创建、更新和读取该规则集选项,从而更轻松地在多个仓库中一致地管理代码覆盖率要求,或将其纳入现有的基础设施即代码工作流。

要使用该规则,你的仓库必须启用 GitHub Code Quality,并已配置代码覆盖率上传。该功能适用于 GitHub Enterprise Cloud 和 GitHub Team,包括具备数据驻留功能的 GitHub Enterprise Cloud。GitHub Enterprise Server 不支持该功能。

了解更多关于规则集可用规则以及规则 REST API 端点的信息。

社交图片

English / 原文

You can now use the generally available REST API to manage the Restrict code coverage repository ruleset option, in addition to the existing UI support.

This ruleset lets you enforce a minimum code coverage percentage based on line coverage or set a maximum tolerable coverage drop for a pull request. Previously, configuring this rule required using the web interface. Now you can create, update, and read this ruleset option programmatically, making it easier to manage code coverage requirements consistently across many repositories or as part of your existing infrastructure-as-code workflows.

To use this rule, your repository must have GitHub Code Quality enabled and code coverage uploads configured. It’s available on GitHub Enterprise Cloud and GitHub Team, including GitHub Enterprise Cloud with data residency. It isn’t available on GitHub Enterprise Server.

Learn more about available rules for rulesets and the REST API endpoints for rules.

social