A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.codecov.io/docs/commit-status below:

Status Checks

The codecov/project status measures overall project coverage and compares it against the base of the pull request or parent commit.

coverage:
  status:
    project:
      default:   # default is the status check's name, not default settings
        target: auto 
        threshold: 5
        base: auto 
        flags: 
          - unit
        paths: 
          - "src"
       # advanced settings
        branches: 
          - master
        if_ci_failed: error #success, failure, error, ignore
        informational: false
        only_pulls: false
📘

New to the Codecov yaml?

View the codecov.yml documentation here.

coverage:
	status:
		project: true

auto | <number>
Choose a minimum coverage ratio that the commit must meet to be considered a success.

<number>
Allow the coverage to drop by <number>%, and posting a success status.

[Deprecated as of July 2020 -- Codecov's product roadmap includes a novel way to manually pick base of pull requests]

Flags are a list of user defined Flags, and the impact on their coverage. You can specify an array of flags as follows:

coverage:
  status:
    project:
      default:
        #...
        flags:
          - flag1
          - flag2
          - ...

and the combined coverage from those flags will be reported. Before using flags, it is highly recommended to read more about their use.

Similar to flags, an array of paths and/or regular expressions can be provided and the status will report the combined coverage for the files that match the path name / regular expression.

While Codecov defaults should be sufficient for most use cases, below are some advanced features to personalize your experience even more.

The branches that, when used, will trigger this status.

Settings are 'success' and 'failure' the default is 'success'.

Use Codecov in informational mode. Default is false. If true is specified the resulting status will pass no matter what the coverage is or what other settings are specified. Informational mode is great to use if you want to expose codecov information to other developers in your pull request without necessarily gating PRs on that information.

Only post a status to pull requests, defaults to false. If true no status will be posted for commits not on a pull request

Settings are 'success' and 'error' the default is 'error'.

Options are:

Determines how we handle status checks for which no flag coverage has been newly uploaded on a commit. This includes status checks where flags have carriedforward coverage (since coverage was no newly uploaded), as well as flags for which coverage is missing entirely.
Options are:

This is useful if, for example, you're working on a project in a monorepo and don't want to see status checks related to other projects.
Note that this only applies to status checks that specify flags. If there are no flags on a check, the status check will be processed as usual.

For a full breakdown of all the ways we handle removed code in your project status checks, please see our Removed Code Behavior page.

Below is an example of using the flag_coverage_not_uploaded behavior to omit status checks from unrelated projects.

coverage:
  status:
    default_rules:
      flag_coverage_not_uploaded_behavior: exclude # don't send status checks that don't have flag coverage uploaded
    project:
      projectA:
        target: auto
        flags:
          - projectA-unit
          - projectA-integration
      projectB:
        target: auto
        flags:
          - projectB

In this example, if a PR is opened in projectB then the status check for projectA won't be sent, as long as no coverage for projectA was uploaded on the PR.
Note that this requires that the CI process in projectB only uploads to Codecov using the projectB flag, and does not upload anything under the projectA flag. If your CI runs all tests and uploads coverage for every flag specified in the YAML file on every commit, then all status checks will appear as normal.

Below, is an example of using multiple project statuses that measure different aspects of your project.

coverage:
  status:
    project:
      default: false  # disable the default status that measures entire project
      tests:  # declare a new status context "tests"
        target: 100%  # we always want 100% coverage here
        paths: "tests/"  # only include coverage in "tests/" folder
      app:  # declare a new status context "app"
        paths: "!tests/"  # remove all files in "tests/"

Now you will see two unique status contexts from Codecov: codecov/project/tests and codecov/project/app.

You may have a code base that has multiple application components that you would like to monitor independently. Codecov provides a very simple way create statuses for each component.

coverage:
  status:
    project:
      users:
        paths:
          - tests/users
          - app/components/user*
      products:
        paths:
          - tests/products
          - app/components/product*

As illustrated above, you can set project statuses filtering out specific components of the application, and get 3 unique statuses monitoring each component.

The codecov/patch status only measures lines adjusted in the pull request or single commit, if the commit is not in a pull request. This status provides an indication on how well the pull request is tested.

coverage:
  status:
    patch:
      default:
        # basic
        target: auto
        threshold: 0%
        base: auto 
        # advanced
        branches: 
          - master
        if_ci_failed: error #success, failure, error, ignore
        only_pulls: false
        flags: 
          - "unit"
        paths: 
          - "src"

To illustrate the usage of the patch status, let's go through this exercise.

  def divide(x, y):
+     if y <= 0:
+         raise ValueError("y must be greater than 0")
      return x * y

The resulting codecov/patch status of this commit would be 0% covered because no tests are created for this method. Even though the project coverage is 72% (the entire code base not shown), this patch status will only measure lines added.

To make another commit on this pull request, adding tests, proceed as follows.

+ def test_divide_by_1(self):
+     assert divide(10, 1) == 10

Running the tests will result in a patch coverage of 50% covered because we have not yet tested the behavior of dividing by zero. Let's add another test.

 def test_divide_by_1(self):
     assert divide(10, 1) == 10

+ def test_divide_by_zero(self):
+     with self.assertRaises(ValueError)
+         divide(1, 0)
+

Now Codecov will report a codecov/patch status of 100% covered for this pull request. This indicates that the pull request adjusted code is properly executed by tests.

You may choose to disable the default statuses Codecov posts by using the following yaml configuration.

📘

Enabling a status

Note that you can not enable a status by setting it to yes, you need to define it by using the structure described here

coverage:
  status:
    project: off
    patch: off

Codecov will detect changes in coverage that are NOT included in the commit/pull diff, and report these changes as a commit status.

Let's take this example to illustrate what an Unexpected Coverage Changes would look like.

First commit. 100% coverage.

As shown above, we have 100% coverage. Now let's make a change to this code base.

Second commit's diff.

Our CI will run and result in the following:

Second commit's coverage.

Lines 1 and 2 are considered "changes" in Codecov. This status would detect these changes and report them to the commit status.

A top-level default_rules field can be added to specify some behaviors to be applied by default to every status check, unless the status check definition itself explicitly sets a different behavior.
This can be useful for setting a behavior at a global level for all checks without needing to manually go through the definition of every individual checks. This can also be useful if you want to specify a global behavior but also make exceptions for individual checks.

Example:

coverage:
  status:
    default_rules: # this behavior will be applied to all checks by default
      flag_coverage_not_uploaded_behavior: exclude 
    project:
      projectA:
        flags:
          - projectA
      projectB:
        flags:
          - projectB
      projectC:
        flag_coverage_not_uploaded_behavior: include # this behavior will be applied only to this status check
        flags:
          - projectC

In this example, the exclude behavior for the flag_coverage_not_uploaded_behavior setting will be applied to projectA and projectB, but the include behavior will be applied to projectC because that project's YAML configuration explicitly sets a different value for that setting.

Not all the status check configuration options can be set at a global level like this with default_rules. Currently only the following fields are supported:

Updated 11 months ago


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4