Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Code Coverage

Retrieve and analyze code coverage data from Code Coverage. See the Code Coverage page for more information.

Note: This endpoint is in preview and may be subject to change. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.ap2.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.datadoghq.eu/api/v2/code-coverage/branch/summaryhttps://api.ddog-gov.com/api/v2/code-coverage/branch/summaryhttps://api.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.us3.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.us5.datadoghq.com/api/v2/code-coverage/branch/summary

Présentation

Retrieve aggregated code coverage statistics for a specific branch in a repository. This endpoint provides overall coverage metrics as well as breakdowns by service and code owner.

Note: This endpoint requires the code_coverage_read permission.

This endpoint requires the code_coverage_read permission.

OAuth apps require the code_coverage_read authorization scope to access this endpoint.

Requête

Body Data (required)

Expand All

Champ

Type

Description

data [required]

object

Data object for branch summary request.

attributes [required]

object

Attributes for requesting code coverage summary for a branch.

branch [required]

string

The branch name.

repository_id [required]

string

The repository identifier.

type [required]

enum

JSON:API type for branch coverage summary request. The value must always be ci_app_coverage_branch_summary_request. Allowed enum values: ci_app_coverage_branch_summary_request

{
  "data": {
    "attributes": {
      "branch": "prod",
      "repository_id": "github.com/datadog/shopist"
    },
    "type": "ci_app_coverage_branch_summary_request"
  }
}

Réponse

OK

Response object containing code coverage summary.

Expand All

Champ

Type

Description

data

object

Data object for coverage summary response.

attributes

object

Attributes object for code coverage summary response.

codeowners

object

Coverage statistics broken down by code owner.

<any-key>

object

Coverage statistics for a specific code owner.

evaluated_flags_count

int64

Number of coverage flags evaluated for the code owner.

evaluated_reports_count

int64

Number of coverage reports evaluated for the code owner.

patch_coverage

double

Patch coverage percentage for the code owner.

total_coverage

double

Total coverage percentage for the code owner.

evaluated_flags_count

int64

Total number of coverage flags evaluated.

evaluated_reports_count

int64

Total number of coverage reports evaluated.

patch_coverage

double

Overall patch coverage percentage.

services

object

Coverage statistics broken down by service.

<any-key>

object

Coverage statistics for a specific service.

evaluated_flags_count

int64

Number of coverage flags evaluated for the service.

evaluated_reports_count

int64

Number of coverage reports evaluated for the service.

patch_coverage

double

Patch coverage percentage for the service.

total_coverage

double

Total coverage percentage for the service.

total_coverage

double

Overall total coverage percentage.

id

string

Unique identifier for the coverage summary (base64-hashed).

type

enum

JSON:API type for coverage summary response. The value must always be ci_app_coverage_summary. Allowed enum values: ci_app_coverage_summary

{
  "data": {
    "attributes": {
      "codeowners": {
        "<any-key>": {
          "evaluated_flags_count": 2,
          "evaluated_reports_count": 4,
          "patch_coverage": 75.2,
          "total_coverage": 88.7
        }
      },
      "evaluated_flags_count": 8,
      "evaluated_reports_count": 12,
      "patch_coverage": 70.1,
      "services": {
        "<any-key>": {
          "evaluated_flags_count": 3,
          "evaluated_reports_count": 5,
          "patch_coverage": 72.3,
          "total_coverage": 85.5
        }
      },
      "total_coverage": 82.4
    },
    "id": "ZGQxMjM0NV9tYWluXzE3MDk1NjQwMDA=",
    "type": "ci_app_coverage_summary"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Authorized

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Internal server error

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

                  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/code-coverage/branch/summary" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "branch": "prod", "repository_id": "github.com/datadog/shopist" }, "type": "ci_app_coverage_branch_summary_request" } } EOF

Note: This endpoint is in preview and may be subject to change. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/code-coverage/commit/summaryhttps://api.ap2.datadoghq.com/api/v2/code-coverage/commit/summaryhttps://api.datadoghq.eu/api/v2/code-coverage/commit/summaryhttps://api.ddog-gov.com/api/v2/code-coverage/commit/summaryhttps://api.datadoghq.com/api/v2/code-coverage/commit/summaryhttps://api.us3.datadoghq.com/api/v2/code-coverage/commit/summaryhttps://api.us5.datadoghq.com/api/v2/code-coverage/commit/summary

Présentation

Retrieve aggregated code coverage statistics for a specific commit in a repository. This endpoint provides overall coverage metrics as well as breakdowns by service and code owner.

The commit SHA must be a 40-character hexadecimal string (SHA-1 hash).

Note: This endpoint requires the code_coverage_read permission.

This endpoint requires the code_coverage_read permission.

OAuth apps require the code_coverage_read authorization scope to access this endpoint.

Requête

Body Data (required)

Expand All

Champ

Type

Description

data [required]

object

Data object for commit summary request.

attributes [required]

object

Attributes for requesting code coverage summary for a commit.

commit_sha [required]

string

The commit SHA (40-character hexadecimal string).

repository_id [required]

string

The repository identifier.

type [required]

enum

JSON:API type for commit coverage summary request. The value must always be ci_app_coverage_commit_summary_request. Allowed enum values: ci_app_coverage_commit_summary_request

{
  "data": {
    "attributes": {
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_id": "github.com/datadog/shopist"
    },
    "type": "ci_app_coverage_commit_summary_request"
  }
}

Réponse

OK

Response object containing code coverage summary.

Expand All

Champ

Type

Description

data

object

Data object for coverage summary response.

attributes

object

Attributes object for code coverage summary response.

codeowners

object

Coverage statistics broken down by code owner.

<any-key>

object

Coverage statistics for a specific code owner.

evaluated_flags_count

int64

Number of coverage flags evaluated for the code owner.

evaluated_reports_count

int64

Number of coverage reports evaluated for the code owner.

patch_coverage

double

Patch coverage percentage for the code owner.

total_coverage

double

Total coverage percentage for the code owner.

evaluated_flags_count

int64

Total number of coverage flags evaluated.

evaluated_reports_count

int64

Total number of coverage reports evaluated.

patch_coverage

double

Overall patch coverage percentage.

services

object

Coverage statistics broken down by service.

<any-key>

object

Coverage statistics for a specific service.

evaluated_flags_count

int64

Number of coverage flags evaluated for the service.

evaluated_reports_count

int64

Number of coverage reports evaluated for the service.

patch_coverage

double

Patch coverage percentage for the service.

total_coverage

double

Total coverage percentage for the service.

total_coverage

double

Overall total coverage percentage.

id

string

Unique identifier for the coverage summary (base64-hashed).

type

enum

JSON:API type for coverage summary response. The value must always be ci_app_coverage_summary. Allowed enum values: ci_app_coverage_summary

{
  "data": {
    "attributes": {
      "codeowners": {
        "<any-key>": {
          "evaluated_flags_count": 2,
          "evaluated_reports_count": 4,
          "patch_coverage": 75.2,
          "total_coverage": 88.7
        }
      },
      "evaluated_flags_count": 8,
      "evaluated_reports_count": 12,
      "patch_coverage": 70.1,
      "services": {
        "<any-key>": {
          "evaluated_flags_count": 3,
          "evaluated_reports_count": 5,
          "patch_coverage": 72.3,
          "total_coverage": 85.5
        }
      },
      "total_coverage": 82.4
    },
    "id": "ZGQxMjM0NV9tYWluXzE3MDk1NjQwMDA=",
    "type": "ci_app_coverage_summary"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Authorized

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Internal server error

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

                  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/code-coverage/commit/summary" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist" }, "type": "ci_app_coverage_commit_summary_request" } } EOF