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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. ---
  2. kind: pipeline
  3. type: docker
  4. name: default
  5. platform:
  6. os: linux
  7. steps:
  8. - name: prepare
  9. # any image with a root shell can be used here, but Ubuntu used as base
  10. # image for build and test images and we need to download it anyway
  11. image: ubuntu:22.04
  12. pull: if-not-exists
  13. volumes:
  14. - name: rspamd
  15. path: /rspamd
  16. commands:
  17. - install -d -o nobody -g nogroup /rspamd/build /rspamd/install /rspamd/fedora/build /rspamd/fedora/install
  18. - name: build
  19. # https://github.com/rspamd/rspamd-build-docker/blob/master/ubuntu-build/Dockerfile
  20. image: rspamd/ci:ubuntu-build
  21. pull: always
  22. volumes:
  23. - name: rspamd
  24. path: /rspamd
  25. depends_on: [ prepare ]
  26. commands:
  27. # build directories should be writable by nobody, for rspamd in functional tests
  28. # works as nobody and writes coverage files there
  29. - test "$(id -un)" = nobody
  30. - cd /rspamd/build
  31. - >
  32. cmake
  33. -DCMAKE_INSTALL_PREFIX=/rspamd/install
  34. -DCMAKE_RULE_MESSAGES=OFF
  35. -DCMAKE_VERBOSE_MAKEFILE=ON
  36. -DENABLE_COVERAGE=ON
  37. -DENABLE_LIBUNWIND=ON
  38. -GNinja
  39. $CI_WORKSPACE
  40. - ncpu=$(getconf _NPROCESSORS_ONLN)
  41. - ninja -j $ncpu install
  42. - ninja -j $ncpu rspamd-test
  43. - ninja -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. - env RSPAMD_LUA_EXPENSIVE_TESTS=1 ./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. if [ $EXIT_CODE -ne 0 ]; then
  107. exit $EXIT_CODE;
  108. fi
  109. # luacov-coveralls reads luacov.stats.out written by rspamd-test using luacov module
  110. # and writes json report for coveralls.io service
  111. - luacov-coveralls -o /rspamd/build/unit_test_lua.json --dryrun
  112. - set +e
  113. - ./rspamd-test-cxx -s; EXIT_CODE=$?
  114. - set -e
  115. # shell sets exit status of a process terminated by a signal to '128 + signal-number'
  116. # if rspamd-test was terminated by a signal it should be SIGSEGV or SIGABRT, try to examine core
  117. - >
  118. if [ $EXIT_CODE -gt 128 ]; then
  119. gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test-cxx.core ./rspamd-test-cxx;
  120. exit $EXIT_CODE;
  121. fi
  122. - exit $EXIT_CODE
  123. - name: test-fedora-clang
  124. # https://github.com/rspamd/rspamd-build-docker/blob/master/fedora-test/Dockerfile
  125. image: rspamd/ci:fedora-test
  126. pull: always
  127. volumes:
  128. - name: rspamd
  129. path: /rspamd
  130. depends_on: [ build-clang ]
  131. commands:
  132. - test "$(id -un)" = nobody
  133. # Asan reserves 20Tb of virtual memory, limit core size to 2 Gb to avoid writing huge core
  134. - ulimit -c 2097152
  135. - ulimit -s unlimited
  136. # disable leak sanitizer: too many leaks detected, most of them probably FP
  137. - export ASAN_OPTIONS="detect_leaks=0:print_stacktrace=1:disable_coredump=0"
  138. - export UBSAN_OPTIONS="print_stacktrace=1:print_summary=0:log_path=/tmp/ubsan"
  139. - cd /rspamd/fedora/build/test
  140. - set +e
  141. - env RSPAMD_LUA_EXPENSIVE_TESTS=1 ./rspamd-test -p /rspamd/lua; EXIT_CODE=$?
  142. - set -e
  143. # shell sets exit status of a process terminated by a signal to '128 + signal-number'
  144. # if rspamd-test was terminated by a signal it should be SIGSEGV or SIGABRT, try to examine core
  145. - >
  146. if [ $EXIT_CODE -gt 128 ]; then
  147. gdb --batch -ex 'bt' -c /var/tmp/*.rspamd-test.core ./rspamd-test;
  148. fi
  149. - set +e
  150. - ./rspamd-test-cxx -s; EXIT_CODE=$?
  151. - set -e
  152. # shell sets exit status of a process terminated by a signal to '128 + signal-number'
  153. # if rspamd-test was terminated by a signal it should be SIGSEGV or SIGABRT, try to examine core
  154. - >
  155. if [ $EXIT_CODE -gt 128 ]; then
  156. gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test-cxx.core ./rspamd-test-cxx;
  157. exit $EXIT_CODE;
  158. fi
  159. - cat /tmp/ubsan.* || true
  160. - exit $EXIT_CODE
  161. - name: functional
  162. # https://github.com/rspamd/rspamd-build-docker/blob/master/ubuntu-test-func/Dockerfile
  163. image: rspamd/ci:ubuntu-test-func
  164. pull: always
  165. volumes:
  166. - name: rspamd
  167. path: /rspamd
  168. depends_on: [ build ]
  169. commands:
  170. - cd /rspamd/build
  171. - ulimit -c unlimited
  172. - ulimit -s unlimited
  173. # some rspamd processes during this test work as root and some as nobody
  174. # use umask to create world-writable files so nobody can write to *.gcda files created by root
  175. - umask 0000
  176. - set +e
  177. - RSPAMD_INSTALLROOT=/rspamd/install robot --removekeywords wuks --exclude isbroken $CI_WORKSPACE/test/functional/cases; EXIT_CODE=$?
  178. - set -e
  179. # upload test results to nginx frontent using WebDAV PUT
  180. - >
  181. if [ -n "$HTTP_PUT_AUTH" ]; then
  182. $CI_WORKSPACE/test/tools/http_put.py log.html report.html https://$DRONE_SYSTEM_HOSTNAME/testlogs/$DRONE_REPO/$DRONE_BUILD_NUMBER/;
  183. fi
  184. # core_pattern=/var/tmp/%u.%e.core so one or two cores can be saved for each binary
  185. - core_files=$(find /var/tmp/ -name '*.core')
  186. # use 'info proc mappings' to find path to executable file for given core
  187. # first mapping is usually program executable
  188. - >
  189. for core in $core_files;
  190. do
  191. exe=$(gdb --batch -ex 'info proc mappings' -c $core | tail -1 | awk '{print $5}');
  192. gdb --batch -ex 'bt' -c $core $exe; echo '---';
  193. done
  194. - exit $EXIT_CODE
  195. environment:
  196. HTTP_PUT_AUTH: { from_secret: http_put_auth }
  197. - name: send-coverage
  198. image: rspamd/ci:ubuntu-test
  199. pull: if-not-exists
  200. volumes:
  201. - name: rspamd
  202. path: /rspamd
  203. depends_on: [ functional, rspamd-test ]
  204. commands:
  205. - cd /rspamd/build
  206. # extract coverage data for C code from .gcda files and save it in a format suitable for coveralls.io
  207. - $CI_WORKSPACE/test/tools/gcov_coveralls.py --exclude test --prefix /rspamd/build --prefix $CI_WORKSPACE --out coverage.c.json
  208. # luacov-coveralls reads luacov.stats.out generated by functional tests
  209. # (see collect_lua_coverage() in test/functional/lib/rspamd.py)
  210. # and writes json report for coveralls.io
  211. - luacov-coveralls -o coverage.functional.lua.json --dryrun
  212. # * merge coverage for C and Lua code
  213. # * remove prefixes from absolute paths (in luacov-coveralls files), filter test, contrib, e. t.c
  214. # * upload report to coveralls.io
  215. - $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
  216. environment:
  217. COVERALLS_REPO_TOKEN: { from_secret: coveralls_repo_token }
  218. when:
  219. branch: [ master ]
  220. # don't send coverage report for pull request
  221. event: [push, tag]
  222. - name: eslint
  223. image: node:17-alpine
  224. pull: if-not-exists
  225. failure: ignore
  226. commands:
  227. - npm install
  228. - ./node_modules/.bin/eslint -v
  229. - ./node_modules/.bin/eslint ./
  230. # Run stylelint checks
  231. - ./node_modules/.bin/stylelint -v
  232. - npm show stylelint-config-standard version
  233. - ./node_modules/.bin/stylelint ./**/*.css ./**/*.html ./**/*.js
  234. - name: perl-tidyall
  235. # https://github.com/rspamd/rspamd-build-docker/blob/master/perl-tidyall/Dockerfile
  236. image: rspamd/ci:perl-tidyall
  237. pull: if-not-exists
  238. failure: ignore
  239. commands:
  240. - tidyall --version
  241. - perltidy --version | head -1
  242. # checks are configured in .tidyallrc at the top of rspamd repo
  243. - tidyall --all --check-only --no-cache --data-dir /tmp/tidyall
  244. - name: notify
  245. image: drillster/drone-email
  246. pull: if-not-exists
  247. depends_on:
  248. - rspamd-test
  249. - test-fedora-clang
  250. - functional
  251. - send-coverage
  252. - eslint
  253. - perl-tidyall
  254. settings:
  255. from: noreply@rspamd.com
  256. host: { from_secret: email_host }
  257. username: { from_secret: email_username }
  258. password: { from_secret: email_password }
  259. when:
  260. status: [ failure ]
  261. volumes:
  262. - name: rspamd
  263. temp: {}
  264. trigger:
  265. event: [push, tag, pull_request, custom]
  266. ---
  267. kind: signature
  268. hmac: 577234b81e1f00d04b84687ed18dba05838233d3ca9cb1328d02937f52be6b0d
  269. ...