Skip to content

Commit fb79ab3

Browse files
Add Code Coverage Data Collected page (#30830)
1 parent 4b18938 commit fb79ab3

File tree

5 files changed

+94
-18
lines changed

5 files changed

+94
-18
lines changed

config/_default/menus/main.en.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5133,6 +5133,11 @@ menu:
51335133
parent: code_coverage
51345134
identifier: code_coverage_setup
51355135
weight: 1
5136+
- name: Data Collected
5137+
url: code_coverage/data_collected/
5138+
parent: code_coverage
5139+
identifier: code_coverage_data_collected
5140+
weight: 2
51365141
- name: Quality Gates
51375142
url: quality_gates/
51385143
pre: ci

content/en/code_coverage/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ further_reading:
44
- link: "/code_coverage/setup"
55
tag: "Documentation"
66
text: "Set up Code Coverage"
7+
- link: "/code_coverage/data_collected"
8+
tag: "Documentation"
9+
text: "Learn what data is collected for Code Coverage"
710
algolia:
811
tags: ["code coverage"]
912
---
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Code Coverage Data Collected
3+
further_reading:
4+
- link: "/code_coverage"
5+
tag: "Documentation"
6+
text: "Code Coverage"
7+
- link: "/code_coverage/setup"
8+
tag: "Documentation"
9+
text: "Set up Code Coverage"
10+
---
11+
12+
{{< callout url="http://datadoghq.com/product-preview/code-coverage/" >}}
13+
Code Coverage is in Preview. This product replaces Test Optimization's <a href="https://docs.datadoghq.com/tests/code_coverage">code coverage</a> feature, which is being deprecated. Complete the form to request access for the new Code Coverage product.
14+
{{< /callout >}}
15+
16+
## Source Code Provider Integration
17+
18+
The exact data received by Datadog depends on your source code provider type:
19+
20+
{{< tabs >}}
21+
{{% tab "GitHub" %}}
22+
23+
Code Coverage relies on the following GitHub webhooks:
24+
* Pull request
25+
* Pull request review
26+
* Pull request review comment
27+
* Push
28+
29+
None of the webhooks include your source code content; they only include metadata about the pull request, such as title, description, author, labels, and commit SHAs.
30+
31+
See GitHub's [webhook events and payloads documentation][1] for a detailed description of the data sent by these webhooks.
32+
33+
[1]: https://docs.github.com/en/webhooks/webhook-events-and-payloads
34+
35+
{{% /tab %}}
36+
{{< /tabs >}}
37+
38+
By default, when synchronizing your repositories, Datadog doesn’t store the actual content of files in your repository, only the Git commit and tree objects.
39+
40+
See [Datadog Source Code Integration][1] for more information about how Datadog integrates with your source code provider.
41+
42+
## Code Coverage Report Upload
43+
44+
The `datadog-ci coverage upload` command sends the following data to Datadog:
45+
- **Coverage reports**: The report files, which contain the coverage data for your codebase. The data depends on the coverage tool and report format you are using, and normally includes file paths, line numbers, and coverage percentages.
46+
- **Git metadata**: Git repository URL, branch name, commit SHA, timestamp, author information, and list of file paths that were changed in the commit. You can disable Git metadata upload by adding `--skip-git-metadata-upload=1` to the command.
47+
- **Git diff summary**: List of file paths that were changed in the commit, along with the numbers of added and removed lines. You can disable Diff data upload by adding `--upload-git-diff=0` to the command.
48+
- **CI metadata**: Information about the CI environment, such as the CI provider, job ID, and pipeline ID.
49+
50+
No source code is uploaded to Datadog.
51+
52+
## Further reading
53+
54+
{{< partial name="whats-next/whats-next.html" >}}
55+
56+
[1]: /integrations/guide/source-code-integration

content/en/code_coverage/setup.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ further_reading:
44
- link: "/code_coverage"
55
tag: "Documentation"
66
text: "Code Coverage"
7+
- link: "/code_coverage/data_collected"
8+
tag: "Documentation"
9+
text: "Learn what data is collected for Code Coverage"
710
---
811

912
{{< callout url="http://datadoghq.com/product-preview/code-coverage/" >}}
@@ -41,28 +44,36 @@ The following webhooks are required:
4144
| Pull request review comment | Receive PR data updates. |
4245
| Push | Receive Git commit metadata. |
4346

47+
If everything is configured correctly, a green check mark is displayed in Datadog's [GitHub Integration][2] page:
48+
{{< img src="/code_coverage/github_app_success.png" alt="GitHub App integration success check" style="width:100%" >}}
49+
4450
<div class="alert alert-info">If you have a Datadog-managed Marketplace App or a custom app with default settings, the required permissions and webhooks are included.</div>
4551

4652
[1]: /integrations/github/#github-apps-1
53+
[2]: https://app.datadoghq.com/integrations/github/configuration
4754
{{% /tab %}}
4855
{{< /tabs >}}
4956

57+
See [Data Collected][1] for details on what data is collected from your source code provider.
58+
5059
## Data access permissions
5160

52-
If you are using [custom roles][1] rather than [Datadog-managed roles][2], be sure to enable the `Code Coverage Read` permission for the roles that need to view code coverage data.
61+
If you are using [custom roles][2] rather than [Datadog-managed roles][3], be sure to enable the `Code Coverage Read` permission for the roles that need to view code coverage data.
5362

54-
Navigate to [Roles settings][3], click `Edit` on the role you need, add the `Code Coverage Read` permission to the role, and save the changes.
63+
Navigate to [Roles settings][4], click `Edit` on the role you need, add the `Code Coverage Read` permission to the role, and save the changes.
5564

5665
## PR Gates
5766

5867
If you wish to gate on PR coverage, configure PR Gates rules in Datadog.
5968

60-
Navigate to [PR Gates rule creation][4] and configure a rule to gate on total or patch coverage.
69+
Navigate to [PR Gates rule creation][5] and configure a rule to gate on total or patch coverage.
6170

6271
## Upload code coverage reports
6372

6473
Update your CI pipeline to upload code coverage report files to Datadog. This involves installing and running the `datadog-ci` CLI in your CI environment.
6574

75+
See [Data Collected][6] for details on what data is collected during code coverage report upload.
76+
6677
### Supported coverage report formats
6778

6879
Datadog supports the following coverage data formats—expand for examples:
@@ -238,15 +249,15 @@ end_of_record
238249

239250
### Install the datadog-ci CLI
240251

241-
Install the [`datadog-ci`][5] CLI globally using `npm`:
252+
Install the [`datadog-ci`][7] CLI globally using `npm`:
242253

243254
{{< code-block lang="shell" >}}
244255
npm install -g @datadog/datadog-ci
245256
{{< /code-block >}}
246257

247258
#### Standalone binary
248259

249-
If installing Node.js in the CI is an issue, standalone binaries are provided with [Datadog CI releases][6]. Only _linux-x64_, _linux-arm64_, _darwin-x64_, _darwin-arm64_ (MacOS) and _win-x64_ (Windows) are supported. To install, run the following from your terminal:
260+
If installing Node.js in the CI is an issue, standalone binaries are provided with [Datadog CI releases][8]. Only _linux-x64_, _linux-arm64_, _darwin-x64_, _darwin-arm64_ (MacOS) and _win-x64_ (Windows) are supported. To install, run the following from your terminal:
250261

251262
{{< tabs >}}
252263
{{% tab "Linux" %}}
@@ -285,7 +296,7 @@ Start-Process -FilePath "./datadog-ci.exe" -ArgumentList version
285296

286297
### Uploading coverage reports
287298

288-
To upload your code coverage reports to Datadog, run the following command. Provide a valid [Datadog API key][7] (`DD_API_KEY`), and one or more file paths to either the coverage report files directly or directories containing them:
299+
To upload your code coverage reports to Datadog, run the following command. Provide a valid [Datadog API key][9] (`DD_API_KEY`), and one or more file paths to either the coverage report files directly or directories containing them:
289300

290301
{{< tabs >}}
291302
{{% tab "GitHub Actions" %}}
@@ -299,28 +310,29 @@ steps:
299310
DD_SITE: {{< region-param key="dd_site" >}}
300311
</code>
301312
</pre>
302-
[1]: https://docs.github.com/en/actions/learn-github-actions/expressions#always
303313
{{% /tab %}}
304314
{{< /tabs >}}
305315

306316
The command recursively searches the specified directories for supported coverage report files, so specifying the current directory (`.`) is usually sufficient.
307-
See the [`datadog-ci` documentation][8] for more details on the `datadog-ci coverage upload` command.
317+
See the [`datadog-ci` documentation][10] for more details on the `datadog-ci coverage upload` command.
308318

309319
Shortly after the code coverage report upload is finished, Datadog adds a PR comment with code coverage percentage values.
310-
You can also view your coverage data aggregated by pull request in the [Code Coverage page][9] in Datadog, with the ability to examine individual files and lines of code.
320+
You can also view your coverage data aggregated by pull request in the [Code Coverage page][11] in Datadog, with the ability to examine individual files and lines of code.
311321

312322
{{< img src="/code_coverage/pr_details.png" text="Code Coverage PR details page in Datadog" style="width:100%" >}}
313323

314324
## Further reading
315325

316326
{{< partial name="whats-next/whats-next.html" >}}
317327

318-
[1]: /account_management/rbac/permissions/#custom-roles
319-
[2]: /account_management/rbac/permissions/#managed-roles
320-
[3]: https://app.datadoghq.com/organization-settings/roles
321-
[4]: https://app.datadoghq.com/ci/pr-gates/rule/create
322-
[5]: https://www.npmjs.com/package/@datadog/datadog-ci
323-
[6]: https://github.com/DataDog/datadog-ci/releases
324-
[7]: https://app.datadoghq.com/organization-settings/api-keys
325-
[8]: https://github.com/DataDog/datadog-ci/blob/master/src/commands/coverage/README.md
326-
[9]: https://app.datadoghq.com/ci/code-coverage
328+
[1]: /code_coverage/data_collected/#source-code-provider-integration
329+
[2]: /account_management/rbac/permissions/#custom-roles
330+
[3]: /account_management/rbac/permissions/#managed-roles
331+
[4]: https://app.datadoghq.com/organization-settings/roles
332+
[5]: https://app.datadoghq.com/ci/pr-gates/rule/create
333+
[6]: /code_coverage/data_collected/#code-coverage-report-upload
334+
[7]: https://www.npmjs.com/package/@datadog/datadog-ci
335+
[8]: https://github.com/DataDog/datadog-ci/releases
336+
[9]: https://app.datadoghq.com/organization-settings/api-keys
337+
[10]: https://github.com/DataDog/datadog-ci/blob/master/src/commands/coverage/README.md
338+
[11]: https://app.datadoghq.com/ci/code-coverage
3.43 KB
Loading

0 commit comments

Comments
 (0)