.gitlab-ci.yml 6.9 KB

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