.travis.yml 8.0 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
10
group: edge
N
Niels 已提交
11

N
Niels 已提交
12

N
Niels 已提交
13 14 15 16 17 18 19 20 21 22 23
###################
# 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 已提交
24 25 26
################
# build matrix #
################
N
Niels 已提交
27

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

31 32 33 34 35
  # Valgrind
  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
36
      - CMAKE_OPTIONS=-DJSON_Valgrind=ON
37 38 39 40 41
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: [g++-4.9, valgrind]

42
  # clang sanitizer
43
  - os: linux
44
    compiler: clang
45
    env:
46
      - COMPILER=clang++-5.0
47
      - CMAKE_OPTIONS=-DJSON_Sanitizer=ON
48 49
    addons:
      apt:
50
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
51
        packages: ['g++-6', 'clang-5.0']
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

  # 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

  # no exceptions

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
      - SPECIAL=no_exceptions
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: [g++-4.9, cppcheck]
    after_success:
      - make clean
      - CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN="-e \"*\""

  # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)

  - os: linux
    compiler: gcc
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: ['g++-4.9', 'ruby']
    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
      - pip install --user cpp-coveralls
    after_success:
      - make clean
      - CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make json_unit
      - test/json_unit "*"
      - 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
    compiler: clang
    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:
114 115
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
116
        packages: ['g++-6', 'clang-3.6']
117 118 119 120 121 122 123 124 125 126
      coverity_scan:
        project:
          name: "nlohmann/json"
          description: "Build submitted via Travis CI"
        notification_email: niels.lohmann@gmail.com
        build_command_prepend: "make clean"
        build_command: "make"
        branch_pattern: coverity_scan
    env:
      - SPECIAL=coverity
127
      - COMPILER=clang++-3.6
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

  # OSX / Clang

  - os: osx
    osx_image: xcode6.4

  - os: osx
    osx_image: xcode7.3

  - os: osx
    osx_image: xcode8

  - os: osx
    osx_image: xcode8.1

  - os: osx
    osx_image: xcode8.2

  - os: osx
    osx_image: xcode8.3

  - os: osx
    osx_image: xcode9

  # Linux / GCC

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

  - os: linux
    compiler: gcc
    env: COMPILER=g++-5
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-5

  - os: linux
    compiler: gcc
    env: COMPILER=g++-6
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-6

  - os: linux
    compiler: gcc
    env: COMPILER=g++-7
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-7

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-7
      - CXXFLAGS=-std=c++17
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: g++-7

  # Linux / Clang

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.5
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
204
        packages: ['g++-6', 'clang-3.5']
205

N
Niels Lohmann 已提交
206
  - os: linux
207
    compiler: clang
208
    env: COMPILER=clang++-3.6
N
Niels Lohmann 已提交
209 210
    addons:
      apt:
211
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
212
        packages: ['g++-6', 'clang-3.6']
213 214 215 216 217 218 219

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.7
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
220
        packages: ['g++-6', 'clang-3.7']
221 222 223 224 225 226 227

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.8
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
228
        packages: ['g++-6', 'clang-3.8']
229 230 231 232 233 234 235

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.9
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
236
        packages: ['g++-6', 'clang-3.9']
237 238 239 240 241 242 243

  - os: linux
    compiler: clang
    env: COMPILER=clang++-4.0
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
244
        packages: ['g++-6', 'clang-4.0']
N
Niels 已提交
245

246 247
  - os: linux
    compiler: clang
248
    env: COMPILER=clang++-5.0
249 250
    addons:
      apt:
251
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
252
        packages: ['g++-6', 'clang-5.0']
253

254 255
  - os: linux
    compiler: clang
256 257 258
    env:
      - COMPILER=clang++-5.0
      - CXXFLAGS=-std=c++1z
259 260 261
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
262
        packages: ['g++-6', 'clang-5.0']
263

N
Niels 已提交
264 265 266 267
################
# build script #
################

N
Niels 已提交
268
script:
269 270 271 272 273 274 275 276
  # 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 Lohmann 已提交
277 278 279
  # make sure CXX is correctly set
  - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi

N
Niels 已提交
280 281 282 283
  # show OS/compiler version
  - uname -a
  - $CXX --version

284
  # compile and execute unit tests
285
  - mkdir -p build && cd build
286
  - cmake .. ${CMAKE_OPTIONS} && cmake --build . --config Release -- -j4
287 288
  - ctest -C Release -V
  - cd ..
289 290 291 292 293 294 295 296

  # 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 ;
    fi