.gitlab-ci.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. ####
  2. # DO NOT EDIT THIS FILE IN MASTER. ONLY EDIT IT IN THE OLDEST SUPPORTED
  3. # BRANCH, THEN MERGE FORWARD.
  4. ####
  5. # This file controls how gitlab validates Tor commits and merge requests.
  6. #
  7. # It is primarily based on a set of scripts and configurations by
  8. # Hans-Christoph Steiner. It only copies parts of those scripts and
  9. # configurations for now. If you want a new piece of functionality
  10. # (more debians, more fedoras, android support) then you shouldn't
  11. # start from scratch: have a look at the original ticket, at
  12. # https://gitlab.torproject.org/tpo/core/tor/-/issues/32193 !
  13. #
  14. # The file to copy from is
  15. # https://gitlab.torproject.org/tpo/core/tor/-/merge_requests/96/diffs#diff-content-587d266bb27a4dc3022bbed44dfa19849df3044c
  16. #
  17. # Having said that, if there is anything really stupid here, don't
  18. # blame it on Hans-Christoph! Tor probably added it on their own.
  19. #
  20. # Copyright 2020, The Tor Project, Inc.
  21. # See LICENSE for licence information.
  22. # These variables are set everywhere, unconditionally.
  23. variables:
  24. TERM: "ansi"
  25. DEBUG_CI: "yes"
  26. # This template is for exporting ephemeral things from the scripts. By
  27. # convention we expect our scripts to copy stuff into artifacts/, rather than
  28. # having a big list of files that be treated as artifacts.
  29. .artifacts-template: &artifacts-template
  30. artifacts:
  31. name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
  32. expire_in: 1 week
  33. when: always
  34. paths:
  35. - artifacts/
  36. # This template is used for x86-64 builds.
  37. .x86-64-template: &x86-64-template
  38. tags:
  39. - amd64
  40. - physical
  41. # This template should be usable on any system that's based on apt.
  42. .apt-template: &apt-template |
  43. export LC_ALL=C.UTF-8
  44. echo Etc/UTC > /etc/timezone
  45. mkdir -p apt-cache
  46. export APT_CACHE_DIR="$(pwd)/apt-cache"
  47. rm -f /etc/apt/apt.conf.d/docker-clean
  48. echo 'quiet "1";' \
  49. 'Acquire::Retries "20";' \
  50. 'APT::Install-Recommends "0";' \
  51. 'APT::Install-Suggests "0";' \
  52. 'APT::Get::Assume-Yes "true";' \
  53. 'Dpkg::Use-Pty "0";' \
  54. "Dir::Cache::Archives \"${APT_CACHE_DIR}\"; " \
  55. >> /etc/apt/apt.conf.d/99gitlab
  56. apt-get update -qq
  57. apt-get upgrade -qy
  58. # This template sets us up for Debian system in particular.
  59. .debian-template: &debian-template
  60. <<: *artifacts-template
  61. <<: *x86-64-template
  62. variables:
  63. DEBIAN_FRONTEND: "noninteractive"
  64. # TODO: Using "cache" in this way speeds up our downloads. It would be
  65. # even better, though, to start with a pre-upgraded debian image.
  66. #
  67. # TODO: Will we have to do this differently once we have more than one
  68. # debian version that we're using?
  69. cache:
  70. key: apt
  71. paths:
  72. - apt-cache
  73. before_script:
  74. - *apt-template
  75. # Install patches unconditionally.
  76. - apt-get install
  77. apt-utils
  78. automake
  79. build-essential
  80. ca-certificates
  81. file
  82. git
  83. libevent-dev
  84. liblzma-dev
  85. libscrypt-dev
  86. libseccomp-dev
  87. libssl-dev
  88. pkg-config
  89. python3
  90. zlib1g-dev
  91. # Install patches that we only need for some use cases.
  92. - if [ "$ASCIIDOC" = yes ]; then apt-get install asciidoc xmlto; fi
  93. - if [ "$DOXYGEN" = yes ]; then apt-get install doxygen; fi
  94. - if [ "$STEM" = yes ]; then apt-get install timelimit; fi
  95. - if [ "$CC" = clang ]; then apt-get install clang; fi
  96. - if [ "$NSS" = yes ]; then apt-get install libnss3 libnss3-dev; fi
  97. # llvm-symbolizer for sanitizer backtrace
  98. - if [ "$HARDENING" = yes ]; then apt-get install llvm; fi
  99. # TODO: This next line should not be debian-only.
  100. - if [ "$STEM" = yes ]; then git clone --depth 1 https://gitlab.torproject.org/tpo/network-health/stem.git ; export STEM_PATH="$(pwd)/stem"; fi
  101. # TODO: This next line should not be debian-only.
  102. - if [ "$CHUTNEY" = yes ]; then git clone --depth 1 https://gitlab.torproject.org/tpo/core/chutney.git ; export CHUTNEY_PATH="$(pwd)/chutney"; fi
  103. - if [ "$TRACING" = yes ]; then apt install liblttng-ust-dev; fi
  104. # Minimal check on debian: just make, make check.
  105. #
  106. debian-minimal:
  107. image: debian:bullseye
  108. <<: *debian-template
  109. script:
  110. - ./scripts/ci/ci-driver.sh
  111. # Minimal check on debian/i386: just make, make check.
  112. #
  113. debian-i386-minimal:
  114. image: i386/debian:bullseye
  115. <<: *debian-template
  116. script:
  117. - ./scripts/ci/ci-driver.sh
  118. tags:
  119. - physical
  120. #####
  121. # Run "make check" with a hardened clang on debian stable. This takes
  122. # care of a hardening check, and a compile-with-clang check.
  123. #
  124. # TODO: This will be faster once we merge #40098 and #40099.
  125. debian-hardened:
  126. image: debian:bullseye
  127. <<: *debian-template
  128. variables:
  129. ALL_BUGS_ARE_FATAL: "yes"
  130. HARDENING: "yes"
  131. CC: "clang"
  132. script:
  133. - ./scripts/ci/ci-driver.sh
  134. #####
  135. # Distcheck on debian stable
  136. debian-distcheck:
  137. image: debian:bullseye
  138. <<: *debian-template
  139. variables:
  140. DISTCHECK: "yes"
  141. CHECK: "no"
  142. script:
  143. - ./scripts/ci/ci-driver.sh
  144. #####
  145. # Documentation tests on debian stable: doxygen and asciidoc.
  146. debian-docs:
  147. image: debian:bullseye
  148. <<: *debian-template
  149. variables:
  150. DOXYGEN: "yes"
  151. ASCIIDOC: "yes"
  152. CHECK: "no"
  153. RUN_STAGE_BUILD: "no"
  154. script:
  155. - ./scripts/ci/ci-driver.sh
  156. #####
  157. # Integration tests on debian stable: chutney and stem.
  158. #
  159. # TODO: It would be cool if this target didn't have to re-build tor, and
  160. # could instead re-use Tor from debian-minimal. That can be done
  161. # with the 'artifacts' mechanism, in theory, but it would be good to
  162. # avoid having to have a system with hundreds of artifacts.
  163. debian-integration:
  164. image: debian:bullseye
  165. <<: *debian-template
  166. variables:
  167. CHECK: "no"
  168. CHUTNEY: "yes"
  169. CHUTNEY_MAKE_TARGET: "test-network-all"
  170. STEM: "yes"
  171. ALL_BUGS_ARE_FATAL: "yes"
  172. script:
  173. - ./scripts/ci/ci-driver.sh
  174. #####
  175. # Tracing build on Debian stable.
  176. debian-tracing:
  177. image: debian:bullseye
  178. <<: *debian-template
  179. variables:
  180. TRACING: "yes"
  181. CHECK: "no"
  182. DISTCHECK: "yes"
  183. script:
  184. - ./scripts/ci/ci-driver.sh
  185. #####
  186. # No-authority mode
  187. debian-disable-dirauth:
  188. image: debian:bullseye
  189. <<: *debian-template
  190. variables:
  191. DISABLE_DIRAUTH: "yes"
  192. script:
  193. - ./scripts/ci/ci-driver.sh
  194. #####
  195. # No-relay mode
  196. debian-disable-relay:
  197. image: debian:bullseye
  198. <<: *debian-template
  199. variables:
  200. DISABLE_RELAY: "yes"
  201. script:
  202. - ./scripts/ci/ci-driver.sh
  203. #####
  204. # GPL licensed mode, enables pow module
  205. debian-gpl:
  206. image: debian:buster
  207. <<: *debian-template
  208. variables:
  209. GPL: "yes"
  210. script:
  211. - ./scripts/ci/ci-driver.sh
  212. #####
  213. # NSS check on debian
  214. debian-nss:
  215. image: debian:bullseye
  216. <<: *debian-template
  217. variables:
  218. NSS: "yes"
  219. script:
  220. - ./scripts/ci/ci-driver.sh
  221. #####
  222. # Debian packaging triggers for maintenance branches
  223. debian-packaging-0.4.5:
  224. stage: deploy
  225. trigger:
  226. project: tpo/core/debian/tor
  227. branch: debian-0.4.5
  228. rules:
  229. - if: $CI_PROJECT_NAMESPACE == "tpo/core" &&
  230. $CI_COMMIT_BRANCH == "maint-0.4.5"
  231. debian-packaging-0.4.6:
  232. stage: deploy
  233. trigger:
  234. project: tpo/core/debian/tor
  235. branch: debian-0.4.6
  236. rules:
  237. - if: $CI_PROJECT_NAMESPACE == "tpo/core" &&
  238. $CI_COMMIT_BRANCH == "maint-0.4.6"
  239. #####
  240. # Run tests written in Rust, and run clippy on all Rust code here.
  241. rust-latest:
  242. image: rust:latest
  243. <<: *debian-template
  244. script:
  245. - apt-get install llvm-dev libclang-dev clang
  246. - rustup show
  247. - cargo build --locked --verbose
  248. - cargo test --verbose
  249. - rustup component add clippy
  250. - rustup show
  251. - cargo clippy --all-features --all-targets -- -D warnings
  252. after_script:
  253. - cargo clean