您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

.drone.yml 11KB

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