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.4KB

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