Set metric thresholds using the API

In an earlier release, we introduced the ability to add thresholds to repository metrics on DeepSource and to configure analysis runs on pull-requests to fail if the threshold isn’t met.

Today, we’ve added a new mutation, setRepositoryMetricThreshold in our API, enabling you to programmatically set thresholds for repository metrics.

For instance, you can set the threshold for the Line Coverage metric for Python on a repository like this:

mutation ($input: SetRepositoryMetricThresholdInput!) {
  setRepositoryMetricThreshold(input: $input) {
    ok
  }
}
variables = {
  "input": {
    "repositoryId": "VHJhbnNmb3JtZXI6bGp6a3d6",
    "metricShortcode": "LCV",
    "metricKey": "PYTHON",
    "thresholdValue": 90
}

Read the full documentation here.

1 Like