GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing docs.datadoghq.com — Set Up Code Coverage For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/code_coverage/setup.md.
A documentation index is available at /llms.txt.
Set Up Code CoverageThis product is not supported for your selected Datadog site. (). Setting up Code Coverage involves the following steps:
Integrate with source code providerCode Coverage supports the following: Follow instructions in the GitHub integration documentation on how to connect your GitHub repositories to Datadog. Code Coverage requires the following GitHub App permissions:
The following webhooks are required:
If everything is configured correctly, a green check mark is displayed in Datadog’s GitHub Integration page: If you have a Datadog-managed Marketplace App or a custom app with default settings, the required permissions and webhooks are included. Follow instructions in the GitLab Source Code integration documentation on how to connect your GitLab repositories to Datadog. See Datadog Source Code Integration Guide for additional context. Follow instructions in the Datadog Source Code Integration Guide on how to connect your Azure DevOps repositories to Datadog using Azure DevOps Source Code integration. The integration supports only Bitbucket Cloud repositories and requires a Bitbucket Cloud Premium workspace. Bitbucket Server and Data Center are not supported. Install Datadog’s Bitbucket Source Code integration to connect to your Bitbucket repositories. Use the integration tile or install the integration during onboarding for other Datadog products. See Data Collected for details on what data is collected from your source code provider. Data access permissionsIf you are using custom roles rather than Datadog-managed roles, be sure to enable the Code Coverage Read permission for the roles that need to view code coverage data. Navigate to Roles settings, click Edit on the role you need, add the Code Coverage Read permission to the role, and save the changes. For more granular control, use Data Access Control to restrict code coverage data by repository rather than across your entire organization. This prevents sensitive information in coverage reports, such as source paths and test names, from crossing team boundaries. In Datadog, go to Organization Settings > Data Access Control and create a Restricted Dataset scoped to Software Delivery and the repository you want to restrict. Grant access to the roles or teams that should see it. PR GatesIf you wish to gate on PR coverage, you can configure PR Gates rules in one of two ways:
Rules from both sources are evaluated when a pull request is opened or updated. See Configuration for YAML gate syntax and examples. Upload code coverage reportsUpload code coverage report files to Datadog either automatically, with a supported Test Optimization library, or manually, by running the See Data Collected for details on what data is collected during code coverage report upload. Upload reports automatically with Test OptimizationSupported libraries and versionsAutomatic code coverage report upload is supported in the following Test Optimization library versions:
These version requirements apply only to automatic uploads by Test Optimization libraries. Enable automatic uploadsYou can apply the Code Coverage setting at the organization, repository, or test service level.
The library uploads the report to Datadog after the command finishes. To organize and filter reports uploaded by the library, see Add flags to automatically uploaded reports, which lists the libraries and versions that support Supported coverage report formatsDatadog supports the following coverage data formats—expand for examples:
LCOV
Go Coverprofile
Cobertura XML
Jacoco XML
Clover XML
OpenCover XML
Simplecov JSONInstall the datadog-ci CLIIf you use GitHub Actions, you can skip this installation step. The GitHub Actions upload method below uses a dedicated action that handles datadog-ci installation automatically.Standalone binaries are provided with Datadog CI releases. The linux-x64, linux-arm64, darwin-x64, darwin-arm64 (macOS), and win-x64 (Windows) architectures are supported. To install, run the following from your terminal: Then run any command with Then run any command with Then run any command with npmAlternatively, if Node.js is available in your CI environment, install the Docker imageAlternatively, you can update your CI job to run in a container based on the Datadog CI Docker image.
The image comes with Uploading coverage reportsDatadog automatically aggregates all reports for the same commit on the backend. You don't need to merge coverage reports before uploading them. To upload your code coverage reports to Datadog, run the following command. Provide a valid Datadog API key ( Use the Datadog Code Coverage Upload GitHub Action. This action automatically installs and runs Alternatively, if you have - script: datadog-ci coverage upload --format=clover coverage/clover.xml
displayName: 'Upload coverage to Datadog'
env:
DD_API_KEY: $(DD_API_KEY)
DD_SITE: 'datadoghq.com'The command recursively searches the specified directories for supported coverage report files, so specifying the current directory ( Shortly after the code coverage report upload is finished, Datadog adds a PR comment with code coverage percentage values. To add a per-file breakdown of total and patch coverage to the comment, see PR Comments. To annotate uncovered lines directly on the pull request diff, see Inline annotations. You can also view your coverage data aggregated by pull request in the Code Coverage page in Datadog, with the ability to examine individual files and lines of code. TroubleshootingCoverage upload command does not detect coverage report filesThe Coverage upload fails with “Format could not be detected” errorThe specify the format explicitly using the Coverage upload outputs “Could not sync git metadata” errorGit metadata upload is only required if you can’t integrate your CI provider directly with Datadog.
If you are using a source code provider integration, such as Datadog GitHub app or GitLab integration, you can disable the git metadata upload by passing the Datadog UI does not show changed files in the PR viewBy default, the “Changed files” table only contains executable source code files that are present in the uploaded coverage reports. Select Non-executable files or All in the table header to display all files that were changed in the PR, regardless of whether they are executable or not. If a source code file is mistakenly marked as non-executable, it is probably missing from your uploaded coverage reports. Make sure that you are uploading all of your relevant reports, and double-check your coverage tool configuration to verify that coverage data is collected for all applicable files. Test sources are not considered executable files as they are not part of the production codebase being measured for coverage. Datadog UI shows incorrect file pathsCode Coverage relies on the file paths in coverage reports to be either absolute or relative to the repository root.
If the paths in your report are relative to a different directory in your repository, specify the correct base path (relative to the repo root) with the Inaccurate coverage from non-executable linesSome coverage tools include non-executable lines (such as comments, blank lines, and closing brackets) in their reports, counting them as uncovered. This can lower your coverage percentages and produce false negatives for lines that can never be executed. During upload, the CLI automatically scans your source files to identify these non-executable lines so they can be excluded from coverage calculations. File fixes support the following languages: Go, Kotlin, C/C++, Swift, Objective-C, and PHP. You can control this behavior with the following options:
Discrepancy between Datadog UI and coverage report valuesDatadog automatically merges coverage reports for the same commit. As a result, the coverage percentage displayed in the Datadog UI may differ from the values in your individual coverage reports, especially if those reports contain overlapping or duplicate source code file entries. If you use an external tool (such as ReportGenerator) to merge coverage reports before uploading to Datadog, ensure your merged reports do not contain duplicate source code file entries. Datadog deduplicates overlapping files across reports, which can result in differences between your original coverage values and the merged values displayed in the Datadog UI. For a description of how reports are merged and how each line status is counted, see Code Coverage Calculation. Further readingAdditional helpful documentation, links, and articles: | ||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |