| 67 | |
| 68 | |
| 69 | === Profits ==== |
| 70 | Travis is a continuous integration system that builds and run tests on each push to github repository. It helps you to find and report errors faster. |
| 71 | |
| 72 | Coveralls shows tests coverage. This is a useful feature, that allows you to make sure that newly created code is covered by tests. Even 100% coverage does not mean that there's no errors. However it motivates people to write tests, helps to find trivial errors and typos and sometimes even helps to find hard detectable errors ([https://github.com/boostorg/variant/commit/6db01d649441e0d16b386bd357a9141b8f3f3b17 bug that have been in Variant for years and was highlighted by Coveralls]) |
| 73 | |
| 74 | |
| 75 | === `.travis.yml` content (18.12.2014) === |
| 76 | {{{ |
| 77 | # Use, modification, and distribution are |
| 78 | # subject to the Boost Software License, Version 1.0. (See accompanying |
| 79 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 80 | # |
| 81 | # Copyright Antony Polukhin 2014. |
| 82 | |
| 83 | # |
| 84 | # See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file |
| 85 | # and how it can be used with Boost libraries. |
| 86 | # |
| 87 | |
| 88 | os: |
| 89 | - linux |
| 90 | |
| 91 | env: |
| 92 | - CXX_STANDARD=c++98 |
| 93 | - CXX_STANDARD=c++0x |
| 94 | |
| 95 | before_install: |
| 96 | # Set this to the name of your Boost library |
| 97 | # Autodetect library name by using the following code: - PROJECT_TO_TEST=$(basename $(pwd)) |
| 98 | - PROJECT_TO_TEST=$(basename $(pwd)) |
| 99 | |
| 100 | # Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=`git rev-parse --abbrev-ref HEAD` |
| 101 | # or by - BRANCH_TO_TEST=$TRAVIS_BRANCH or just directly specify it |
| 102 | - BRANCH_TO_TEST=$TRAVIS_BRANCH |
| 103 | |
| 104 | # Files, which coverage results must be ignored (files from other projects). Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/path.cpp' |
| 105 | - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/path.cpp */numeric/conversion/converter_policies.hpp' |
| 106 | |
| 107 | |
| 108 | # From this point and below code is same for all the Boost libs |
| 109 | # Cloning Boost libraries (fast nondeep cloning) |
| 110 | - PROJECT_DIR=`pwd` |
| 111 | - BOOST=$HOME/boost-local |
| 112 | - git init $BOOST |
| 113 | - cd $BOOST |
| 114 | - git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git |
| 115 | - git fetch --depth=1 |
| 116 | - git checkout $BRANCH_TO_TEST |
| 117 | - git submodule update --init --merge |
| 118 | - git remote set-branches --add origin $BRANCH_TO_TEST |
| 119 | - git pull --recurse-submodules |
| 120 | - git submodule update --init |
| 121 | - git checkout $BRANCH_TO_TEST |
| 122 | - git submodule foreach "git reset --quiet --hard; git clean -fxd" |
| 123 | - git reset --hard; git clean -fxd |
| 124 | - git status |
| 125 | - rm -rf $BOOST/libs/$PROJECT_TO_TEST |
| 126 | - mv $PROJECT_DIR/../$PROJECT_TO_TEST/ $BOOST/libs/$PROJECT_TO_TEST |
| 127 | - PROJECT_DIR=$BOOST/libs/$PROJECT_TO_TEST |
| 128 | - ./bootstrap.sh |
| 129 | - ./b2 headers |
| 130 | |
| 131 | script: |
| 132 | - if [ "$CCFLAGS" != "" ]; then FLAGS="cxxflags=\"$CCFLAGS\" linkflags=\"$LINKFLAGS\""; else FLAGS=""; fi |
| 133 | - cd $BOOST/libs/$PROJECT_TO_TEST/test/ |
| 134 | # `--coverage` flags required to generate coverage info for Coveralls |
| 135 | - ../../../b2 cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage" |
| 136 | |
| 137 | after_success: |
| 138 | # Copying Coveralls data to a separate folder |
| 139 | - mkdir -p $PROJECT_DIR/coverals |
| 140 | - find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $PROJECT_DIR/coverals/ \; |
| 141 | - find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $PROJECT_DIR/coverals/ \; |
| 142 | |
| 143 | # Preparing Coveralls data by |
| 144 | # ... installing the tools |
| 145 | - sudo apt-get install -qq python-yaml lcov |
| 146 | # ... changind data format to a readable one |
| 147 | - lcov --directory $PROJECT_DIR/coverals --base-directory ./ --capture --output-file $PROJECT_DIR/coverals/coverage.info |
| 148 | |
| 149 | # ... erasing /test/ /example/ folder data |
| 150 | - cd $BOOST |
| 151 | - lcov --remove $PROJECT_DIR/coverals/coverage.info "/usr*" "*/$PROJECT_TO_TEST/test/*" $IGNORE_COVERAGE "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $PROJECT_DIR/coverals/coverage.info |
| 152 | |
| 153 | # ... erasing data that is not related to this project directly |
| 154 | - OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'` |
| 155 | - echo $OTHER_LIBS |
| 156 | - eval "lcov --remove $PROJECT_DIR/coverals/coverage.info $OTHER_LIBS -o $PROJECT_DIR/coverals/coverage.info" |
| 157 | |
| 158 | # Sending data to Coveralls |
| 159 | - cd $PROJECT_DIR |
| 160 | - gem install coveralls-lcov |
| 161 | - coveralls-lcov coverals/coverage.info |
| 162 | }}} |