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
Code Coverage is in Preview. This product replaces Test Optimization's <ahref="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.
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.
<divclass="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>
See [Data Collected][1] for details on what data is collected from your source code provider.
58
+
50
59
## Data access permissions
51
60
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.
53
62
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.
55
64
56
65
## PR Gates
57
66
58
67
If you wish to gate on PR coverage, configure PR Gates rules in Datadog.
59
68
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.
61
70
62
71
## Upload code coverage reports
63
72
64
73
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.
65
74
75
+
See [Data Collected][6] for details on what data is collected during code coverage report upload.
76
+
66
77
### Supported coverage report formats
67
78
68
79
Datadog supports the following coverage data formats—expand for examples:
@@ -238,15 +249,15 @@ end_of_record
238
249
239
250
### Install the datadog-ci CLI
240
251
241
-
Install the [`datadog-ci`][5] CLI globally using `npm`:
252
+
Install the [`datadog-ci`][7] CLI globally using `npm`:
242
253
243
254
{{< code-block lang="shell" >}}
244
255
npm install -g @datadog/datadog-ci
245
256
{{< /code-block >}}
246
257
247
258
#### Standalone binary
248
259
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:
250
261
251
262
{{< tabs >}}
252
263
{{% tab "Linux" %}}
@@ -285,7 +296,7 @@ Start-Process -FilePath "./datadog-ci.exe" -ArgumentList version
285
296
286
297
### Uploading coverage reports
287
298
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:
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.
308
318
309
319
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.
0 commit comments