You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intro: 'An AI-powered agent can analyze your repository and generate a working code coverage workflow, so you can start tracking test coverage without manually authoring CI configuration.'
5
+
versions:
6
+
feature: code-quality
7
+
product: '{% data reusables.gated-features.code-quality-availability %}'
8
+
contentType: concepts
9
+
category:
10
+
- Improve code quality
11
+
---
12
+
13
+
When you use automatic setup for code coverage, an AI-powered agent analyzes your repository, identifies your test framework, and opens a pull request with a coverage workflow ready for review.
14
+
15
+
**There is no additional cost for using this feature.**
16
+
17
+
## How the agent works
18
+
19
+
The agent works in three phases:
20
+
21
+
1.**Discovery:** The agent reads your CI configuration, documentation, and build files to understand your project structure and identify your test framework.
22
+
1.**Execution:** The agent installs dependencies, builds the project, and runs your tests with coverage enabled. If coverage tooling is not already configured, the agent adds it to your project configuration (for example, `vitest.config.ts` or `jest.config.js`).
23
+
1.**Workflow integration:** If the agent produces a valid coverage report, it checks whether your repository already has a {% data variables.product.prodname_actions %} workflow that runs tests on pull requests. If so, the agent augments that workflow with a coverage upload step. If not, it creates a new workflow file and opens a pull request.
24
+
25
+
## When the agent stops
26
+
27
+
The agent may stop before opening a pull request in the following situations:
28
+
29
+
***No tests found.** The agent couldn't find tests to instrument, so there's nothing to generate coverage for.
30
+
***Can't reproduce the build.** Missing private registries, proprietary SDKs, or system dependencies prevent the agent from verifying the test suite.
31
+
32
+
If the agent stops or produces unexpected results, you can review the agent's session log for details. Navigate to the **Tasks** tab in your repository to find the session associated with the workflow generation attempt.
33
+
***Unsupported coverage report conversion.** The agent won't reconstruct Cobertura XML from reports that only expose aggregated counters. For example, JaCoCo XML does not contain enough line and branch structure for a trustworthy Cobertura upload, so JVM projects that only produce JaCoCo XML may need manual setup instead.
34
+
## Pull request outcomes
35
+
36
+
> [!NOTE]
37
+
> The agent opens the pull request immediately with an initial planning commit that contains no code changes. The actual implementation commit typically arrives a few minutes later. If the pull request initially shows 0 changed files, wait a few minutes and refresh the page.
38
+
39
+
If the agent successfully opens a pull request, the pull request may be in one of these states:
40
+
41
+
***Mergeable as-is:** The workflow completes successfully in CI and coverage uploads correctly.
42
+
***Ready to iterate:** The workflow runs but requires adjustments (for example, missing secrets, self-hosted runner configuration, or path differences between local verification and CI).
43
+
***Useful as a reference:** Maintainers may prefer to configure coverage themselves, using the agent's pull request as a starting point for the build and test commands it discovered.
Copy file name to clipboardExpand all lines: content/code-security/how-tos/maintain-quality-code/enable-code-quality.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,5 +59,5 @@ If you're rolling out the feature across many teams, we recommend you pilot on a
59
59
60
60
## Next steps
61
61
62
-
***Add code coverage:** Upload reported code coverage from your test suite to see coverage results directly on pull requests. See [AUTOTITLE](/code-security/how-tos/maintain-quality-code/set-up-code-coverage).
62
+
***Add code coverage:** Upload reported code coverage from your test suite to see coverage results directly on pull requests. {% data reusables.code-quality.workflow-generation %}
63
63
***For your organization:** Understand the code health of your repositories at a glance. See [AUTOTITLE](/code-security/how-tos/maintain-quality-code/explore-code-quality).
Copy file name to clipboardExpand all lines: content/code-security/how-tos/maintain-quality-code/set-up-code-coverage.md
+44-4Lines changed: 44 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,55 @@ category:
14
14
- Improve code quality
15
15
---
16
16
17
+
You can set up code coverage for your repository in two ways:
18
+
19
+
***Automatic setup:** Use the AI-powered agent to generate a workflow automatically. Choose this option if:
20
+
* You want to get started quickly without writing YAML configuration.
21
+
* Your project uses common test frameworks and build patterns.
22
+
* You're comfortable iterating on an AI-generated workflow.
23
+
***Manual setup:** Configure your CI workflow yourself. Choose this option if:
24
+
* You need precise control over the coverage process.
25
+
* You have complex CI requirements (such as private registries or custom build steps).
26
+
* You want to understand exactly how coverage is configured.
27
+
28
+
## Automatic setup
29
+
30
+
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.
31
+
32
+
> [!NOTE]
33
+
> Automatic setup uses AI to generate the workflow file. There is no additional cost for using this feature.
34
+
35
+
### Prerequisites for automatic setup
36
+
37
+
* {% data variables.product.prodname_code_quality_short %} is enabled for your repository. See [AUTOTITLE](/code-security/how-tos/maintain-quality-code/enable-code-quality).
38
+
* Your repository has an existing test suite.
39
+
40
+
### Generating a coverage workflow automatically
41
+
42
+
{% data reusables.repositories.navigate-to-repo %}
43
+
{% data reusables.repositories.sidebar-settings %}
44
+
1. In the sidebar, under "Security", click **{% data variables.code-quality.code_quality_ui_settings %}** to display the "{% data variables.code-quality.code_quality_ui %}" page.
45
+
1. In the "Code coverage analysis" section, click the **Setup** dropdown box.
46
+
1. In the list, select **Generate workflow with AI**. Wait for the agent to analyze your repository. The agent opens a draft pull request and posts a checklist of the steps it is working through.
47
+
1. To review the pull request, click **Review pull request**.
48
+
Review the pull request once the agent completes its work. The pull request description summarizes the changes, including any project configuration updates, workflow file changes, and coverage output settings.
49
+
1. If the workflow runs successfully in CI and coverage uploads correctly, merge the pull request.
50
+
51
+
If the workflow needs adjustments, see [AUTOTITLE](/code-security/concepts/code-quality/automatic-code-coverage-setup) for guidance on the different outcomes and how to iterate.
52
+
53
+
For more information about how the agent works and what to expect, see [AUTOTITLE](/code-security/concepts/code-quality/automatic-code-coverage-setup).
54
+
55
+
## Manual setup
56
+
17
57
Built-in code coverage lets you track how thoroughly your tests exercise your code, without adding a third-party service to your toolchain or budget. In the following procedures, you will generate a Cobertura XML coverage report from your test suite, upload it to {% data variables.product.github %}, and view the coverage results on your pull requests.
18
58
19
-
## Prerequisites
59
+
###Prerequisites for manual setup
20
60
21
61
* {% data variables.product.prodname_code_quality_short %} is enabled for your repository.
22
62
* Your repository has a test suite that runs in {% data variables.product.prodname_actions %}.
23
63
* Your test framework can produce a coverage report in **Cobertura XML** format.
24
64
25
-
## Step 1: Generate a Cobertura XML coverage report
65
+
###Step 1: Generate a Cobertura XML coverage report
26
66
27
67
Configure your test framework to output a coverage report in the Cobertura XML format. Code coverage works with any programming language that can produce this format.
28
68
@@ -40,7 +80,7 @@ Configure your test framework to output a coverage report in the Cobertura XML f
40
80
> [!TIP]
41
81
> If your framework isn't listed above, check its documentation for Cobertura output support. Many tools either support it directly or can convert to Cobertura XML from other formats.
42
82
43
-
## Step 2: Upload the coverage report
83
+
###Step 2: Upload the coverage report
44
84
45
85
After your tests generate a Cobertura XML report, upload it to {% data variables.product.github %} so coverage results appear on pull requests.
46
86
@@ -117,7 +157,7 @@ jobs:
117
157
label: code-coverage/pytest
118
158
```
119
159
120
-
## Step 3: View coverage results on pull requests
160
+
### Step 3: View coverage results on pull requests
121
161
122
162
1. Open a pull request (or push to an existing one) that triggers the workflow you configured.
123
163
1. After the workflow completes, look for a comment from `{% data variables.code-quality.pr_commenter %}` on the pull request. The comment includes:
Copy file name to clipboardExpand all lines: content/code-security/responsible-use/security-and-quality-ai-features.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ GitHub's security and quality platform includes several AI-powered capabilities
40
40
***Copilot Autofix for code scanning**: Automatically generates fix suggestions for CodeQL alerts on pull requests and the default branch.
41
41
***Generic secret detection**: Uses a model to identify unstructured secrets in source code that deterministic pattern matching cannot find.
42
42
***Custom pattern regex generator**: Uses AI to generate regular expressions for custom secret scanning patterns from natural language descriptions.
43
-
***GitHub Code Quality**: Surfaces code quality issues and offers LLM-powered fix suggestions on pull requests and the default branch.
43
+
***GitHub Code Quality**: Surfaces code quality issues and offers LLM-powered fix suggestions on pull requests and the default branch. Also provides AI-powered automatic generation of code coverage workflows.
44
44
45
45
Copilot Autofix is an expansion of code scanning that provides users with targeted recommendations to help them fix code scanning alerts, avoiding the introduction of new security vulnerabilities. Potential fixes are generated automatically by large language models (LLMs) using data from the codebase and from code scanning analysis. Copilot Autofix is available for CodeQL analysis and does not require a GitHub Copilot subscription.
46
46
@@ -50,7 +50,7 @@ Secret scanning's generic secret detection is an AI-powered expansion of secret
50
50
51
51
Secret scanning's custom pattern regular expression generator makes it possible to define custom secret scanning patterns without knowledge of regular expressions. Users input a natural language description of what they want to detect, along with optional example strings, and the generator produces up to three candidate regular expressions. These patterns can then be validated via the dry-run mechanism before being deployed as custom patterns. The regular expression generator does not require a GitHub Copilot subscription.
52
52
53
-
GitHub Code Quality helps users improve code reliability, maintainability, and overall project health by surfacing actionable feedback and offering automatic fixes for findings in pull requests and on the default branch. When Code Quality is enabled, two types of analysis run: CodeQL quality queries identify problems with the maintainability, reliability, or style of code, and LLM-powered analysis provides additional insights beyond what deterministic engines can find. When a quality issue is detected, Copilot Autofix suggests a relevant fix. On pull requests, results are displayed as comments left by the `github-code-quality` bot. On the default branch, LLM-powered findings are displayed in the **AI findings** dashboard under the **{% octicon "shield" aria-hidden="true" aria-label="shield" %} {% ifversion security-and-quality-tab %}Security and quality{% else %}Security{% endif %}** tab.
53
+
GitHub Code Quality helps users improve code reliability, maintainability, and overall project health by surfacing actionable feedback and offering automatic fixes for findings in pull requests and on the default branch. When Code Quality is enabled, two types of analysis run: CodeQL quality queries identify problems with the maintainability, reliability, or style of code, and LLM-powered analysis provides additional insights beyond what deterministic engines can find. When a quality issue is detected, Copilot Autofix suggests a relevant fix. On pull requests, results are displayed as comments left by the `github-code-quality` bot. On the default branch, LLM-powered findings are displayed in the **AI findings** dashboard under the **{% octicon "shield" aria-hidden="true" aria-label="shield" %} {% ifversion security-and-quality-tab %}Security and quality{% else %}Security{% endif %}** tab. Additionally, Code Quality can automatically generate a code coverage CI workflow for your repository using an AI-powered agent, reducing the manual effort required to set up coverage tracking.
54
54
55
55
The primary supported language for GitHub Code Security AI features is English.
You can use the automatic setup option to generate a workflow with an AI-powered agent, or configure your workflow manually. See [AUTOTITLE](/code-security/how-tos/maintain-quality-code/set-up-code-coverage).
0 commit comments