You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.drone.yml 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. ---
  2. kind: pipeline
  3. type: docker
  4. name: default
  5. platform:
  6. os: linux
  7. arch: amd64
  8. steps:
  9. - name: prepare
  10. # any image with a root shell can be used here, but Ubuntu used as base
  11. # image for build and test images and we need to download it anyway
  12. image: ubuntu:18.04
  13. pull: if-not-exists
  14. volumes:
  15. - name: rspamd
  16. path: /rspamd
  17. commands:
  18. - install -d -o nobody -g nogroup /rspamd/build /rspamd/install /rspamd/fedora/build /rspamd/fedora/install
  19. - name: build
  20. # https://github.com/rspamd/rspamd-build-docker/blob/master/ubuntu-build/Dockerfile
  21. image: rspamd/ci-ubuntu-build
  22. pull: always
  23. volumes:
  24. - name: rspamd
  25. path: /rspamd
  26. depends_on: [ prepare ]
  27. commands:
  28. # build directories should be writable by nobody, for rspamd in functional tests
  29. # works as nobody and writes coverage files there
  30. - test "$(id -un)" = nobody
  31. - cd /rspamd/build
  32. - >
  33. cmake
  34. -DCMAKE_INSTALL_PREFIX=/rspamd/install
  35. -DCMAKE_RULE_MESSAGES=OFF
  36. -DCMAKE_VERBOSE_MAKEFILE=ON
  37. -DENABLE_COVERAGE=ON
  38. -DENABLE_LIBUNWIND=ON
  39. $CI_WORKSPACE
  40. - ncpu=$(getconf _NPROCESSORS_ONLN)
  41. - make -j $ncpu install
  42. - make -j $ncpu rspamd-test
  43. - name: build-clang
  44. # https://github.com/rspamd/rspamd-build-docker/blob/master/fedora-build/Dockerfile
  45. image: rspamd/ci-fedora-build
  46. pull: always
  47. volumes:
  48. - name: rspamd
  49. path: /rspamd
  50. depends_on: [ prepare ]
  51. commands:
  52. - test "$(id -un)" = nobody
  53. - cd /rspamd/fedora/build
  54. - export LDFLAGS='-fuse-ld=lld'
  55. - export CFLAGS='-fsanitize=address,undefined,implicit-integer-truncation'
  56. - export ASAN_OPTIONS=detect_leaks=0
  57. - >
  58. cmake
  59. -DCMAKE_INSTALL_PREFIX=/rspamd/fedora/install
  60. -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
  61. -DCMAKE_RULE_MESSAGES=OFF
  62. -DCMAKE_VERBOSE_MAKEFILE=ON
  63. -DENABLE_CLANG_PLUGIN=ON
  64. -DENABLE_FULL_DEBUG=ON
  65. $CI_WORKSPACE
  66. - ncpu=$(getconf _NPROCESSORS_ONLN)
  67. - make -j $ncpu install
  68. - make -j $ncpu rspamd-test
  69. # We run rspamd-test (unit test) and functional test (runned by robot) in
  70. # parallel to save time. To avoid conflict in saving lua coverage we run them
  71. # from different directories. For C code coverage counters is saved to .gcda
  72. # files and binary contain absolute path to them, so rspamd-test and
  73. # processes started by functional test are writing to the same files. On
  74. # process exit new coverage data merged with existing content of .gcda file.
  75. # Race is possible if rspamd-test and some rspamd process in functional test
  76. # will try to write .gcda file simultaneous. But it is very unlikely and
  77. # performance is more important then correct coverage data.
  78. - name: rspamd-test
  79. # https://github.com/rspamd/rspamd-build-docker/blob/master/ubuntu-test/Dockerfile
  80. image: rspamd/ci-ubuntu-test
  81. pull: always
  82. volumes:
  83. - name: rspamd
  84. path: /rspamd
  85. depends_on: [ build ]
  86. commands:
  87. - test "$(id -un)" = nobody
  88. - ulimit -c unlimited
  89. # rspamd-test and functional test both use luacov.stats.out file and should be started from
  90. # different directories (if started in parallel)
  91. - cd /rspamd/build/test
  92. - set +e
  93. - ./rspamd-test -p /rspamd/lua; EXIT_CODE=$?
  94. - set -e
  95. # shell sets exit status of a process terminated by a signal to '128 + signal-number'
  96. # if rspamd-test was terminated by a signal it should be SIGSEGV or SIGABRT, try to examine core
  97. - >
  98. if [ $EXIT_CODE -gt 128 ]; then
  99. gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test.core ./rspamd-test;
  100. exit $EXIT_CODE;
  101. fi
  102. # luacov-coveralls reads luacov.stats.out written by rspamd-test using luacov module
  103. # and writes json report for coveralls.io service
  104. - luacov-coveralls -o /rspamd/build/unit_test_lua.json --dryrun
  105. - exit $EXIT_CODE
  106. - name: test-fedora-clang
  107. # https://github.com/rspamd/rspamd-build-docker/blob/master/fedora-test/Dockerfile
  108. image: rspamd/ci-fedora-test
  109. pull: always
  110. volumes:
  111. - name: rspamd
  112. path: /rspamd
  113. depends_on: [ build-clang ]
  114. commands:
  115. - test "$(id -un)" = nobody
  116. # Asan reserves 20Tb of virtual memory, limit core size to 2 Gb to avoid writing huge core
  117. - ulimit -c 2097152
  118. - ulimit -s unlimited
  119. # disable leak sanitizer: too many leaks detected, most of them probably FP
  120. - export ASAN_OPTIONS="detect_leaks=0:print_stacktrace=1:disable_coredump=0"
  121. - export UBSAN_OPTIONS="print_stacktrace=1:print_summary=0:log_path=/tmp/ubsan"
  122. - cd /rspamd/fedora/build/test
  123. - set +e
  124. - ./rspamd-test -p /rspamd/lua; EXIT_CODE=$?
  125. - set -e
  126. # shell sets exit status of a process terminated by a signal to '128 + signal-number'
  127. # if rspamd-test was terminated by a signal it should be SIGSEGV or SIGABRT, try to examine core
  128. - >
  129. if [ $EXIT_CODE -gt 128 ]; then
  130. gdb --batch -ex 'bt' -c /var/tmp/*.rspamd-test.core ./rspamd-test;
  131. fi
  132. - cat /tmp/ubsan.*
  133. - exit $EXIT_CODE
  134. - name: functional
  135. # https://github.com/rspamd/rspamd-build-docker/blob/master/ubuntu-test-func/Dockerfile
  136. image: rspamd/ci-ubuntu-test-func
  137. pull: always
  138. volumes:
  139. - name: rspamd
  140. path: /rspamd
  141. depends_on: [ build ]
  142. commands:
  143. - cd /rspamd/build
  144. - ulimit -c unlimited
  145. - ulimit -s unlimited
  146. # some rspamd processes during this test work as root and some as nobody
  147. # use umask to create world-writable files so nobody can write to *.gcda files created by root
  148. - umask 0000
  149. - set +e
  150. - RSPAMD_INSTALLROOT=/rspamd/install robot --removekeywords wuks --exclude isbroken $CI_WORKSPACE/test/functional/cases; EXIT_CODE=$?
  151. - set -e
  152. # upload test results to nginx frontent using WebDAV PUT
  153. - >
  154. if [ -n "$HTTP_PUT_AUTH" ]; then
  155. $CI_WORKSPACE/test/tools/http_put.py log.html report.html https://$DRONE_SYSTEM_HOSTNAME/testlogs/$DRONE_REPO/$DRONE_BUILD_NUMBER/;
  156. fi
  157. # core_pattern=/var/tmp/%u.%e.core so one or two cores can be saved for each binary
  158. - core_files=$(find /var/tmp/ -name '*.core')
  159. # use 'info proc mappings' to find path to executable file for given core
  160. # first mapping is usually program executable
  161. - >
  162. for core in $core_files;
  163. do
  164. exe=$(gdb --batch -ex 'info proc mappings' -c $core | awk 'h {print $5; exit}; /objfile/ {h=1}');
  165. gdb --batch -ex 'bt' -c $core $exe; echo '---';
  166. done
  167. - exit $EXIT_CODE
  168. environment:
  169. HTTP_PUT_AUTH: { from_secret: http_put_auth }
  170. - name: send-coverage
  171. image: rspamd/ci-ubuntu-test
  172. pull: if-not-exists
  173. volumes:
  174. - name: rspamd
  175. path: /rspamd
  176. depends_on: [ functional, rspamd-test ]
  177. commands:
  178. - cd /rspamd/build
  179. # extract coverage data for C code from .gcda files and save it in a format suitable for coveralls.io
  180. - $CI_WORKSPACE/test/tools/gcov_coveralls.py --exclude test --prefix /rspamd/build --prefix $CI_WORKSPACE --out coverage.c.json
  181. # luacov-coveralls reads luacov.stats.out generated by functional tests
  182. # (see collect_lua_coverage() in test/functional/lib/rspamd.py)
  183. # and writes json report for coveralls.io
  184. - luacov-coveralls -o coverage.functional.lua.json --dryrun
  185. # * merge coverage for C and Lua code
  186. # * remove prefixes from absolute paths (in luacov-coveralls files), filter test, contrib, e. t.c
  187. # * upload report to coveralls.io
  188. - $CI_WORKSPACE/test/tools/merge_coveralls.py --root $CI_WORKSPACE --input coverage.c.json unit_test_lua.json coverage.functional.lua.json --token=$COVERALLS_REPO_TOKEN
  189. environment:
  190. COVERALLS_REPO_TOKEN: { from_secret: coveralls_repo_token }
  191. when:
  192. branch: [ master ]
  193. # don't send coverage report for pull request
  194. event: [push, tag]
  195. - name: eslint
  196. image: node:10-alpine
  197. pull: if-not-exists
  198. commands:
  199. - npm install
  200. - ./node_modules/.bin/eslint -v
  201. - ./node_modules/.bin/eslint ./
  202. # Run stylelint checks
  203. - ./node_modules/.bin/stylelint -v
  204. - npm show stylelint-config-standard version
  205. - ./node_modules/.bin/stylelint ./**/*.css ./**/*.html ./**/*.js
  206. - name: perl-tidyall
  207. # https://github.com/rspamd/rspamd-build-docker/blob/master/perl-tidyall/Dockerfile
  208. image: rspamd/ci-perl-tidyall
  209. pull: if-not-exists
  210. commands:
  211. - tidyall --version
  212. - perltidy --version | head -1
  213. # checks are configured in .tidyallrc at the top of rspamd repo
  214. - tidyall --all --check-only --no-cache --data-dir /tmp/tidyall
  215. - name: notify
  216. image: drillster/drone-email
  217. pull: if-not-exists
  218. depends_on:
  219. - rspamd-test
  220. - test-fedora-clang
  221. - functional
  222. - send-coverage
  223. - eslint
  224. - perl-tidyall
  225. settings:
  226. from: noreply@rspamd.com
  227. host: { from_secret: email_host }
  228. username: { from_secret: email_username }
  229. password: { from_secret: email_password }
  230. when:
  231. status: [ failure ]
  232. volumes:
  233. - name: rspamd
  234. temp: {}
  235. trigger:
  236. event: [push, tag, pull_request]
  237. ---
  238. kind: signature
  239. hmac: 9997b0189f3cf3acce7575372f728ccc57bf57b9a72936d86e91b1cff852a48b
  240. ...