• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#########################
2# project configuration #
3#########################
4
5# C++ project
6language: cpp
7
8dist: trusty
9sudo: required
10group: edge
11
12
13################
14# build matrix #
15################
16
17matrix:
18  include:
19
20  # Valgrind
21  - os: linux
22    compiler: gcc
23    env:
24      - COMPILER=g++-4.9
25      - CMAKE_OPTIONS=-DJSON_Valgrind=ON
26    addons:
27      apt:
28        sources: ['ubuntu-toolchain-r-test']
29        packages: ['g++-4.9', 'valgrind', 'ninja-build']
30
31  # clang sanitizer
32  - os: linux
33    compiler: clang
34    env:
35      - COMPILER=clang++-7
36      - CMAKE_OPTIONS=-DJSON_Sanitizer=ON
37      - UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp
38    addons:
39      apt:
40        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
41        packages: ['g++-6', 'clang-7', 'ninja-build']
42    before_script:
43      - export PATH=$PATH:/usr/lib/llvm-7/bin
44
45  # cppcheck
46  - os: linux
47    compiler: gcc
48    env:
49      - COMPILER=g++-4.9
50      - SPECIAL=cppcheck
51    addons:
52      apt:
53        sources: ['ubuntu-toolchain-r-test']
54        packages: ['g++-4.9', 'cppcheck', 'ninja-build']
55    after_success:
56      - make cppcheck
57
58  # no exceptions
59  - os: linux
60    compiler: gcc
61    env:
62      - COMPILER=g++-4.9
63      - CMAKE_OPTIONS=-DJSON_NoExceptions=ON
64    addons:
65      apt:
66        sources: ['ubuntu-toolchain-r-test']
67        packages: ['g++-4.9', 'ninja-build']
68
69  # check amalgamation
70  - os: linux
71    compiler: gcc
72    env:
73      - COMPILER=g++-4.9
74      - SPECIAL=amalgamation
75      - MULTIPLE_HEADERS=ON
76    addons:
77      apt:
78        sources: ['ubuntu-toolchain-r-test']
79        packages: ['g++-4.9', 'astyle', 'ninja-build']
80    after_success:
81      - make check-amalgamation
82
83  # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
84
85  - os: linux
86    compiler: gcc
87    dist: bionic
88    addons:
89      apt:
90        sources: ['ubuntu-toolchain-r-test']
91        packages: ['g++-7', 'ninja-build']
92    before_script:
93      - pip install --user cpp-coveralls
94    after_success:
95      - coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp'
96    env:
97      - COMPILER=g++-7
98      - CMAKE_OPTIONS=-DJSON_Coverage=ON
99      - MULTIPLE_HEADERS=ON
100
101  # Coverity (only for branch coverity_scan)
102
103  - os: linux
104    compiler: clang
105    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
106    addons:
107      apt:
108        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
109        packages: ['g++-6', 'clang-3.6', 'ninja-build']
110      coverity_scan:
111        project:
112          name: "nlohmann/json"
113          description: "Build submitted via Travis CI"
114        notification_email: niels.lohmann@gmail.com
115        build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
116        build_command: "make -C coverity_build"
117        branch_pattern: coverity_scan
118    env:
119      - SPECIAL=coverity
120      - COMPILER=clang++-3.6
121        # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
122        #   via the "travis encrypt" command using the project repo's public key
123      - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
124
125  # OSX / Clang
126
127  - os: osx
128    osx_image: xcode9.3
129
130  - os: osx
131    osx_image: xcode9.4
132
133  - os: osx
134    osx_image: xcode10
135
136  - os: osx
137    osx_image: xcode10.1
138
139  - os: osx
140    osx_image: xcode10.2
141
142  - os: osx
143    osx_image: xcode11.2
144
145  - os: osx
146    osx_image: xcode12
147
148  - os: osx
149    osx_image: xcode12
150    env:
151      - IMPLICIT_CONVERSIONS=OFF
152
153  # Linux / GCC
154
155  - os: linux
156    compiler: gcc
157    env: COMPILER=g++-4.8
158    addons:
159      apt:
160        sources: ['ubuntu-toolchain-r-test']
161        packages: ['g++-4.8', 'ninja-build']
162
163  - os: linux
164    compiler: gcc
165    env: COMPILER=g++-4.9
166    addons:
167      apt:
168        sources: ['ubuntu-toolchain-r-test']
169        packages: ['g++-4.9', 'ninja-build']
170
171  - os: linux
172    compiler: gcc
173    env: COMPILER=g++-5
174    addons:
175      apt:
176        sources: ['ubuntu-toolchain-r-test']
177        packages: ['g++-5', 'ninja-build']
178
179  - os: linux
180    compiler: gcc
181    env: COMPILER=g++-6
182    addons:
183      apt:
184        sources: ['ubuntu-toolchain-r-test']
185        packages: ['g++-6', 'ninja-build']
186
187  - os: linux
188    compiler: gcc
189    env: COMPILER=g++-7
190    addons:
191      apt:
192        sources: ['ubuntu-toolchain-r-test']
193        packages: ['g++-7', 'ninja-build']
194
195  - os: linux
196    compiler: gcc
197    env: COMPILER=g++-8
198    addons:
199      apt:
200        sources: ['ubuntu-toolchain-r-test']
201        packages: ['g++-8', 'ninja-build']
202
203  - os: linux
204    compiler: gcc
205    env: COMPILER=g++-9
206    addons:
207      apt:
208        sources: ['ubuntu-toolchain-r-test']
209        packages: ['g++-9', 'ninja-build']
210
211  - os: linux
212    compiler: gcc
213    env:
214      - COMPILER=g++-9
215      - IMPLICIT_CONVERSIONS=OFF
216    addons:
217      apt:
218        sources: ['ubuntu-toolchain-r-test']
219        packages: ['g++-9', 'ninja-build']
220
221  - os: linux
222    compiler: gcc
223    env:
224      - COMPILER=g++-9
225      - CXXFLAGS=-std=c++2a
226    addons:
227      apt:
228        sources: ['ubuntu-toolchain-r-test']
229        packages: ['g++-9', 'ninja-build']
230
231  # Linux / Clang
232
233  - os: linux
234    compiler: clang
235    env: COMPILER=clang++-3.5
236    addons:
237      apt:
238        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
239        packages: ['g++-6', 'clang-3.5', 'ninja-build']
240
241  - os: linux
242    compiler: clang
243    env: COMPILER=clang++-3.6
244    addons:
245      apt:
246        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
247        packages: ['g++-6', 'clang-3.6', 'ninja-build']
248
249  - os: linux
250    compiler: clang
251    env: COMPILER=clang++-3.7
252    addons:
253      apt:
254        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
255        packages: ['g++-6', 'clang-3.7', 'ninja-build']
256
257  - os: linux
258    compiler: clang
259    env: COMPILER=clang++-3.8
260    addons:
261      apt:
262        sources: ['ubuntu-toolchain-r-test']
263        packages: ['g++-6', 'clang-3.8', 'ninja-build']
264
265  - os: linux
266    compiler: clang
267    env: COMPILER=clang++-3.9
268    addons:
269      apt:
270        sources: ['ubuntu-toolchain-r-test']
271        packages: ['g++-6', 'clang-3.9', 'ninja-build']
272
273  - os: linux
274    compiler: clang
275    env: COMPILER=clang++-4.0
276    addons:
277      apt:
278        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
279        packages: ['g++-6', 'clang-4.0', 'ninja-build']
280
281  - os: linux
282    compiler: clang
283    env: COMPILER=clang++-5.0
284    addons:
285      apt:
286        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
287        packages: ['g++-6', 'clang-5.0', 'ninja-build']
288
289  - os: linux
290    compiler: clang
291    env: COMPILER=clang++-6.0
292    addons:
293      apt:
294        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0']
295        packages: ['g++-6', 'clang-6.0', 'ninja-build']
296
297  - os: linux
298    compiler: clang
299    env: COMPILER=clang++-7
300    addons:
301      apt:
302        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
303        packages: ['g++-6', 'clang-7', 'ninja-build']
304
305  - os: linux
306    compiler: clang
307    env:
308      - COMPILER=clang++-7
309      - CXXFLAGS=-std=c++1z
310    addons:
311      apt:
312        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
313        packages: ['g++-6', 'clang-7', 'ninja-build']
314
315################
316# build script #
317################
318
319script:
320  # get CMake and Ninja (only for systems with brew - macOS)
321  - |
322     if [[ (-x $(which brew)) ]]; then
323       brew update
324       brew install cmake ninja
325       brew upgrade cmake
326       cmake --version
327     fi
328
329  # make sure CXX is correctly set
330  - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
331  # by default, use the single-header version
332  - if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
333  # by default, use implicit conversions
334  - if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi
335
336  # compile and execute unit tests
337  - mkdir -p build && cd build
338  - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
339  - ctest -C Release --timeout 2700 -V -j
340  - cd ..
341
342  # check if homebrew works (only checks develop branch)
343  - if [ `which brew` ]; then
344    brew update ;
345    brew tap nlohmann/json ;
346    brew install nlohmann_json --HEAD ;
347    brew test nlohmann_json ;
348    fi
349