.gitlab-ci.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. # This template should be usable on any system that's based on apt.
  41. .apt-template: &apt-template |
  42. export LC_ALL=C.UTF-8
  43. echo Etc/UTC > /etc/timezone
  44. mkdir -p apt-cache
  45. export APT_CACHE_DIR="$(pwd)/apt-cache"
  46. echo 'quiet "1";' \
  47. 'APT::Install-Recommends "0";' \
  48. 'APT::Install-Suggests "0";' \
  49. 'APT::Acquire::Retries "20";' \
  50. 'APT::Get::Assume-Yes "true";' \
  51. 'Dpkg::Use-Pty "0";' \
  52. "Dir::Cache::Archives \"${APT_CACHE_DIR}\"; " \
  53. >> /etc/apt/apt.conf.d/99gitlab
  54. apt-get update -qq
  55. apt-get upgrade -qy
  56. # This template sets us up for Debian system in particular.
  57. .debian-template: &debian-template
  58. <<: *artifacts-template
  59. <<: *x86-64-template
  60. variables:
  61. DEBIAN_FRONTEND: "noninteractive"
  62. # TODO: Using "cache" in this way speeds up our downloads. It would be
  63. # even better, though, to start with a pre-upgraded debian image.
  64. #
  65. # TODO: Will we have to do this differently once we have more than one
  66. # debian version that we're using?
  67. cache:
  68. key: apt
  69. paths:
  70. - apt-cache
  71. before_script:
  72. - *apt-template
  73. # Install patches unconditionally.
  74. - apt-get install
  75. automake
  76. build-essential
  77. ca-certificates
  78. git
  79. libevent-dev
  80. liblzma-dev
  81. libscrypt-dev
  82. libseccomp-dev
  83. libssl-dev
  84. pkg-config
  85. python3
  86. zlib1g-dev
  87. # Install patches that we only need for some use cases.
  88. - if [ "$ASCIIDOC" = yes ]; then apt-get install asciidoc xmlto; fi
  89. - if [ "$DOXYGEN" = yes ]; then apt-get install doxygen; fi
  90. - if [ "$STEM" = yes ]; then apt-get install timelimit; fi
  91. - if [ "$CC" = clang ]; then apt-get install clang; fi
  92. - if [ "$NSS" = yes ]; then apt-get install libnss3 libnss3-dev; fi
  93. # TODO: This next line should not be debian-only.
  94. - if [ "$STEM" = yes ]; then git clone --depth 1 https://git.torproject.org/stem.git ; export STEM_PATH="$(pwd)/stem"; fi
  95. # TODO: This next line should not be debian-only.
  96. - if [ "$CHUTNEY" = yes ]; then git clone --depth 1 https://git.torproject.org/chutney.git ; export CHUTNEY_PATH="$(pwd)/chutney"; fi
  97. - if [ "$TRACING" = yes ]; then apt install liblttng-ust-dev; fi
  98. # Minmal check on debian: just make, make check.
  99. #
  100. debian-minimal:
  101. image: debian:buster
  102. <<: *debian-template
  103. script:
  104. - ./scripts/ci/ci-driver.sh
  105. # Minmal check on debian/i386: just make, make check.
  106. #
  107. debian-i386-minimal:
  108. image: i386/debian:buster
  109. <<: *debian-template
  110. script:
  111. - ./scripts/ci/ci-driver.sh
  112. #####
  113. # Run "make check" with a hardened clang on debian stable. This takes
  114. # care of a hardening check, and a compile-with-clang check.
  115. #
  116. # TODO: This will be faster once we merge #40098 and #40099.
  117. debian-hardened:
  118. image: debian:bullseye
  119. <<: *debian-template
  120. variables:
  121. ALL_BUGS_ARE_FATAL: "yes"
  122. HARDENING: "yes"
  123. CC: "clang"
  124. script:
  125. - ./scripts/ci/ci-driver.sh
  126. #####
  127. # Distcheck on debian stable
  128. debian-distcheck:
  129. image: debian:buster
  130. <<: *debian-template
  131. variables:
  132. DISTCHECK: "yes"
  133. CHECK: "no"
  134. script:
  135. - ./scripts/ci/ci-driver.sh
  136. #####
  137. # Documentation tests on debian stable: doxygen and asciidoc.
  138. debian-docs:
  139. image: debian:buster
  140. <<: *debian-template
  141. variables:
  142. DOXYGEN: "yes"
  143. ASCIIDOC: "yes"
  144. CHECK: "no"
  145. RUN_STAGE_BUILD: "no"
  146. script:
  147. - ./scripts/ci/ci-driver.sh
  148. #####
  149. # Integration tests on debian stable: chutney and stem.
  150. #
  151. # TODO: It would be cool if this target didn't have to re-build tor, and
  152. # could instead re-use Tor from debian-minimal. That can be done
  153. # with the 'artifacts' mechanism, in theory, but it would be good to
  154. # avoid having to have a system with hundreds of artifacts.
  155. debian-integration:
  156. image: debian:buster
  157. <<: *debian-template
  158. variables:
  159. CHECK: "no"
  160. CHUTNEY: "yes"
  161. CHUTNEY_MAKE_TARGET: "test-network-all"
  162. STEM: "yes"
  163. ALL_BUGS_ARE_FATAL: "yes"
  164. script:
  165. - ./scripts/ci/ci-driver.sh
  166. #####
  167. # Tracing build on Debian stable.
  168. debian-tracing:
  169. image: debian:buster
  170. <<: *debian-template
  171. variables:
  172. TRACING: "yes"
  173. CHECK: "no"
  174. script:
  175. - ./scripts/ci/ci-driver.sh
  176. # Ensure that we only run tracing when it's implemented.
  177. #
  178. # Once versions before 0.4.5 are obsolete, we can remove this test.
  179. rules:
  180. # This first "if" check prevents us from running a duplicate version of
  181. # this pipeline whenever we push and create an MR. I don't understand why
  182. # it is necessary, though the following URL purports to explain:
  183. #
  184. # https://docs.gitlab.com/ee/ci/yaml/#prevent-duplicate-pipelines
  185. - if: '$CI_PIPELINE_SOURCE == "push"'
  186. exists:
  187. - src/lib/trace/trace_sys.c
  188. #####
  189. # No-authority mode
  190. debian-disable-dirauth:
  191. image: debian:buster
  192. <<: *debian-template
  193. variables:
  194. DISABLE_DIRAUTH: "yes"
  195. script:
  196. - ./scripts/ci/ci-driver.sh
  197. #####
  198. # No-relay mode
  199. debian-disable-relay:
  200. image: debian:buster
  201. <<: *debian-template
  202. variables:
  203. DISABLE_RELAY: "yes"
  204. script:
  205. - ./scripts/ci/ci-driver.sh
  206. # Ensure that we only run tracing when it's implemented.
  207. #
  208. # Once versions before 0.4.3 are obsolete, we can remove this test.
  209. rules:
  210. # This first "if" check prevents us from running a duplicate version of
  211. # this pipeline whenever we push and create an MR. I don't understand why
  212. # it is necessary, though the following URL purports to explain:
  213. #
  214. # https://docs.gitlab.com/ee/ci/yaml/#prevent-duplicate-pipelines
  215. - if: '$CI_PIPELINE_SOURCE == "push"'
  216. exists:
  217. - src/feature/relay/relay_stub.c
  218. #####
  219. # NSS check on debian
  220. debian-nss:
  221. image: debian:buster
  222. <<: *debian-template
  223. variables:
  224. NSS: "yes"
  225. script:
  226. - ./scripts/ci/ci-driver.sh