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.

config.yml 7.4KB

Fix coverage (#2603) * Add utility to prepare C coverage for upload to coveralls.io It turned out that it is more easy to write own script then debug and fix coveralls utility (https://github.com/eddyxu/cpp-coveralls). gcov-coveralls.py can be used as a replacement for coveralls. * Save coverage data from .gcda files only once Coverage data in .gcda files is merged after each binary invocation, so we can run all test and then gather coverage data. If we dump them two times execution counts will be more then they be. * Switch from coveralls (cpp-coveralls) to own script Problem with coveralls was, that coverage for source files outside build directory was not added to the report. * Add tool to dump info from json for coveralls.io * Add debug * Fix: don't die if there is no service_job_id in json * Debug * Fix dump_coveralls.py * Rename to gcov_coveralls.py (s/-/_/) For most files in this repo '_' is used as separator. * Don't add source code to coveralls JSON According to https://docs.coveralls.io/api-introduction Coverals don't need source code, only MD5 digest to tracks changes. Anyway source code is already added by luacov-coveralls and source_digest is added by cpp-coveralls and gcov_coveralls.py Both options seems to work for now. * Provide path to source directory to merge_coveralls.py merge_coveralls.py has code to filter files and remove prefixes. When --root points to source directory merge_coveralls.py can strip prefix from absolute path in JSONs generated by luacov-coveralls. * Style Don't add parameters with default values. * Make --output optional It useful mainly for debugging. We can send report without saving it. * Log CI_COMMIT_AUTHOR env var It is not clear from drone.io source how CI_COMMIT_AUTHOR variable is set. Log it to see what it means. * Move merge_coveralls.py to test/tools This script is used not only for funcional test coverage, but for rspamd-test coverage too. * Remove debug * Style Use more compact formatting. * Write comment about parallel tests running [SKIP CI] Document why running tests in parallel may be bad idea (but still do so). * Fix typo [SKIP CI]
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. references:
  2. - &defaults
  3. docker:
  4. - image: circleci/ruby:latest
  5. - &workspace_root
  6. ~/
  7. - &capture_coverage_data
  8. run:
  9. name: Capturing coverage data
  10. command: |
  11. set -e
  12. sudo apt-get install -qq python-pip
  13. sudo pip install cpp-coveralls
  14. # further, these files will be saved in cache and used in "send-coverage" step
  15. # see "merge_and_upload_coverage_data" and "save_cache" records
  16. coveralls --dump coverage.${CIRCLE_JOB}.dump
  17. - &merge_and_upload_coverage_data
  18. run:
  19. name: Merging and uploading coverage data
  20. command: |
  21. set -e
  22. if [ -f ~/project/coverage.rspamd-test.dump ] && [ -f ~/project/coverage.functional.dump ]; then
  23. sudo apt-get install -qq python-pip python-dev
  24. sudo pip install --upgrade setuptools
  25. sudo pip install --upgrade pyOpenSSL
  26. sudo pip install cpp-coveralls requests cryptography
  27. cd ~/project
  28. if [ ! -z $COVERALLS_REPO_TOKEN ]; then
  29. # Merge Lua coverage (collected into lua_coverage_report.json) and with C-coverage
  30. # (in coverage.rspamd-test.dump, coverage.functional.dump, see &capture_coverage_data)
  31. # and finally upload it into coveralls.io
  32. test/tools/merge_coveralls.py --input coverage.functional.dump coverage.rspamd-test.dump lua_coverage_report.json unit_test_lua.json --output out.josn --token=${COVERALLS_REPO_TOKEN}
  33. fi
  34. fi
  35. version: 2
  36. jobs:
  37. build:
  38. <<: *defaults
  39. steps:
  40. - checkout
  41. - run: sudo apt-get update -qq || true
  42. - run: sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libicu-dev libluajit-5.1-dev libmagic-dev libsqlite3-dev libssl-dev ragel libunwind-dev libunwind8
  43. - run: mkdir ../build ; mkdir ../install ; cd ../build
  44. # this weird peice is needed to properly collect coverage
  45. # rspamd works under "nobody" user and will not be able to dump
  46. # the coverage if directories have restrictive permissions
  47. - run: umask 0000
  48. - run: cmake ../project -DDBDIR=/nana -DENABLE_COVERAGE=ON -DENABLE_LIBUNWIND=ON -DCMAKE_INSTALL_PREFIX=../install
  49. - run: make install -j`nproc`
  50. - persist_to_workspace:
  51. root: *workspace_root
  52. paths:
  53. - project
  54. - build
  55. - install
  56. rspamd-test:
  57. <<: *defaults
  58. steps:
  59. - attach_workspace:
  60. at: *workspace_root
  61. - run: sudo apt-get update -qq || true
  62. - run: sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libicu-dev libluajit-5.1-dev libmagic-dev libsqlite3-dev libssl-dev ragel libunwind-dev libunwind8 luarocks
  63. - run: sudo luarocks install luacheck
  64. - run: sudo luarocks install luacov
  65. - run: sudo luarocks install luacov-coveralls
  66. - run: cd ../build
  67. - run: make rspamd-test -j`nproc`
  68. - run: set +e; test/rspamd-test -p /rspamd/lua; echo "export RETURN_CODE=$?" >> $BASH_ENV
  69. - run: luacov-coveralls -o unit_test_lua.json --dryrun
  70. - *capture_coverage_data
  71. # Share coverage data between jobs
  72. - save_cache:
  73. key: coverage-rspamd-test-{{ .Environment.CIRCLE_WORKFLOW_ID }}
  74. paths:
  75. - coverage.rspamd-test.dump
  76. - unit_test_lua.json
  77. - run: (exit $RETURN_CODE)
  78. functional:
  79. <<: *defaults
  80. steps:
  81. - attach_workspace:
  82. at: *workspace_root
  83. - run: echo 'deb http://repo.yandex.ru/clickhouse/deb/stable/ main/' | sudo tee /etc/apt/sources.list.d/clickhouse.list
  84. - run: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 # optional, clickhouse key
  85. - run: sudo apt-get update -qq || true
  86. - run: sudo apt-get install -qq libluajit-5.1-dev libpcre3-dev luarocks opendkim-tools python-pip redis-server libunwind8 libglib2.0-dev libicu-dev libevent-dev python-dev
  87. - run: sudo apt-get install clickhouse-server
  88. - run: sudo pip install demjson psutil robotframework requests http
  89. - run: sudo luarocks install luacheck
  90. - run: sudo luarocks install luacov
  91. - run: sudo luarocks install luacov-coveralls
  92. - run: cd ../build
  93. # see coverage notice in "build" stage
  94. - run: set +e; RSPAMD_INSTALLROOT=../install sudo -E bash -c "umask 0000; robot -x xunit.xml --exclude isbroken ../project/test/functional/cases"; echo "export RETURN_CODE=$?" >> $BASH_ENV
  95. # luacov-coveralls reads luacov.stats.out generated by functional tests
  96. # (see collect_lua_coverage() in test/functional/lib/rspamd.py)
  97. # and writes json report for coveralls.io
  98. - run: luacov-coveralls -o lua_coverage_report.json --dryrun
  99. - *capture_coverage_data
  100. # Share coverage data between jobs
  101. - save_cache:
  102. key: coverage-functional-{{ .Environment.CIRCLE_WORKFLOW_ID }}
  103. paths:
  104. - coverage.functional.dump
  105. - lua_coverage_report.json
  106. - store_artifacts:
  107. path: output.xml
  108. - store_artifacts:
  109. path: log.html
  110. - store_artifacts:
  111. path: report.html
  112. - run: mkdir -p test-results; mv xunit.xml test-results
  113. - store_test_results:
  114. path: test-results
  115. - run: (exit $RETURN_CODE)
  116. eslint:
  117. docker:
  118. - image: circleci/node:latest
  119. steps:
  120. - checkout
  121. - restore_cache:
  122. keys:
  123. - v1-dependencies-{{ checksum "package.json" }}
  124. # fallback to using the latest cache if no exact match is found
  125. - v1-dependencies-
  126. - run: npm install
  127. - save_cache:
  128. paths:
  129. - node_modules
  130. key: v1-dependencies-{{ checksum "package.json" }}
  131. - run: ./node_modules/.bin/eslint -v && ./node_modules/.bin/eslint ./
  132. tidy:
  133. docker:
  134. - image: buildpack-deps:latest
  135. steps:
  136. - run:
  137. name: Exporting env vars
  138. command: |
  139. cat >> $BASH_ENV <<EOF
  140. export PATH=$PATH:$HOME/perl5/bin
  141. export PERL_CPANM_OPT=--local-lib=$HOME/perl5
  142. export PERL5LIB=$HOME/perl5/lib/perl5:$PERL5LIB
  143. EOF
  144. - checkout
  145. - restore_cache:
  146. key: v0-tidyall_dependencies
  147. - run:
  148. name: Installing cpanm
  149. command: 'curl -L https://cpanmin.us | perl - App::cpanminus'
  150. - run:
  151. name: Installing CPAN dependencies
  152. command: |
  153. cpanm --quiet --notest \
  154. Code::TidyAll \
  155. Code::TidyAll::Plugin::Test::Vars \
  156. Perl::Critic \
  157. Perl::Tidy \
  158. Pod::Tidy
  159. - save_cache:
  160. key: v0-tidyall_dependencies
  161. paths:
  162. - ~/perl5
  163. - run: tidyall -a --check-only
  164. send-coverage:
  165. <<: *defaults
  166. steps:
  167. - attach_workspace:
  168. at: *workspace_root
  169. - restore_cache:
  170. key: coverage-rspamd-test-{{ .Environment.CIRCLE_WORKFLOW_ID }}
  171. - restore_cache:
  172. key: coverage-functional-{{ .Environment.CIRCLE_WORKFLOW_ID }}
  173. - *merge_and_upload_coverage_data
  174. - store_artifacts:
  175. path: out.josn
  176. notify:
  177. webhooks:
  178. - url: https://coveralls.io/webhook?repo_token={{ .Environment.COVERALLS_REPO_TOKEN }}
  179. workflows:
  180. version: 2
  181. build-and-test:
  182. jobs:
  183. - build
  184. - eslint
  185. - tidy
  186. - rspamd-test:
  187. requires:
  188. - build
  189. - functional:
  190. requires:
  191. - build
  192. - send-coverage:
  193. requires:
  194. - rspamd-test
  195. - functional