.travis.yml 9.1 KB
Newer Older
N
Niels 已提交
1 2 3 4 5
#########################
# project configuration #
#########################

# C++ project
N
Niels 已提交
6 7
language: cpp

N
Niels 已提交
8 9
dist: trusty
sudo: required
N
Niels 已提交
10

N
Niels 已提交
11

N
Niels 已提交
12 13 14 15 16 17 18 19 20 21 22
###################
# global settings #
###################

env:
  global:
   # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
   #   via the "travis encrypt" command using the project repo's public key
   - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="


N
Niels 已提交
23 24 25
################
# build matrix #
################
N
Niels 已提交
26

N
Niels 已提交
27 28
matrix:
  include:
N
Niels 已提交
29

N
Niels 已提交
30 31 32 33 34 35 36 37 38 39 40 41
  # Valgrind

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
      - SPECIAL=valgrind
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: [g++-4.9, valgrind]
    after_success:
42
      - make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
N
Niels 已提交
43

44
  # cLang sanitizer
45 46 47 48 49 50 51 52 53 54 55 56 57 58
  # note: sadly clang's libc++ has errors when running with sanitize,
  # so we use clang with gcc's libstdc++ which doesn't give those error.
  # that's why we need to install g++-6 to get the lastest version
  - os: linux
    env:
      - LLVM_VERSION=3.8.1
      - SPECIAL=sanitizer
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-6
    compiler: clang
    before_script:
      - make clang_sanitize
59

N
Niels 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73
  # cppcheck

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
      - SPECIAL=cppcheck
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: [g++-4.9, cppcheck]
    after_success:
      - make cppcheck

74 75 76 77 78 79 80
  # no exceptions

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
      - SPECIAL=no_exceptions
N
Niels Lohmann 已提交
81
      - TEST_PATTERN=-e \"*\"
82 83 84 85 86
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: [g++-4.9, cppcheck]
    before_script:
N
Niels Lohmann 已提交
87
      - CPPFLAGS="-DJSON_NOEXCEPTION" make
88

N
Niels 已提交
89
  # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
N
Niels 已提交
90 91 92 93 94 95

  - os: linux
    compiler: gcc
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
N
Niels 已提交
96
        packages: ['g++-4.9', 'ruby']
N
Niels 已提交
97 98 99 100 101
    before_script:
      - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
      - tar xf lcov_1.11.orig.tar.gz
      - sudo make -C lcov-1.11/ install
      - gem install coveralls-lcov
102
      - pip install --user cpp-coveralls
N
Niels Lohmann 已提交
103
    after_success:
N
Niels 已提交
104
      - make clean
105 106
      - CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make json_unit
      - test/json_unit "*"
N
Niels 已提交
107 108 109 110 111 112 113 114 115 116 117 118
      - coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
      - lcov --directory src --directory test/src --capture --output-file coverage.info --rc lcov_branch_coverage=1 --no-external
      - lcov --remove coverage.info 'test/src/*' --output-file coverage.info --rc lcov_branch_coverage=1
      - lcov --list coverage.info --rc lcov_branch_coverage=1
      - coveralls-lcov --repo-token F9bs4Nop10JRgqPQXRcifyQKYhb3FczkS coverage.info
    env:
      - COMPILER=g++-4.9
      - SPECIAL=coveralls

  # Coverity (only for branch coverity_scan)

  - os: linux
119
    compiler: clang
N
Niels 已提交
120 121 122 123 124 125 126
    before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
    addons:
      coverity_scan:
        project:
          name: "nlohmann/json"
          description: "Build submitted via Travis CI"
        notification_email: niels.lohmann@gmail.com
127
        build_command_prepend: "make clean"
N
Niels 已提交
128 129 130
        build_command: "make"
        branch_pattern: coverity_scan
    env:
131
      - LLVM_VERSION=3.6.0
N
Niels 已提交
132 133
      - SPECIAL=coverity

N
Niels 已提交
134 135 136 137 138 139
  # OSX / Clang

  - os: osx
    osx_image: xcode6.4

  - os: osx
140
    osx_image: xcode7.3
N
Niels 已提交
141 142

  - os: osx
143
    osx_image: xcode8
N
Niels 已提交
144

N
Niels 已提交
145
  - os: osx
146
    osx_image: xcode8.1
N
Niels 已提交
147

N
Niels 已提交
148
  - os: osx
149
    osx_image: xcode8.2
N
Niels 已提交
150

N
Niels 已提交
151 152
  # Linux / GCC

N
Niels 已提交
153 154
  - os: linux
    compiler: gcc
N
Niels 已提交
155 156 157
    env: COMPILER=g++-4.9
    addons:
      apt:
N
Niels 已提交
158
        sources: ['ubuntu-toolchain-r-test']
N
Niels 已提交
159 160 161 162 163 164 165
        packages: g++-4.9

  - os: linux
    compiler: gcc
    env: COMPILER=g++-5
    addons:
      apt:
N
Niels 已提交
166
        sources: ['ubuntu-toolchain-r-test']
N
Niels 已提交
167
        packages: g++-5
N
Niels 已提交
168

N
Niels 已提交
169 170 171 172 173 174 175 176
  - os: linux
    compiler: gcc
    env: COMPILER=g++-6
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-6

N
Niels 已提交
177 178
  # Linux / Clang

N
Niels 已提交
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
  - os: linux
    env: LLVM_VERSION=3.6.0
    compiler: clang

  - os: linux
    env: LLVM_VERSION=3.6.1
    compiler: clang

  - os: linux
    env: LLVM_VERSION=3.6.2
    compiler: clang

  - os: linux
    env: LLVM_VERSION=3.7.0
    compiler: clang

  - os: linux
    env: LLVM_VERSION=3.7.1
    compiler: clang

N
Niels 已提交
199 200 201
  - os: linux
    env: LLVM_VERSION=3.8.0
    compiler: clang
N
Niels 已提交
202

N
Niels 已提交
203 204 205 206
  - os: linux
    env: LLVM_VERSION=3.8.1
    compiler: clang

N
Niels 已提交
207 208 209 210
#####################
# installation step #
#####################

N
Niels 已提交
211
# set directories to cache
N
Niels 已提交
212 213
cache:
  directories:
N
Niels 已提交
214 215 216 217 218
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.0
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.1
N
Niels 已提交
219
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0
N
Niels 已提交
220
    - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1
N
Niels 已提交
221 222


N
Niels 已提交
223
install:
N
Niels 已提交
224
  # create deps dir if not existing
N
Niels 已提交
225
  - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
N
Niels 已提交
226
  - mkdir -p ${DEPS_DIR}
N
Niels 已提交
227

N
Niels 已提交
228
  # make sure CXX is correctly set
N
Niels 已提交
229 230
  - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi

231 232 233 234 235 236 237 238
  # get CMake (only for systems with brew - macOS)
  - |
     if [[ !(-x $(which cmake)) && (-x $(which brew)) ]]; then
       brew update
       brew install cmake
       cmake --version
     fi

N
Niels 已提交
239
  # install LLVM/clang when LLVM_VERSION is set
N
Niels 已提交
240 241 242 243
  - |
     if [[ "${LLVM_VERSION}" != "" ]]; then
       LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION}
       if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then
N
Niels 已提交
244 245 246 247
         travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
         tar xfz cmake-3.6.1.tar.gz
         (cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install)
         export PATH="${LLVM_DIR}/cmake/bin:${PATH}"
N
Niels 已提交
248 249 250 251 252 253 254 255 256 257 258 259 260
         LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
         LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
         LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
         CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
         mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang
         travis_retry wget --quiet -O - ${LLVM_URL}      | tar --strip-components=1 -xJ -C ${LLVM_DIR}
         travis_retry wget --quiet -O - ${LIBCXX_URL}    | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx
         travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi
         travis_retry wget --quiet -O - ${CLANG_URL}     | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang
         (cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++)
         (cd ${LLVM_DIR}/build/projects/libcxx && make install -j2)
         (cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2)
       fi
N
Niels 已提交
261
       export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1"
N
Niels 已提交
262 263 264 265
       export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi"
       export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib"
       export PATH="${LLVM_DIR}/clang/bin:${PATH}"
     fi
N
Niels 已提交
266 267 268 269 270

################
# build script #
################

N
Niels 已提交
271 272 273 274 275
script:
  # show OS/compiler version
  - uname -a
  - $CXX --version

276
  # compile and execute unit tests
277 278 279 280
  - mkdir -p build && cd build
  - cmake .. && cmake --build . --config Release -- -j4
  - ctest -C Release -V
  - cd ..
N
Niels 已提交
281 282 283 284 285 286 287

  # check if homebrew works (only checks develop branch)
  - if [ `which brew` ]; then
    brew update ;
    brew tap nlohmann/json ;
    brew install nlohmann_json --HEAD ;
    brew test nlohmann_json ;
N
Niels 已提交
288
    fi