Codecov

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

Codecov Bash Uploader

Introduction

The Codecov Bash Uploader is a very unique and original style to uploading reports. It has been a tradition for other products that integrate with different languages to create a specific plugin for each language. We believe this is a bad practice that quickly leads to out-of-date and poorly maintained packages.

One uploader to rule them all.

bash <(curl -s https://codecov.io/bash)

The source code is entirely open source, and we invite anyone to contribute to make the uploader more powerful.

The main objective to uploader is to detect the environment, gather reports and upload them to Codecov. First, you query Codecov for the latest file version, and then you allow bash to execute the uploader. At this time, the uploader runs its code and outputs its progress to stdout.

Upload token

Not required for *public* projects tested on TravisCI, CircleCI or AppVeyor

We require you to provide your unique upload token to identify your projects uploads. You can find this token in your repository settings (/gh/:owner/:repo/settings).

A repository on codecov with no uploaded coverage reports.  Note the upload token.

A repository on codecov with no uploaded coverage reports. Note the upload token.

We have three ways to include this token in the uploading process:

Via flag

bash <(curl -s https://codecov.io/bash) -t token

Environment variable

export CODECOV_TOKEN="token"
bash <(curl -s https://codecov.io/bash)

File

echo "token" > .cc_token
bash <(curl -s https://codecov.io/bash) -t @.cc_token

CI detection

The bash uploader detects all CI providers through environment variables. This process helps to identify the source of the build and maintain a relationship back to the source of the coverage collection.

Finding reports

Codecov can automatically detect coverage files in your project. We have an aggressive file name search that will grab everything that is known to be a coverage report.

Here are some options for discovering reports.

# only upload this file
-f path/to/foo.bar

# also search this folder that is outside the project directory
-s /home/user/reports/foo/bar

# ignore all files at pattern *.bar
-f "!*.bar"

# include all files at pattern *.foo
-f "*.foo"

Uploading process

When the upload script is called, the general logic of what happens is as follows:

  1. The CI is discovered through environment variables.
  2. Language specific process (e.g. xcode, python).
  3. Reports are discovered.
  4. Reports are uploaded to Amazon S3 for archiving (secret location).
  5. Codecov is informed of the upload, and will queue the report processing server side.
  6. Fin. exit 0.

Exit 0

Codecov will exit 0 to prevent failing the build, if there are issues. If you would like Codecov to exit with 1, use bash <(curl -s https://codecov.io/bash) -Z.

exit 0 is not full proof. Please use this command to always exit with 0: bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'.