Skip to content

Commit 23f3fc7

Browse files
joshhaleCopilot
andauthored
Document required checks for code coverage uploads (#63566)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Copilot-Session: 1a963a64-6e69-44a5-9f76-aa6d086f4af3
1 parent 515bcde commit 23f3fc7

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎content/code-security/how-tos/maintain-quality-code/restrict-code-coverage.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Setting code coverage thresholds for pull requests
33
shortTitle: Set coverage thresholds
4-
intro: Protect your code coverage by automatically blocking pull requests that fall below the coverage levels your team requires.
4+
intro: Prevent pull requests from being merged when uploaded code coverage falls below the levels your team requires.
55
allowTitleToDifferFromFilename: true
66
versions:
77
feature: code-quality
@@ -14,14 +14,19 @@ category:
1414
> [!NOTE]
1515
> This feature is in {% data variables.release-phases.public_preview %} and subject to change.
1616
17+
## How the code coverage rule works
18+
19+
The **Restrict code coverage** rule evaluates uploaded line coverage data against the configured thresholds. It does not wait for coverage uploads to complete.
20+
21+
To prevent a pull request from being merged before all expected coverage results are available, make each status check associated with an expected coverage upload a required status check. This includes coverage uploaded from separate jobs or workflows.
22+
23+
For more information about line coverage, see [AUTOTITLE](/code-security/reference/code-quality/code-coverage).
24+
1725
## Prerequisites
1826

1927
* {% data variables.product.prodname_code_quality %} is enabled on the repository.
2028
* Code coverage data is uploaded to {% data variables.product.github %} for the pull request branch. See [AUTOTITLE](/code-security/how-tos/maintain-quality-code/set-up-code-coverage).
2129

22-
> [!NOTE]
23-
> Coverage thresholds are evaluated against **line coverage**. See [AUTOTITLE](/code-security/reference/code-quality/code-coverage).
24-
2530
## Creating a coverage threshold rule
2631

2732
{% data reusables.repositories.navigate-to-repo %}

‎content/code-security/how-tos/maintain-quality-code/set-up-code-coverage.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ You can set up code coverage for your repository in two ways:
2525
* You have complex CI requirements (such as private registries or custom build steps).
2626
* You want to understand exactly how coverage is configured.
2727

28+
> [!IMPORTANT]
29+
> If you use the **Restrict code coverage** rule, make each status check associated with an expected coverage upload a required status check. For more information, see [How the code coverage rule works](/code-security/how-tos/maintain-quality-code/restrict-code-coverage#how-the-code-coverage-rule-works).
30+
2831
## Automatic setup
2932

3033
You can use the automatic setup option to generate a working code coverage workflow without manually authoring CI configuration. An agent analyzes your repository, identifies your test framework, and opens a pull request with a coverage workflow ready for review.

‎content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ For more information, see [AUTOTITLE](/code-security/concepts/code-quality/code-
254254
255255
If your repository has {% data variables.product.prodname_code_quality %} enabled and code coverage data is being uploaded, you can use rulesets to prevent pull requests from being merged based on code coverage thresholds. For more information about uploading coverage data, see [AUTOTITLE](/code-security/how-tos/maintain-quality-code/set-up-code-coverage).
256256

257+
The rule evaluates only coverage data that has already been uploaded and does not wait for coverage uploads to complete. To ensure that all expected coverage results are evaluated before a pull request can be merged, make each status check associated with an expected coverage upload a required status check.
258+
257259
This rule blocks a pull request from being merged when either of two code coverage thresholds is not met:
258260

259261
* **Minimum line coverage percentage**: the aggregated line coverage for the pull request branch is below the configured percentage.

0 commit comments

Comments
 (0)