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.jsonnet 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. local docker_pipeline = {
  2. kind: 'pipeline',
  3. type: 'docker',
  4. };
  5. local default_trigger_events_ex_pr = [
  6. 'push',
  7. 'tag',
  8. 'custom',
  9. ];
  10. local default_trigger = {
  11. trigger: {
  12. event: default_trigger_events_ex_pr + ['pull_request'],
  13. },
  14. };
  15. local platform(arch) = {
  16. platform: {
  17. os: 'linux',
  18. arch: arch,
  19. },
  20. };
  21. local coveralls_attribs = {
  22. branch: [
  23. 'master',
  24. ],
  25. event: [
  26. 'push',
  27. 'tag',
  28. ],
  29. };
  30. local close_coveralls_trigger = {
  31. trigger: coveralls_attribs { status: ['success', 'failure'] },
  32. };
  33. local coveralls_when = {
  34. when: coveralls_attribs,
  35. };
  36. local notify_pipeline = {
  37. name: 'notify',
  38. depends_on: [
  39. 'default-amd64',
  40. 'default-arm64',
  41. 'default-noarch',
  42. ],
  43. steps: [
  44. {
  45. name: 'notify',
  46. image: 'drillster/drone-email',
  47. pull: 'if-not-exists',
  48. settings: {
  49. from: 'noreply@rspamd.com',
  50. host: {
  51. from_secret: 'email_host',
  52. },
  53. username: {
  54. from_secret: 'email_username',
  55. },
  56. password: {
  57. from_secret: 'email_password',
  58. },
  59. },
  60. },
  61. ],
  62. trigger: {
  63. event: default_trigger_events_ex_pr,
  64. status: [
  65. 'failure',
  66. ],
  67. },
  68. } + docker_pipeline;
  69. local pipeline(arch) = {
  70. local rspamd_volumes = {
  71. volumes: [
  72. {
  73. name: 'rspamd',
  74. path: '/rspamd',
  75. },
  76. ],
  77. },
  78. local hyperscan_altroot = if (arch) == 'amd64' then '' else '-DHYPERSCAN_ROOT_DIR=/vectorscan',
  79. depends_on: [
  80. ],
  81. name: 'default-' + arch,
  82. steps: [
  83. {
  84. name: 'prepare',
  85. image: 'ubuntu:22.04',
  86. pull: 'if-not-exists',
  87. commands: [
  88. 'install -d -o nobody -g nogroup /rspamd/build /rspamd/install /rspamd/fedora/build /rspamd/fedora/install',
  89. ],
  90. } + rspamd_volumes,
  91. {
  92. name: 'build',
  93. image: 'rspamd/ci:ubuntu-build',
  94. pull: 'always',
  95. depends_on: [
  96. 'prepare',
  97. ],
  98. commands: [
  99. 'test "$(id -un)" = nobody',
  100. 'cd /rspamd/build',
  101. 'cmake -DCMAKE_INSTALL_PREFIX=/rspamd/install -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_COVERAGE=ON -DENABLE_LIBUNWIND=ON -DENABLE_HYPERSCAN=ON ' + hyperscan_altroot + ' -GNinja $DRONE_WORKSPACE\n',
  102. 'ncpu=$(getconf _NPROCESSORS_ONLN)',
  103. 'ninja -j $ncpu install',
  104. 'ninja -j $ncpu rspamd-test',
  105. 'ninja -j $ncpu rspamd-test-cxx',
  106. ],
  107. } + rspamd_volumes,
  108. {
  109. name: 'build-clang',
  110. image: 'rspamd/ci:fedora-build',
  111. pull: 'always',
  112. depends_on: [
  113. 'prepare',
  114. ],
  115. commands: [
  116. 'test "$(id -un)" = nobody',
  117. 'cd /rspamd/fedora/build',
  118. "export LDFLAGS='-fuse-ld=lld'",
  119. 'export ASAN_OPTIONS=detect_leaks=0',
  120. 'cmake -DCMAKE_INSTALL_PREFIX=/rspamd/fedora/install -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_CLANG_PLUGIN=ON -DENABLE_FULL_DEBUG=ON -DENABLE_HYPERSCAN=ON ' + hyperscan_altroot + ' -DSANITIZE=address $DRONE_WORKSPACE\n',
  121. 'ncpu=$(getconf _NPROCESSORS_ONLN)',
  122. 'make -j $ncpu install',
  123. 'make -j $ncpu rspamd-test',
  124. 'make -j $ncpu rspamd-test-cxx',
  125. ],
  126. } + rspamd_volumes,
  127. {
  128. name: 'rspamd-test',
  129. image: 'rspamd/ci:ubuntu-test',
  130. pull: 'always',
  131. depends_on: [
  132. 'build',
  133. ],
  134. commands: [
  135. 'test "$(id -un)" = nobody',
  136. 'ulimit -c unlimited',
  137. 'cd /rspamd/build/test',
  138. 'set +e',
  139. 'env RSPAMD_LUA_EXPENSIVE_TESTS=1 ./rspamd-test -p /rspamd/lua; EXIT_CODE=$?',
  140. 'set -e',
  141. "if [ $EXIT_CODE -gt 128 ]; then gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test.core ./rspamd-test; exit $EXIT_CODE; fi; if [ $EXIT_CODE -ne 0 ]; then exit $EXIT_CODE; fi\n",
  142. 'luacov-coveralls -o /rspamd/build/unit_test_lua.json --dryrun',
  143. 'set +e',
  144. './rspamd-test-cxx -s; EXIT_CODE=$?',
  145. 'set -e',
  146. "if [ $EXIT_CODE -gt 128 ]; then gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test-cxx.core ./rspamd-test-cxx; exit $EXIT_CODE; fi\n",
  147. 'exit $EXIT_CODE',
  148. ],
  149. } + rspamd_volumes,
  150. {
  151. name: 'test-fedora-clang',
  152. image: 'rspamd/ci:fedora-test',
  153. pull: 'always',
  154. depends_on: [
  155. 'build-clang',
  156. ],
  157. commands: [
  158. 'test "$(id -un)" = nobody',
  159. 'ulimit -c 2097152',
  160. 'ulimit -s unlimited',
  161. 'export ASAN_OPTIONS="detect_leaks=0:print_stacktrace=1:disable_coredump=0"',
  162. 'export UBSAN_OPTIONS="print_stacktrace=1:print_summary=0:log_path=/tmp/ubsan"',
  163. 'cd /rspamd/fedora/build/test',
  164. 'set +e',
  165. 'env RSPAMD_LUA_EXPENSIVE_TESTS=1 ./rspamd-test -p /rspamd/lua; EXIT_CODE=$?',
  166. 'set -e',
  167. "if [ $EXIT_CODE -gt 128 ]; then gdb --batch -ex 'bt' -c /var/tmp/*.rspamd-test.core ./rspamd-test; fi\n",
  168. 'set +e',
  169. './rspamd-test-cxx -s; EXIT_CODE=$?',
  170. 'set -e',
  171. "if [ $EXIT_CODE -gt 128 ]; then gdb --batch -ex 'thread apply all bt full' -c /var/tmp/*.rspamd-test-cxx.core ./rspamd-test-cxx; exit $EXIT_CODE; fi\n",
  172. 'cat /tmp/ubsan.* || true',
  173. 'exit $EXIT_CODE',
  174. ],
  175. } + rspamd_volumes,
  176. {
  177. name: 'functional',
  178. image: 'rspamd/ci:ubuntu-test-func',
  179. pull: 'always',
  180. depends_on: [
  181. 'build',
  182. ],
  183. commands: [
  184. 'cd /rspamd/build',
  185. 'ulimit -c unlimited',
  186. 'ulimit -s unlimited',
  187. 'set +e',
  188. 'RSPAMD_INSTALLROOT=/rspamd/install robot --removekeywords wuks --exclude isbroken $DRONE_WORKSPACE/test/functional/cases; EXIT_CODE=$?',
  189. 'set -e',
  190. 'if [ -n "$HTTP_PUT_AUTH" ]; then $DRONE_WORKSPACE/test/tools/http_put.py log.html report.html https://$DRONE_SYSTEM_HOSTNAME/testlogs/$DRONE_REPO/${DRONE_BUILD_NUMBER}-' + arch + '/; fi\n',
  191. "core_files=$(find /var/tmp/ -name '*.core')",
  192. "for core in $core_files; do exe=$(gdb --batch -ex 'info proc mappings' -c $core | tail -1 | awk '{print $5}'); gdb --batch -ex 'bt' -c $core $exe; echo '---'; done\n",
  193. 'exit $EXIT_CODE',
  194. ],
  195. environment: {
  196. HTTP_PUT_AUTH: {
  197. from_secret: 'http_put_auth',
  198. },
  199. },
  200. } + rspamd_volumes,
  201. {
  202. name: 'send-coverage',
  203. image: 'rspamd/ci:ubuntu-test',
  204. pull: 'if-not-exists',
  205. depends_on: [
  206. 'functional',
  207. 'rspamd-test',
  208. ],
  209. commands: [
  210. 'cd /rspamd/build',
  211. '$DRONE_WORKSPACE/test/tools/gcov_coveralls.py --exclude test --prefix /rspamd/build --prefix $DRONE_WORKSPACE --out coverage.c.json',
  212. 'luacov-coveralls -o coverage.functional.lua.json --dryrun',
  213. '$DRONE_WORKSPACE/test/tools/merge_coveralls.py --parallel --root $DRONE_WORKSPACE --input coverage.c.json unit_test_lua.json coverage.functional.lua.json --token=$COVERALLS_REPO_TOKEN',
  214. ],
  215. environment: {
  216. COVERALLS_REPO_TOKEN: {
  217. from_secret: 'coveralls_repo_token',
  218. },
  219. },
  220. } + coveralls_when + rspamd_volumes,
  221. ],
  222. volumes: [
  223. {
  224. name: 'rspamd',
  225. temp: {},
  226. },
  227. ],
  228. } + platform(arch) + default_trigger + docker_pipeline;
  229. local close_coveralls = {
  230. name: 'close_coveralls',
  231. depends_on: [
  232. 'default-amd64',
  233. 'default-arm64',
  234. ],
  235. steps: [
  236. {
  237. name: 'close_coveralls',
  238. image: 'rspamd/ci:ubuntu-test-func',
  239. pull: 'always',
  240. commands: [
  241. '$DRONE_WORKSPACE/test/tools/merge_coveralls.py --parallel-close --token=$COVERALLS_REPO_TOKEN',
  242. ],
  243. environment: {
  244. COVERALLS_REPO_TOKEN: {
  245. from_secret: 'coveralls_repo_token',
  246. },
  247. },
  248. },
  249. ],
  250. } + close_coveralls_trigger + docker_pipeline;
  251. local noarch_pipeline = {
  252. name: 'default-noarch',
  253. steps: [
  254. {
  255. name: 'perl-tidyall',
  256. image: 'rspamd/ci:perl-tidyall',
  257. pull: 'if-not-exists',
  258. failure: 'ignore',
  259. commands: [
  260. 'tidyall --version',
  261. 'perltidy --version | head -1',
  262. 'tidyall --all --check-only --no-cache --data-dir /tmp/tidyall',
  263. ],
  264. },
  265. {
  266. name: 'eslint',
  267. image: 'node:18-alpine',
  268. pull: 'if-not-exists',
  269. failure: 'ignore',
  270. commands: [
  271. 'npm install',
  272. 'npm ls',
  273. './node_modules/.bin/eslint ./',
  274. './node_modules/.bin/stylelint ./**/*.css ./**/*.html ./**/*.js',
  275. ],
  276. },
  277. {
  278. name: 'luacheck',
  279. image: 'pipelinecomponents/luacheck',
  280. pull: 'if-not-exists',
  281. commands: [
  282. 'luacheck -q --no-color .',
  283. ],
  284. },
  285. ],
  286. } + default_trigger + docker_pipeline;
  287. local signature = {
  288. kind: 'signature',
  289. hmac: '0000000000000000000000000000000000000000000000000000000000000000',
  290. };
  291. [
  292. pipeline('amd64'),
  293. pipeline('arm64'),
  294. close_coveralls,
  295. noarch_pipeline,
  296. notify_pipeline,
  297. signature,
  298. ]