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