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 10KB

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