Code coverage done right.®

Welcome to Codecov Documentation. You'll find comprehensive guides and documentation to help you start working with Codecov as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Carryforward Flags

Reference of past coverage for tests that are not run on current commit.


Carryforward Flags are Best Used for Monorepos and Iterative Testing Setups

Carryforward Flags are designed for those projects that do not upload total coverage for every commit (e.g., monorepos with multiple applications/languages, iterative/partial/delta testing setups, etc).

Before Getting Started

To benefit from Carryforward Flags, make sure you are set up with Codecov's Flag feature, to tag different sessions/builds.

Basic Flags documentation, including:

  1. Set Flags in your YAML
  2. Passing -F parameter in your upload

A straightforward example repository using carryforward flags can be seen here:

GitHub --
Codecov --

How Carryforward Flags Work: A Motivating Example

Before discussing how to use carryforward flags, it's important to discuss how they work. That is best demonstrated with the following diagram:

An example of two commits using flags, carryforward flags, and no flags.

The following codecov.yml is also supplied for the above example:

    carryforward: true
    carryforward: true
    carryforward: false 
   # If no Carryfoward flag specified in YAML, the
   # default configuration is false.

In this example, the coverage for and was taken directly from the coverage report uploaded for Commit 1. The ui_cov.xml coverage report was uploaded using the following syntax:

bash <(curl -f ui_cov.xml -F ui

This upload command specifies both the path to the coverage file for files under the ui flag and the appropriate flag name (ui in this case). Once uploaded, coverage was calculated to the and files in the same manner as any report upload.

Since no report is uploaded for the unit flag, which has a setting of carryforward: true , Codecov reaches back to Commit 0 to carry forward the coverage for all files covered by the unit flag. As a result, those files have coverage information for Commit 1 that is equivalent to Commit 0.

Finally, since the enterprise flag has a setting of carryforward: false no coverage is carried forward for any file covered by the enterprise flag. Since no coverage report was uploaded for the enterprise flag for Commit 1, the and files have 0% coverage for Commit 1.


You Must Upload using -F

To properly leverage flags, and thus, carryforward flags, you must ensure you're uploading coverage reports with the appropriate flag name.

Carryforward Flags in the Codecov UI

Once your team starts using carryforward flags they will appear in the UI just like normal flags, with the addition of distinctive iconography to set them apart from Codecov's standard flags. For example, carryforward flags can be toggled when viewing source:

In this example flagone is carried forward and flagtwo and flagthree are not.

Additionally, any coverage that is carried forward will be shown in the Build tab of a the commit that carried the coverage forward. The commit from which the coverage was carried forward is also referenced wherever carryforward flags are shown, like so:

Advanced: Configuring Carryforward Flags in the Code Host

Carryforward Flags in the Pull Request Comment


Carryforward Flags do not show in the pull request comment by default

By default, any flags that are carried forward will not show up in the pull request / merge request in your code host (Github, Gitlab, or Bitbucket) in the status checks and/or the pull request comments.

Instead, only flags that have coverage uploaded on the most recent commit will show in the PR Comments.

By default flags that are carried forward will not appear in the Pull Request Comment.

If you would like Carryforward Flags to appear in PR comments, use the following YAML configuration under show_carryforward_flags.

The possible settings for:show_carryforward_flags are:

  • false [default]: flags with carried forward coverage will not show up on the flags table

  • true: if any flag coverage was carried forward, the flags table will have an additional column labeled “Carriedforward” indicating which flags had coverage carried forward

PR comment with show_carryforward_flags set to true

Example YAML:


  layout: "reach, diff, flags, files” 

  behavior: default require_changes: false 
  # if true: only post the comment if coverage changes 

  require_base: no # [yes :: must have a base report to post] 

  require_head: yes # [yes :: must have a head report to post] 

  branches: # branch names that can post comment 

    - "master"

  show_carryforward_flags: false

Updated about a month ago

Carryforward Flags

Reference of past coverage for tests that are not run on current commit.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.