autobuild: Remove the os.getpid() from the autobuild directory
[samba.git] / .gitlab-ci.yml
1 # see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options
2
3 stages:
4   - images
5   - build
6   - analysis
7   - report
8
9 variables:
10   GIT_STRATEGY: fetch
11   GIT_DEPTH: "3"
12   # "--enable-coverage" or ""
13   SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE: ""
14   #
15   # we run autobuild.py inside a samba CI docker image located on gitlab's registry
16   # overwrite this variable if you want use your own image registry.
17   #
18   # Or better ask for access to the shared development repository, see
19   # https://wiki.samba.org/index.php/Samba_CI_on_gitlab#Getting_Access
20   #
21   SAMBA_CI_CONTAINER_REGISTRY: registry.gitlab.com/samba-team/devel/samba
22   #
23   # Set this to the contents of bootstrap/sha1sum.txt
24   # which is generated by bootstrap/template.py --render
25   #
26   SAMBA_CI_CONTAINER_TAG: 86279163d150fb95742f4b34fce0dfc1a639f5de
27   #
28   # We use the ubuntu1804 image as default as
29   # it matches what we have on sn-devel-184.
30   #
31   SAMBA_CI_CONTAINER_IMAGE: ubuntu1804
32   #
33   # The following images are available
34   # Please see the samba-o3 sections at the end of this file!
35   # We should run that for each available image
36   #
37   SAMBA_CI_CONTAINER_IMAGE_ubuntu1604: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-ubuntu1604:${SAMBA_CI_CONTAINER_TAG}
38   SAMBA_CI_CONTAINER_IMAGE_ubuntu1804: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-ubuntu1804:${SAMBA_CI_CONTAINER_TAG}
39   SAMBA_CI_CONTAINER_IMAGE_ubuntu2004: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-ubuntu2004:${SAMBA_CI_CONTAINER_TAG}
40   SAMBA_CI_CONTAINER_IMAGE_debian9: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-debian9:${SAMBA_CI_CONTAINER_TAG}
41   SAMBA_CI_CONTAINER_IMAGE_debian10: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-debian10:${SAMBA_CI_CONTAINER_TAG}
42   SAMBA_CI_CONTAINER_IMAGE_opensuse150: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-opensuse150:${SAMBA_CI_CONTAINER_TAG}
43   SAMBA_CI_CONTAINER_IMAGE_opensuse151: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-opensuse151:${SAMBA_CI_CONTAINER_TAG}
44   SAMBA_CI_CONTAINER_IMAGE_fedora31: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-fedora31:${SAMBA_CI_CONTAINER_TAG}
45   SAMBA_CI_CONTAINER_IMAGE_fedora32: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-fedora32:${SAMBA_CI_CONTAINER_TAG}
46   SAMBA_CI_CONTAINER_IMAGE_centos7: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-centos7:${SAMBA_CI_CONTAINER_TAG}
47   SAMBA_CI_CONTAINER_IMAGE_centos8: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-centos8:${SAMBA_CI_CONTAINER_TAG}
48
49 include:
50   # The image creation details are specified in a separate file
51   # See bootstrap/README.md for details
52   - 'bootstrap/.gitlab-ci.yml'
53
54 .shared_template:
55   # All Samba jobs are interruptible, this avoids burning CPU when a
56   # newer branch is pushed.
57   interruptible: true
58
59   variables:
60     AUTOBUILD_JOB_NAME: $CI_JOB_NAME
61   image: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-${SAMBA_CI_CONTAINER_IMAGE}:${SAMBA_CI_CONTAINER_TAG}
62   stage: build
63   tags:
64     - docker
65     - shared
66   cache:
67     key: ccache.${CI_JOB_NAME}
68     paths:
69       - ccache
70   before_script:
71     - uname -a
72     - lsb_release -a
73     - cat /etc/os-release
74     - mount
75     - df -h
76     - cat /proc/swaps
77     - free -h
78       # ld will fail if coverage enabled, force link ld to ld.bfd
79     - if [ -n "$SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE" ]; then sudo ln -sf $(which ld.bfd) $(which ld); fi
80       # See bootstrap/.gitlab-ci.yml how to generate a new image
81     - echo "SAMBA_CI_CONTAINER_REGISTRY[${SAMBA_CI_CONTAINER_REGISTRY}]"
82     - echo "SAMBA_CI_CONTAINER_TAG[${SAMBA_CI_CONTAINER_TAG}]"
83     - bootstrap/template.py --sha1sum > /tmp/sha1sum-template.txt
84     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-template.txt
85     - echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
86     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
87     - diff -u bootstrap/sha1sum.txt /sha1sum.txt
88     - export CCACHE_BASEDIR="${PWD}"
89     - export CCACHE_DIR="${PWD}/ccache" && mkdir -pv "$CCACHE_DIR"
90     - export CC="ccache cc"
91     - export CXX="ccache c++"
92     - ccache -z -M 500M
93     - ccache -s
94   after_script:
95     - mount
96     - df -h
97     - cat /proc/swaps
98     - free -h
99     - CCACHE_BASEDIR="${PWD}" CCACHE_DIR="${PWD}/ccache" ccache -s -c
100   artifacts:
101     expire_in: 1 week
102     paths:
103       - "*.stdout"
104       - "*.stderr"
105       - "*.info"
106       - system-info.txt
107   retry:
108     max: 2
109     when:
110       - runner_system_failure
111       - stuck_or_timeout_failure
112   script:
113     # gitlab predefines CI_JOB_NAME for each job. The gitlab job usually matches the
114     # autobuild name, which means we can define a default template that runs most autobuild jobs
115     - echo "Running cmd script/autobuild.py $AUTOBUILD_JOB_NAME $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase"
116     - script/autobuild.py $AUTOBUILD_JOB_NAME $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE  --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase
117
118 # Ensure when adding a new job below that you also add it to
119 # the dependencies for 'pages' below for the code coverage page
120 # generation.
121
122 others:
123   extends: .shared_template
124   script:
125     - script/autobuild.py ldb      $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/ldb
126     - script/autobuild.py pidl     $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/pidl
127     - script/autobuild.py replace  $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/replace
128     - script/autobuild.py talloc   $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/talloc
129     - script/autobuild.py tdb      $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/tdb
130     - script/autobuild.py tevent   $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/tevent
131     - script/autobuild.py samba-xc $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/samba-xc
132     - script/autobuild.py docs-xml $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/docs-xml
133
134 samba:
135   extends: .shared_template
136
137 samba-mitkrb5:
138   extends: .shared_template
139
140 samba-minimal-smbd:
141   extends: .shared_template
142
143 samba-admem:
144   extends: .shared_template
145
146 samba-ad-dc-2:
147   extends: .shared_template
148
149 samba-ad-dc-3:
150   extends: .shared_template
151
152 samba-ad-dc-4:
153   extends: .shared_template
154
155 samba-ad-dc-5:
156   extends: .shared_template
157
158 samba-ad-dc-6:
159   extends: .shared_template
160
161 samba-libs:
162   extends: .shared_template
163
164 samba-fuzz:
165   extends: .shared_template
166   image: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-ubuntu1604:${SAMBA_CI_CONTAINER_TAG}
167
168 ctdb:
169   extends: .shared_template
170
171 samba-ctdb:
172   extends: .shared_template
173
174 samba-ad-dc-ntvfs:
175   extends: .shared_template
176
177 samba-admem-mit:
178   extends: .shared_template
179
180 samba-ad-dc-4-mitkrb5:
181   extends: .shared_template
182
183 samba-fips:
184   extends: .shared_template
185   image: $SAMBA_CI_CONTAINER_IMAGE_fedora32
186
187 .private_template:
188   extends: .shared_template
189   tags:
190     - docker
191     - samba-ci-private
192   only:
193     variables:
194       # These jobs are only run if the gitlab repo has private runners available.
195       # To enable private jobs, you must add the following var and value to
196       # your gitlab repo by navigating to:
197       # settings -> CI/CD -> Environment variables
198       - $SUPPORT_PRIVATE_TEST == "yes"
199
200 samba-ad-dc-backup:
201   extends: .private_template
202
203 samba-fileserver:
204   extends: .private_template
205
206 samba-ad-dc-1:
207   extends: .private_template
208
209 samba-nt4:
210   extends: .private_template
211
212 samba-schemaupgrade:
213   extends: .private_template
214
215 samba-ad-dc-1-mitkrb5:
216   extends: .private_template
217
218 # 'pages' is a special job which can publish artifacts in `public` dir to gitlab pages
219 pages:
220   image: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-${SAMBA_CI_CONTAINER_IMAGE}:${SAMBA_CI_CONTAINER_TAG}
221   stage: report
222   tags:
223     - docker
224     - shared
225   dependencies:  # tell gitlab to download artifacts for these jobs
226     - others
227     - samba
228     - samba-mitkrb5
229     - samba-admem
230     - samba-ad-dc-2
231     - samba-ad-dc-3
232     - samba-ad-dc-4
233     - samba-ad-dc-5
234     - samba-ad-dc-6
235     - samba-libs
236     - samba-minimal-smbd
237     - samba-fuzz
238     # - ctdb  # TODO
239     - samba-ctdb
240     - samba-ad-dc-ntvfs
241     - samba-admem-mit
242     - samba-ad-dc-4-mitkrb5
243     - samba-ad-dc-backup
244     - samba-fileserver
245     - samba-ad-dc-1
246     - samba-nt4
247     - samba-schemaupgrade
248     - samba-ad-dc-1-mitkrb5
249     - samba-fips
250   script:
251     - ./configure.developer
252     - make -j
253     - lcov $(ls *.info | xargs -I{} echo -n "-a {} ") -o all.info
254     - genhtml all.info --output-directory public --prefix=$(pwd) --title "coverage report for $CI_COMMIT_REF_NAME $CI_COMMIT_SHORT_SHA"
255   artifacts:
256     expire_in: 30 days
257     paths:
258       - public
259   only:
260     variables:
261       - $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE == "--enable-coverage"
262
263 # Coverity Scan
264 coverity:
265   stage: analysis
266   image: $SAMBA_CI_CONTAINER_IMAGE_fedora32
267   tags:
268     - docker
269     - shared
270   script:
271     - wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=$COVERITY_SCAN_PROJECT_NAME" -O /tmp/coverity_tool.tgz
272     - tar xf /tmp/coverity_tool.tgz
273     - ./configure.developer --with-system-mitkrb5 --with-experimental-mit-ad-dc
274     - cov-analysis-linux64-*/bin/cov-build --dir cov-int make -j$(nproc)
275     - tar czf cov-int.tar.gz cov-int
276     - curl
277       --form token=$COVERITY_SCAN_TOKEN
278       --form email=$COVERITY_SCAN_EMAIL
279       --form file=@cov-int.tar.gz
280       --form version="`git describe --tags`"
281       --form description="CI build"
282       https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
283   only:
284     refs:
285       - master
286       - schedules
287     variables:
288       - $COVERITY_SCAN_TOKEN != null
289       - $COVERITY_SCAN_PROJECT_NAME != null
290       - $COVERITY_SCAN_EMAIL != null
291   artifacts:
292     expire_in: 1 week
293     when: on_failure
294     paths:
295       - cov-int/*.txt
296
297 #
298 # We build samba-o3 on all supported distributions
299 #
300
301 .samba-o3-template:
302   extends: .shared_template
303   variables:
304     AUTOBUILD_JOB_NAME: samba-o3
305   only:
306     variables:
307       # do not run o3 for coverage since they are using different images
308       - $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE == ""
309
310 ubuntu1804-samba-o3:
311   extends: .samba-o3-template
312   image: $SAMBA_CI_CONTAINER_IMAGE_ubuntu1804
313
314 ubuntu2004-samba-o3:
315   extends: .samba-o3-template
316   image: $SAMBA_CI_CONTAINER_IMAGE_ubuntu2004
317
318 debian10-samba-o3:
319   extends: .samba-o3-template
320   image: $SAMBA_CI_CONTAINER_IMAGE_debian10
321
322 opensuse150-samba-o3:
323   extends: .samba-o3-template
324   image: $SAMBA_CI_CONTAINER_IMAGE_opensuse150
325
326 opensuse151-samba-o3:
327   extends: .samba-o3-template
328   image: $SAMBA_CI_CONTAINER_IMAGE_opensuse151
329
330 centos7-samba-o3:
331   extends: .samba-o3-template
332   image: $SAMBA_CI_CONTAINER_IMAGE_centos7
333   variables:
334     # Git on CentOS doesn't support shallow git cloning
335     GIT_DEPTH: ""
336     # We need a newer GnuTLS version on CentOS7
337     PKG_CONFIG_PATH: "/usr/lib64/compat-gnutls34/pkgconfig:/usr/lib64/compat-nettle32/pkgconfig"
338
339 centos8-samba-o3:
340   extends: .samba-o3-template
341   image: $SAMBA_CI_CONTAINER_IMAGE_centos8
342
343 fedora31-samba-o3:
344   extends: .samba-o3-template
345   image: $SAMBA_CI_CONTAINER_IMAGE_fedora31
346
347 fedora32-samba-o3:
348   extends: .samba-o3-template
349   image: $SAMBA_CI_CONTAINER_IMAGE_fedora32
350
351 #
352 # Keep the samba-o3 sections at the end ...
353 #