Code Monkey home page Code Monkey logo

example-cpp11-cmake's Introduction

Codecov CI CMake g++ cpp11 lcov Example

Travis CI logo Codecov logo FOSSA Status

Build Status codecov MIT License

The goal of this project is to build project with following tools:

  • C++ version: C++11
  • Build system: CMake
  • C++ compiler: g++ or Visual Studio
  • Libraries: STL only
  • Code coverage report: lcov and OpenCppCoverage(note: it should show the code coverage is below 100%)
  • CodeCov (code coverage is measured by CodeCov).
  • Source: multiple files

Special Thanks

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 lcov), and here is a list of all his Travis configuration examples.

Prerequisites

To build the project you need to install CMake. (Install instructions) To display a code coverage report in the console, install lcov. (Download lcov, Instructions)

Guide

  1. Compile with code coverage instrumentation enabled (GCC).
  2. Execute the tests to generate the coverage data.
  3. (Optionally) generate and customize reports with lcov.
  4. Upload to CodeCov using the bash uploader.

Travis Setup Using lcov

Add to your .travis.yml file:

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"

Caveats

Private Repos

Add to your .travis.yml file:

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

Example details

This repo can serve as the starting point for a new project. The following is worth noticing:

  1. Use of a build script instead of putting the commands into .travis.yml
  • Allows local testing
  • Allows usage of set -e to error out with meaningfull messages on any command failure
  1. 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 '*/tests/*')
  1. Use of travis cache to cache manually build 3rd-party dependencies (like boost)
  • Speeds up build
  • More can be added (e.g. ccache)
  • Those need to be excluded from coverage info too

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

  1. More documentation at https://docs.codecov.io
  2. Configure codecov through the codecov.yml https://docs.codecov.io/docs/codecov-yaml

We are happy to help if you have any questions. Please email our Support at [email protected]

FOSSA Status

example-cpp11-cmake's People

Contributors

derdakon avatar eliatcodecov avatar farwaykorse avatar flamefire avatar fossabot avatar pavelkryukov avatar rokkos avatar roman3349 avatar sergeyklay avatar thomasrockhu avatar tomped avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.