.travis.yml 6.6 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
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
40
        packages: ['g++-4.9', 'valgrind', 'ninja-build']
41

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', 'ninja-build']
52 53 54 55 56 57 58 59 60 61

  # cppcheck
  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
      - SPECIAL=cppcheck
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
62
        packages: ['g++-4.9', 'cppcheck', 'ninja-build']
63 64 65 66 67 68 69 70
    after_success:
      - make cppcheck

  # no exceptions
  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-4.9
71
      - CMAKE_OPTIONS=-DJSON_NoExceptions=ON
72 73 74
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
75
        packages: ['g++-4.9', 'ninja-build']
76 77 78 79 80 81 82 83

  # 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']
84
        packages: ['g++-4.9', 'ninja-build']
85 86 87
    before_script:
      - pip install --user cpp-coveralls
    after_success:
88
      - coveralls --build-root test --include src --gcov 'gcov-4.9' --gcov-options '\-lp'
89 90
    env:
      - COMPILER=g++-4.9
91
      - CMAKE_OPTIONS=-DJSON_Coverage=ON
92 93 94 95 96 97 98 99
      - 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:
100 101
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
102
        packages: ['g++-6', 'clang-3.6', 'ninja-build']
103 104 105 106 107
      coverity_scan:
        project:
          name: "nlohmann/json"
          description: "Build submitted via Travis CI"
        notification_email: niels.lohmann@gmail.com
108 109
        build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
        build_command: "make -C coverity_build"
110 111 112
        branch_pattern: coverity_scan
    env:
      - SPECIAL=coverity
113
      - COMPILER=clang++-3.6
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

  # 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']
146
        packages: ['g++-4.9', 'ninja-build']
147 148 149 150 151 152 153

  - os: linux
    compiler: gcc
    env: COMPILER=g++-5
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
154
        packages: ['g++-5', 'ninja-build']
155 156 157 158 159 160 161

  - os: linux
    compiler: gcc
    env: COMPILER=g++-6
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
162
        packages: ['g++-6', 'ninja-build']
163 164 165 166 167 168 169

  - os: linux
    compiler: gcc
    env: COMPILER=g++-7
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
170
        packages: ['g++-7', 'ninja-build']
171 172 173 174 175 176 177 178 179

  - os: linux
    compiler: gcc
    env:
      - COMPILER=g++-7
      - CXXFLAGS=-std=c++17
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
180
        packages: ['g++-7', 'ninja-build']
181 182 183 184 185 186 187 188 189

  # Linux / Clang

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

N
Niels Lohmann 已提交
192
  - os: linux
193
    compiler: clang
194
    env: COMPILER=clang++-3.6
N
Niels Lohmann 已提交
195 196
    addons:
      apt:
197
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
198
        packages: ['g++-6', 'clang-3.6', 'ninja-build']
199 200 201 202 203 204 205

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.7
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
206
        packages: ['g++-6', 'clang-3.7', 'ninja-build']
207 208 209 210 211 212 213

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.8
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
214
        packages: ['g++-6', 'clang-3.8', 'ninja-build']
215 216 217 218 219 220 221

  - os: linux
    compiler: clang
    env: COMPILER=clang++-3.9
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test']
222
        packages: ['g++-6', 'clang-3.9', 'ninja-build']
223 224 225 226 227 228 229

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

232 233
  - os: linux
    compiler: clang
234
    env: COMPILER=clang++-5.0
235 236
    addons:
      apt:
237
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
238
        packages: ['g++-6', 'clang-5.0', 'ninja-build']
239

240 241
  - os: linux
    compiler: clang
242 243 244
    env:
      - COMPILER=clang++-5.0
      - CXXFLAGS=-std=c++1z
245 246 247
    addons:
      apt:
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
248
        packages: ['g++-6', 'clang-5.0', 'ninja-build']
249

N
Niels 已提交
250 251 252 253
################
# build script #
################

N
Niels 已提交
254
script:
255
  # get CMake and Ninja (only for systems with brew - macOS)
256
  - |
257
     if [[ (-x $(which brew)) ]]; then
258
       brew update
259
       brew install cmake ninja
260 261 262
       cmake --version
     fi

N
Niels Lohmann 已提交
263 264 265
  # make sure CXX is correctly set
  - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi

N
Niels 已提交
266 267 268 269
  # show OS/compiler version
  - uname -a
  - $CXX --version

270
  # compile and execute unit tests
271
  - mkdir -p build && cd build
272
  - cmake .. ${CMAKE_OPTIONS} -GNinja && cmake --build . --config Release
273 274
  - ctest -C Release -V
  - cd ..
275 276 277 278 279 280 281 282

  # 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