Skip to content

Codecov Setup

vhirtham edited this page Mar 17, 2018 · 5 revisions

General

If the coverage should be tracked, --coverage must be added to the compile flags and the sources must be build in debug mode. After building the project, you need to tun all tests to create the coverage reports. If that is done use:

lcov --directory build --capture --output-file coverage.info

To filter certain directories use:

lcov --remove coverage.info 'usr/*' --output-file coverage.info

If you are using travis to create the coverage reports for the codecov homepage you can use the command below. However, the report file should be in the source directory and also the command should be executed from there, otherwise the reports might not show the desired files.

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

If you use a docker image to build on travis, you might need to create a shared volume to pass the report out of the docker run. There are also other alternatives shown on the codecov homepage. The info how to mount a shared volume is located here.

The current code coverage result can be shown in form of a badge like this:

codecov

The link can be extracted from the codecovs site under settings->badge.

codecov.yml

To customize the codecov report and the tolerated values, you can create a .codecov.yml in your projects root directory. The code is in python and needs to fulfill the code formatting. To test if your file is valid, you can run:

curl --data-binary @.codecov.yml https://codecov.io/validate

For all the possible settings, have a look here:

https://github.com/codecov/support/wiki/Codecov-Yaml

Clone this wiki locally