Codecov CI CMake g++ cpp11 lcov Example
The goal of this project is to build project with following tools:
- C++ version:
- Build system:
- C++ compiler:
g++or Visual Studio
- Code coverage report:
OpenCppCoverage(note: it should show the code coverage is below 100%)
CodeCov(code coverage is measured by CodeCov).
- Source: multiple files
Goes to Richel Bilderbeek for inspiration and all work on Travis CI tutorials.
Here is a link to a project with the same structure (without
and here is a list of all his Travis configuration examples.
- Compile with code coverage instrumentation enabled (GCC).
- Execute the tests to generate the coverage data.
- (Optionally) generate and customize reports with
- Upload to CodeCov using the bash uploader.
Travis Setup Using lcov
Add to your
addons: apt: packages: lcov after_success: # Create lcov report - lcov --capture --directory . --output-file coverage.info - lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter system-files - lcov --list coverage.info # debug info # Uploading report to CodeCov - bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
Travis Setup without lcov
By default the bash uploader processes the coverage data using gcov when no file is supplied.
after_success: - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
Add to your
after_success: - bash <(curl -s https://codecov.io/bash) -t uuid-repo-token
This repo can serve as the starting point for a new project. The following is worth noticing:
- Use of a build script instead of putting the commands into
- Allows local testing
- Allows usage of
set -eto error out with meaningfull messages on any command failure
- Separate testing source tree
- Allows to easily enable/disable testing
- Allows usage in parent projects (you don't want to build the tests if you are consumed)
- You may want to exclude coverage of test files which is easier when they are in a separate folder.
Remember to use full paths for patterns (like
- Use of travis cache to cache manually build 3rd-party dependencies (like boost)
- Speeds up build
- More can be added (e.g.
- Those need to be excluded from coverage info too
This project is licensed under the MIT License - see the LICENSE file for details.
- More documentation at https://docs.codecov.io
- Configure codecov through the
We are happy to help if you have any questions. Please email our Support at email@example.com