travis_linux_script.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. #!/bin/bash
  2. set -e
  3. # Sonar code quality
  4. if ! [ -z ${SONAR+x} ]; then
  5. if ([ "${TRAVIS_REPO_SLUG}" != "open62541/open62541" ] ||
  6. [ "${TRAVIS_PULL_REQUEST}" != "false" ] ||
  7. [ "${TRAVIS_BRANCH}" != "master" ]); then
  8. echo "Skipping Sonarcloud on forks"
  9. # Skip on forks
  10. exit 0;
  11. fi
  12. mkdir -p build && cd build
  13. build-wrapper-linux-x86-64 --out-dir ../bw-output cmake \
  14. -DCMAKE_BUILD_TYPE=Debug \
  15. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  16. -DUA_BUILD_EXAMPLES=ON \
  17. -DUA_ENABLE_DISCOVERY=ON \
  18. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  19. -DUA_ENABLE_ENCRYPTION .. \
  20. && make -j
  21. cd ..
  22. sonar-scanner
  23. exit 0
  24. fi
  25. # Docker build test
  26. if ! [ -z ${DOCKER+x} ]; then
  27. docker build -t open62541 -f docker/Dockerfile .
  28. docker run -d -p 127.0.0.1:4840:4840 --name open62541 open62541 /bin/sh
  29. docker ps | grep -q open62541
  30. # disabled since it randomly fails
  31. # docker ps | grep -q open62541
  32. exit 0
  33. fi
  34. # Cpplint checking
  35. if ! [ -z ${LINT+x} ]; then
  36. mkdir -p build
  37. cd build
  38. cmake ..
  39. make cpplint
  40. if [ $? -ne 0 ] ; then exit 1 ; fi
  41. exit 0
  42. fi
  43. # Fuzzer build test
  44. if ! [ -z ${FUZZER+x} ]; then
  45. # First check if the build is successful
  46. ./tests/fuzz/check_build.sh
  47. if [ $? -ne 0 ] ; then exit 1 ; fi
  48. # Test the corpus generator and use new corpus for fuzz test
  49. ./tests/fuzz/generate_corpus.sh
  50. if [ $? -ne 0 ] ; then exit 1 ; fi
  51. cd build_fuzz
  52. make && make run_fuzzer
  53. if [ $? -ne 0 ] ; then exit 1 ; fi
  54. exit 0
  55. fi
  56. # INSTALL build test
  57. if ! [ -z ${INSTALL+x} ]; then
  58. echo "=== Install build, then compile examples ===" && echo -en 'travis_fold:start:script.build.install\\r'
  59. # Use make install to deploy files and then test if we can build the examples based on the installed files
  60. mkdir -p build
  61. cd build
  62. cmake \
  63. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  64. -DBUILD_SHARED_LIBS=ON \
  65. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  66. -DUA_NAMESPACE_ZERO=FULL \
  67. -DUA_ENABLE_AMALGAMATION=OFF \
  68. -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/open62541_install ..
  69. make -j install
  70. if [ $? -ne 0 ] ; then exit 1 ; fi
  71. cd .. && rm build -rf
  72. echo -en 'travis_fold:end:script.build.install\\r'
  73. echo -en 'travis_fold:start:script.build.mini-example\\r'
  74. # Now create a simple CMake Project which uses the installed file
  75. mkdir compile
  76. cp -r examples compile/examples && cd compile/examples
  77. cmake \
  78. -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/open62541_install \
  79. -DUA_NAMESPACE_ZERO=FULL .
  80. make -j
  81. if [ $? -ne 0 ] ; then exit 1 ; fi
  82. cd ../..
  83. rm -rf compile
  84. echo -en 'travis_fold:end:script.build.mini-example\\r'
  85. exit 0
  86. fi
  87. if ! [ -z ${CLANG_FORMAT+x} ]; then
  88. # Only run clang format on Pull requests, not on direct push
  89. if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
  90. echo -en "\\nSkipping clang-format on non-pull request\\n"
  91. exit 0
  92. fi
  93. echo "=== Running clang-format with diff against branch '$TRAVIS_BRANCH' ===" && echo -en 'travis_fold:start:script.clang-format\\r'
  94. # add clang-format-ci
  95. curl -Ls "https://raw.githubusercontent.com/llvm-mirror/clang/c510fac5695e904b43d5bf0feee31cc9550f110e/tools/clang-format/git-clang-format" -o "$LOCAL_PKG/bin/git-clang-format"
  96. chmod +x $LOCAL_PKG/bin/git-clang-format
  97. # Ignore files in the deps directory diff by resetting them to master
  98. git diff --name-only $TRAVIS_BRANCH | grep 'deps/*' | xargs git checkout $TRAVIS_BRANCH --
  99. # clang-format the diff to the target branch of the PR
  100. difference="$($LOCAL_PKG/bin/git-clang-format --style=file --diff $TRAVIS_BRANCH)"
  101. if ! case $difference in *"no modified files to format"*) false;; esac; then
  102. echo "====== clang-format did not find any issues. Well done! ======"
  103. exit 0
  104. fi
  105. if ! case $difference in *"clang-format did not modify any files"*) false;; esac; then
  106. echo "====== clang-format did not find any issues. Well done! ======"
  107. exit 0
  108. fi
  109. echo "====== clang-format Format Errors ======"
  110. echo "Uploading the patch to a pastebin page ..."
  111. pastebinUrl="$($LOCAL_PKG/bin/git-clang-format --style=file --diff $TRAVIS_BRANCH | curl -F 'sprunge=<-' http://sprunge.us)"
  112. echo "Created a patch file under: $pastebinUrl"
  113. echo "Please fix the following issues.\n\n"
  114. echo "You can also use the following command to apply the diff to your source locally:\n-------------\n"
  115. echo "curl -o format.patch $pastebinUrl && git apply format.patch\n-------------\n"
  116. echo "=============== DIFFERENCE - START =================\n"
  117. # We want to get colored diff output into the variable
  118. git config color.diff always
  119. $LOCAL_PKG/bin/git-clang-format --binary=clang-format-6.0 --style=file --diff $TRAVIS_BRANCH
  120. echo "\n============= DIFFERENCE - END ===================="
  121. echo -en 'travis_fold:start:script.clang-format\\r'
  122. exit 1
  123. fi
  124. if ! [ -z ${ANALYZE+x} ]; then
  125. echo "=== Running static code analysis ===" && echo -en 'travis_fold:start:script.analyze\\r'
  126. if ! case $CC in clang*) false;; esac; then
  127. mkdir -p build
  128. cd build
  129. scan-build-6.0 cmake \
  130. -DUA_BUILD_EXAMPLES=ON \
  131. -DUA_BUILD_UNIT_TESTS=ON ..
  132. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  133. -enable-checker security.insecureAPI.UncheckedReturn \
  134. --status-bugs -v \
  135. make -j
  136. cd .. && rm build -rf
  137. mkdir -p build
  138. cd build
  139. scan-build-6.0 cmake \
  140. -DUA_ENABLE_PUBSUB=ON \
  141. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  142. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON ..
  143. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  144. -enable-checker security.insecureAPI.UncheckedReturn \
  145. --status-bugs -v \
  146. make -j
  147. cd .. && rm build -rf
  148. mkdir -p build
  149. cd build
  150. scan-build-6.0 cmake \
  151. -DUA_ENABLE_AMALGAMATION=OFF ..
  152. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  153. -enable-checker security.insecureAPI.UncheckedReturn \
  154. --status-bugs -v \
  155. make -j
  156. cd .. && rm build -rf
  157. #mkdir -p build && cd build
  158. #cmake -DUA_ENABLE_STATIC_ANALYZER=REDUCED ..
  159. ## previous clang-format to reduce to non-trivial warnings
  160. #make clangformat
  161. #make
  162. #cd .. && rm build -rf
  163. else
  164. cppcheck --template "{file}({line}): {severity} ({id}): {message}" \
  165. --enable=style --force --std=c++11 -j 8 \
  166. --suppress=duplicateBranch \
  167. --suppress=incorrectStringBooleanError \
  168. --suppress=invalidscanf --inline-suppr \
  169. -I include src plugins examples 2> cppcheck.txt
  170. if [ -s cppcheck.txt ]; then
  171. echo "====== CPPCHECK Static Analysis Errors ======"
  172. cat cppcheck.txt
  173. # flush output
  174. sleep 5
  175. exit 1
  176. fi
  177. fi
  178. echo -en 'travis_fold:end:script.analyze\\r'
  179. exit 0
  180. fi
  181. echo -en "\r\n=== Building ===\r\n"
  182. echo -e "\r\n== Documentation build ==" && echo -en 'travis_fold:start:script.build.doc\\r'
  183. mkdir -p build
  184. cd build
  185. cmake \
  186. -DCMAKE_BUILD_TYPE=Release \
  187. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  188. -DUA_BUILD_EXAMPLES=ON ..
  189. make doc
  190. make doc_pdf
  191. cp -r doc ../../
  192. cp -r doc_latex ../../
  193. cd .. && rm build -rf
  194. echo -en 'travis_fold:end:script.build.doc\\r'
  195. # cross compilation only with gcc
  196. if ! [ -z ${MINGW+x} ]; then
  197. echo -e "\r\n== Cross compile release build for MinGW 32 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw32\\r'
  198. mkdir -p build && cd build
  199. cmake \
  200. -DBUILD_SHARED_LIBS=ON \
  201. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  202. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-win32 \
  203. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake \
  204. -DUA_BUILD_EXAMPLES=ON \
  205. -DUA_ENABLE_AMALGAMATION=OFF ..
  206. make -j
  207. if [ $? -ne 0 ] ; then exit 1 ; fi
  208. make install
  209. if [ $? -ne 0 ] ; then exit 1 ; fi
  210. cd ..
  211. zip -r open62541-win32.zip ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-win32/*
  212. rm build -rf
  213. echo -en 'travis_fold:end:script.build.cross_mingw32\\r'
  214. echo -e "\r\n== Cross compile release build for MinGW 64 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw64\\r'
  215. mkdir -p build && cd build
  216. cmake \
  217. -DBUILD_SHARED_LIBS=ON \
  218. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  219. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-win64 \
  220. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake \
  221. -DUA_BUILD_EXAMPLES=ON \
  222. -DUA_ENABLE_AMALGAMATION=OFF ..
  223. make -j
  224. if [ $? -ne 0 ] ; then exit 1 ; fi
  225. make install
  226. if [ $? -ne 0 ] ; then exit 1 ; fi
  227. cd ..
  228. zip -r open62541-win64.zip ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-win64/*
  229. rm build -rf
  230. echo -en 'travis_fold:end:script.build.cross_mingw64\\r'
  231. echo -e "\r\n== Cross compile release build for 32-bit linux ==" && echo -en 'travis_fold:start:script.build.cross_linux\\r'
  232. mkdir -p build && cd build
  233. cmake \
  234. -DBUILD_SHARED_LIBS=ON \
  235. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  236. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux32 \
  237. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake \
  238. -DUA_BUILD_EXAMPLES=ON \
  239. -DUA_ENABLE_AMALGAMATION=OFF ..
  240. make -j
  241. if [ $? -ne 0 ] ; then exit 1 ; fi
  242. make install
  243. if [ $? -ne 0 ] ; then exit 1 ; fi
  244. cd ..
  245. tar -pczf open62541-linux32.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-linux32/*
  246. rm build -rf
  247. echo -en 'travis_fold:end:script.build.cross_linux\\r'
  248. echo -e "\r\n== Cross compile release build for RaspberryPi ==" && echo -en 'travis_fold:start:script.build.cross_raspi\\r'
  249. mkdir -p build && cd build
  250. git clone https://github.com/raspberrypi/tools
  251. export PATH=$PATH:${TRAVIS_BUILD_DIR}/build/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
  252. cmake \
  253. -DBUILD_SHARED_LIBS=ON \
  254. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  255. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-raspberrypi \
  256. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-rpi64.cmake \
  257. -DUA_BUILD_EXAMPLES=ON \
  258. -DUA_ENABLE_AMALGAMATION=OFF ..
  259. make -j
  260. if [ $? -ne 0 ] ; then exit 1 ; fi
  261. make install
  262. if [ $? -ne 0 ] ; then exit 1 ; fi
  263. cd ..
  264. tar -pczf open62541-raspberrypi.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-raspberrypi/*
  265. rm build -rf
  266. echo -en 'travis_fold:end:script.build.cross_raspi\\r'
  267. fi
  268. echo -e "\r\n== Compile release build for 64-bit linux ==" && echo -en 'travis_fold:start:script.build.linux_64\\r'
  269. mkdir -p build && cd build
  270. cmake \
  271. -DBUILD_SHARED_LIBS=ON \
  272. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  273. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux64 \
  274. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  275. -DUA_BUILD_EXAMPLES=ON \
  276. -DUA_ENABLE_AMALGAMATION=OFF ..
  277. make -j
  278. if [ $? -ne 0 ] ; then exit 1 ; fi
  279. make install
  280. if [ $? -ne 0 ] ; then exit 1 ; fi
  281. cd ..
  282. tar -pczf open62541-linux64.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-linux64/*
  283. rm build -rf
  284. echo -en 'travis_fold:end:script.build.linux_64\\r'
  285. echo -e "\r\n== Compile with amalgamation ==" && echo -en 'travis_fold:start:script.build.amalgamate\\r'
  286. mkdir -p build && cd build
  287. cmake \
  288. -DBUILD_SHARED_LIBS=ON \
  289. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  290. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux64 \
  291. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  292. -DUA_BUILD_EXAMPLES=OFF \
  293. -DUA_ENABLE_AMALGAMATION=ON \
  294. -DUA_ENABLE_HISTORIZING=ON ..
  295. make -j
  296. cp open62541.h ../.. # copy single file-release
  297. cp open62541.c ../.. # copy single file-release
  298. gcc -std=c99 -c open62541.c
  299. g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  300. if [ $? -ne 0 ] ; then exit 1 ; fi
  301. cd .. && rm build -rf
  302. echo -en 'travis_fold:end:script.build.amalgamate\\r'
  303. echo "Compile as shared lib version" && echo -en 'travis_fold:start:script.build.shared_libs\\r'
  304. mkdir -p build && cd build
  305. cmake \
  306. -DBUILD_SHARED_LIBS=ON \
  307. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  308. -DUA_BUILD_EXAMPLES=ON \
  309. -DUA_ENABLE_AMALGAMATION=OFF ..
  310. make -j
  311. if [ $? -ne 0 ] ; then exit 1 ; fi
  312. cd .. && rm build -rf
  313. echo -en 'travis_fold:end:script.build.shared_libs\\r'
  314. if [ "$CC" != "tcc" ]; then
  315. echo -e "\r\n==Compile multithreaded version==" && echo -en 'travis_fold:start:script.build.multithread\\r'
  316. mkdir -p build && cd build
  317. cmake \
  318. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  319. -DUA_BUILD_EXAMPLES=ON \
  320. -DUA_MULTITHREADING=200 ..
  321. make -j
  322. if [ $? -ne 0 ] ; then exit 1 ; fi
  323. cd .. && rm build -rf
  324. echo -en 'travis_fold:end:script.build.multithread\\r'
  325. fi
  326. echo -e "\r\n== Compile with encryption ==" && echo -en 'travis_fold:start:script.build.encryption\\r'
  327. mkdir -p build && cd build
  328. cmake \
  329. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  330. -DUA_BUILD_EXAMPLES=ON \
  331. -DUA_ENABLE_ENCRYPTION=ON ..
  332. make -j
  333. if [ $? -ne 0 ] ; then exit 1 ; fi
  334. cd .. && rm build -rf
  335. echo -en 'travis_fold:end:script.build.encryption\\r'
  336. echo -e "\r\n== Compile without discovery version ==" && echo -en 'travis_fold:start:script.build.discovery\\r'
  337. mkdir -p build && cd build
  338. cmake \
  339. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  340. -DUA_BUILD_EXAMPLES=ON \
  341. -DUA_ENABLE_DISCOVERY=OFF \
  342. -DUA_ENABLE_DISCOVERY_MULTICAST=OFF ..
  343. make -j
  344. if [ $? -ne 0 ] ; then exit 1 ; fi
  345. cd .. && rm build -rf
  346. echo -en 'travis_fold:end:script.build.discovery\\r'
  347. if [ "$CC" != "tcc" ]; then
  348. echo -e "\r\n== Compile multithreaded version with discovery ==" && echo -en 'travis_fold:start:script.build.multithread_discovery\\r'
  349. mkdir -p build && cd build
  350. cmake \
  351. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  352. -DUA_BUILD_EXAMPLES=ON \
  353. -DUA_ENABLE_DISCOVERY=ON \
  354. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  355. -DUA_MULTITHREADING=200 ..
  356. make -j
  357. if [ $? -ne 0 ] ; then exit 1 ; fi
  358. cd .. && rm build -rf
  359. echo -en 'travis_fold:end:script.build.multithread_discovery\\r'
  360. fi
  361. echo -e "\r\n== Compile JSON encoding ==" && echo -en 'travis_fold:start:script.build.json\\r'
  362. mkdir -p build && cd build
  363. cmake \
  364. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  365. -DUA_ENABLE_JSON_ENCODING=ON ..
  366. make -j
  367. if [ $? -ne 0 ] ; then exit 1 ; fi
  368. cd .. && rm build -rf
  369. echo -en 'travis_fold:end:script.build.json\\r'
  370. echo -e "\r\n== Compile PubSub MQTT ==" && echo -en 'travis_fold:start:script.build.mqtt\\r'
  371. mkdir -p build && cd build
  372. cmake \
  373. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  374. -DUA_ENABLE_PUBSUB=ON -DUA_ENABLE_PUBSUB_MQTT=ON ..
  375. make -j
  376. if [ $? -ne 0 ] ; then exit 1 ; fi
  377. cd .. && rm build -rf
  378. echo -en 'travis_fold:end:script.build.mqtt\\r'
  379. echo -e "\r\n== Unit tests (full NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_full\\r'
  380. mkdir -p build && cd build
  381. # Valgrind cannot handle the full NS0 because the generated file is too big. Thus run NS0 full without valgrind
  382. cmake \
  383. -DCMAKE_BUILD_TYPE=Debug \
  384. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  385. -DUA_BUILD_EXAMPLES=ON \
  386. -DUA_BUILD_UNIT_TESTS=ON \
  387. -DUA_ENABLE_COVERAGE=OFF \
  388. -DUA_ENABLE_DA=ON \
  389. -DUA_ENABLE_DISCOVERY=ON \
  390. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  391. -DUA_ENABLE_ENCRYPTION=ON \
  392. -DUA_ENABLE_JSON_ENCODING=ON \
  393. -DUA_ENABLE_PUBSUB=ON \
  394. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  395. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON \
  396. -DUA_ENABLE_PUBSUB_MQTT=ON \
  397. -DUA_ENABLE_SUBSCRIPTIONS=ON \
  398. -DUA_ENABLE_SUBSCRIPTIONS_EVENTS=ON \
  399. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=OFF \
  400. -DUA_NAMESPACE_ZERO=FULL ..
  401. make -j && make test ARGS="-V"
  402. if [ $? -ne 0 ] ; then exit 1 ; fi
  403. cd .. && rm build -rf
  404. echo -en 'travis_fold:end:script.build.unit_test_ns0_full\\r'
  405. if ! [ -z ${DEBIAN+x} ]; then
  406. echo -e "\r\n== Building the Debian package ==" && echo -en 'travis_fold:start:script.build.debian\\r'
  407. /usr/bin/$PYTHON ./tools/prepare_packaging.py
  408. echo -e "\r\n --- New debian changelog content ---"
  409. echo "--------------------------------------"
  410. cat ./debian/changelog
  411. echo "--------------------------------------"
  412. # Create a backup copy. We need the clean debian directory for later packaging
  413. cp -r debian debian_bak
  414. dpkg-buildpackage -b
  415. if [ $? -ne 0 ] ; then exit 1 ; fi
  416. rm -rf debian
  417. mv debian_bak debian
  418. cp ../libopen62541*.deb .
  419. # Copy for github release script
  420. cp ../libopen62541*.deb ../..
  421. echo -en 'travis_fold:end:script.build.debian\\r'
  422. fi
  423. if [ "$CC" != "tcc" ]; then
  424. echo -e "\r\n== Unit tests (minimal NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_minimal\\r'
  425. mkdir -p build && cd build
  426. cmake \
  427. -DCMAKE_BUILD_TYPE=Debug \
  428. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  429. -DUA_BUILD_EXAMPLES=ON \
  430. -DUA_BUILD_UNIT_TESTS=ON \
  431. -DUA_ENABLE_COVERAGE=ON \
  432. -DUA_ENABLE_DA=ON \
  433. -DUA_ENABLE_DISCOVERY=ON \
  434. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  435. -DUA_ENABLE_ENCRYPTION=ON \
  436. -DUA_ENABLE_JSON_ENCODING=ON \
  437. -DUA_ENABLE_PUBSUB=ON \
  438. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  439. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=OFF \
  440. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON \
  441. -DUA_NAMESPACE_ZERO=MINIMAL ..
  442. make -j && make test ARGS="-V"
  443. if [ $? -ne 0 ] ; then exit 1 ; fi
  444. cd .. && rm build -rf
  445. echo -en 'travis_fold:end:script.build.unit_test_ns0_minimal\\r'
  446. echo -e "\r\n== Unit tests (reduced NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_reduced\\r'
  447. mkdir -p build && cd build
  448. cmake \
  449. -DCMAKE_BUILD_TYPE=Debug \
  450. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  451. -DUA_BUILD_EXAMPLES=ON \
  452. -DUA_BUILD_UNIT_TESTS=ON \
  453. -DUA_ENABLE_COVERAGE=ON \
  454. -DUA_ENABLE_DA=ON \
  455. -DUA_ENABLE_DISCOVERY=ON \
  456. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  457. -DUA_ENABLE_ENCRYPTION=ON \
  458. -DUA_ENABLE_JSON_ENCODING=ON \
  459. -DUA_ENABLE_PUBSUB=ON \
  460. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  461. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON \
  462. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON \
  463. -DUA_NAMESPACE_ZERO=REDUCED ..
  464. make -j && make test ARGS="-V"
  465. if [ $? -ne 0 ] ; then exit 1 ; fi
  466. echo -en 'travis_fold:end:script.build.unit_test_ns0_reduced\\r'
  467. # only run coveralls on main repo and when MINGW=true
  468. # We only want to build coveralls once, so we just take the travis run where MINGW=true which is only enabled once
  469. echo -e "\r\n== -> Current repo: ${TRAVIS_REPO_SLUG} =="
  470. if [ $MINGW = "true" ] && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  471. echo -en "\r\n== Building codecov.io for ${TRAVIS_REPO_SLUG} ==" && echo -en 'travis_fold:start:script.build.codecov\\r'
  472. cd ..
  473. /bin/bash -c "bash <(curl -s https://codecov.io/bash)"
  474. if [ $? -ne 0 ] ; then exit 1 ; fi
  475. cd build
  476. echo -en 'travis_fold:end:script.build.codecov\\r'
  477. echo -en "\r\n== Building coveralls for ${TRAVIS_REPO_SLUG} ==" && echo -en 'travis_fold:start:script.build.coveralls\\r'
  478. coveralls -E '.*/build/CMakeFiles/.*' -E '.*/examples/.*' -E '.*/tests/.*' -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../ || true # ignore result since coveralls is unreachable from time to time
  479. cd .. && rm build -rf
  480. echo -en 'travis_fold:end:script.build.coveralls\\r'
  481. if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
  482. REAL_BRANCH="${TRAVIS_BRANCH}"
  483. echo -en "== Checking branch for packing: BRANCH_FOR_TAG='$BRANCH_FOR_TAG' and TRAVIS_TAG='${TRAVIS_TAG}'. \n"
  484. if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then
  485. REAL_BRANCH="$BRANCH_FOR_TAG"
  486. echo -en "== Commit is tag build for '${TRAVIS_TAG}'. Detected branch for tag = '$BRANCH_FOR_TAG' \n"
  487. fi
  488. if [ "${REAL_BRANCH}" = "master" ] || [ "${REAL_BRANCH}" = "1.0" ]; then
  489. # Create a separate branch with the `pack/` prefix. This branch has the correct debian/changelog set, and
  490. # The submodules are directly copied
  491. echo -e "\r\n== Pushing 'pack/${REAL_BRANCH}' branch ==" && echo -en 'travis_fold:start:script.build.pack-branch\\r'
  492. git checkout -b pack-tmp/${REAL_BRANCH}
  493. cp -r deps/mdnsd deps/mdnsd_back
  494. cp -r deps/ua-nodeset deps/ua-nodeset_back
  495. git rm -rf --cached deps/mdnsd
  496. git rm -rf --cached deps/ua-nodeset
  497. mv deps/mdnsd_back deps/mdnsd
  498. rm -rf deps/mdnsd/.git
  499. mv deps/ua-nodeset_back deps/ua-nodeset
  500. rm -rf deps/ua-nodeset/.git
  501. rm -rf .gitmodules
  502. git add deps/*
  503. git add debian/*
  504. git add CMakeLists.txt
  505. git commit -m "[ci skip] Pack with inline submodules"
  506. git remote add origin-auth https://$GITAUTH@github.com/${TRAVIS_REPO_SLUG}
  507. git push -uf origin-auth pack-tmp/${REAL_BRANCH}:pack/${REAL_BRANCH}
  508. echo -en 'travis_fold:end:script.build.pack-branch\\r'
  509. else
  510. echo -en "== Skipping push to pack/ because branch does not match: REAL_BRANCH='${REAL_BRANCH}' \n"
  511. fi
  512. else
  513. echo -en "== Skipping push to pack/ because TRAVIS_PULL_REQUEST=false \n"
  514. fi
  515. fi
  516. fi