script/autobuild.py: split samba-no-opath into two tests
[samba.git] / .gitlab-ci-main.yml
1 # see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options
2
3 # Stages explained
4 #
5 # images: Build the images with the bootstrap script
6 # build_first: Build a few things first to find silly errors (fast job)
7 #              (don't pay for 35 machines until something compiles)
8 # build: The main parallel job
9 #              (keep these to 1hour as we are billed per hour)
10 # test_only: Tests using the build from prior stages, these typically
11 #            have an explicit dependency defined to a specific build job,
12 #            which means that start as soon as the build job finished.
13 # test_private: Like test_only, but running on private runners
14 # report: Code coverage reporting
15
16 stages:
17   - images
18   - build_first
19   - build
20   - test_only
21   - test_private
22   - report
23
24 variables:
25   # We want to be resilient to runner failures
26   ARTIFACT_DOWNLOAD_ATTEMPTS: "3"
27   EXECUTOR_JOB_SECTION_ATTEMPTS: "3"
28   GET_SOURCES_ATTEMPTS: "3"
29   RESTORE_CACHE_ATTEMPTS: "3"
30   #
31   GIT_STRATEGY: fetch
32   GIT_DEPTH: "3"
33   # "--enable-coverage" or ""
34   SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE: ""
35   #
36   # we run autobuild.py inside a samba CI docker image located on gitlab's registry
37   # overwrite this variable if you want use your own image registry.
38   #
39   # Or better ask for access to the shared development repository, see
40   # https://wiki.samba.org/index.php/Samba_CI_on_gitlab#Getting_Access
41   #
42   SAMBA_CI_CONTAINER_REGISTRY: registry.gitlab.com/samba-team/devel/samba
43   #
44   # Set this to the contents of bootstrap/sha1sum.txt
45   # which is generated by bootstrap/template.py --render
46   #
47   SAMBA_CI_CONTAINER_TAG: f25e1fa0a828f428ade0e4f37d8a646ff1e207d4
48   #
49   # We use the ubuntu1804 image as default as
50   # it matches what we have on sn-devel-184.
51   #
52   SAMBA_CI_CONTAINER_IMAGE: ubuntu1804
53   #
54   # The following images are available
55   # Please see the samba-o3 sections at the end of this file!
56   # We should run that for each available image
57   #
58   SAMBA_CI_CONTAINER_IMAGE_ubuntu1604: ubuntu1604
59   SAMBA_CI_CONTAINER_IMAGE_ubuntu1804: ubuntu1804
60   SAMBA_CI_CONTAINER_IMAGE_ubuntu2004: ubuntu2004
61   SAMBA_CI_CONTAINER_IMAGE_debian9: debian9
62   SAMBA_CI_CONTAINER_IMAGE_debian10: debian10
63   SAMBA_CI_CONTAINER_IMAGE_opensuse151: opensuse151
64   SAMBA_CI_CONTAINER_IMAGE_opensuse152: opensuse152
65   SAMBA_CI_CONTAINER_IMAGE_fedora32: fedora32
66   SAMBA_CI_CONTAINER_IMAGE_fedora33: fedora33
67   SAMBA_CI_CONTAINER_IMAGE_centos7: centos7
68   SAMBA_CI_CONTAINER_IMAGE_centos8: centos8
69
70 include:
71   # The image creation details are specified in a separate file
72   # See bootstrap/README.md for details
73   - 'bootstrap/.gitlab-ci.yml'
74
75 .shared_runner_build_image:
76   extends: .shared_runner_build
77   variables:
78     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE}
79   image: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-${SAMBA_CI_JOB_IMAGE}:${SAMBA_CI_CONTAINER_TAG}
80
81 .shared_template:
82   extends: .shared_runner_build_image
83   # All Samba jobs are interruptible, this avoids burning CPU when a
84   # newer branch is pushed.
85   interruptible: true
86   timeout: 2h
87
88   variables:
89     AUTOBUILD_JOB_NAME: $CI_JOB_NAME
90   stage: build
91   cache:
92     key: ccache.${CI_JOB_NAME}.${SAMBA_CI_JOB_IMAGE}
93     paths:
94       - ccache
95   before_script:
96     - uname -a
97     - lsb_release -a
98     - cat /etc/os-release
99     - lscpu
100     - cat /proc/cpuinfo
101     - mount
102     - df -h
103     - cat /proc/swaps
104     - free -h
105       # ld will fail if coverage enabled, force link ld to ld.bfd
106     - if [ -n "$SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE" ]; then sudo ln -sf $(which ld.bfd) $(which ld); fi
107       # See bootstrap/.gitlab-ci.yml how to generate a new image
108     - echo "SAMBA_CI_CONTAINER_REGISTRY[${SAMBA_CI_CONTAINER_REGISTRY}]"
109     - echo "SAMBA_CI_CONTAINER_TAG[${SAMBA_CI_CONTAINER_TAG}]"
110     - echo "SAMBA_CI_JOB_IMAGE[${SAMBA_CI_JOB_IMAGE}]"
111     - echo "CI_JOB_IMAGE[${CI_JOB_IMAGE}]"
112     - bootstrap/template.py --sha1sum > /tmp/sha1sum-template.txt
113     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-template.txt
114     - echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
115     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
116     - diff -u bootstrap/sha1sum.txt /sha1sum.txt
117     - echo "${CI_COMMIT_SHA} ${CI_COMMIT_TITLE}" > /tmp/commit.txt
118     - export CCACHE_BASEDIR="${PWD}"
119     - export CCACHE_DIR="${PWD}/ccache" && mkdir -pv "$CCACHE_DIR"
120     - export CC="ccache cc"
121     - export CXX="ccache c++"
122     - ccache -z -M 500M
123     - ccache -s
124   after_script:
125     - mount
126     - df -h
127     - cat /proc/swaps
128     - free -h
129     - CCACHE_BASEDIR="${PWD}" CCACHE_DIR="${PWD}/ccache" ccache -s -c
130   artifacts:
131     expire_in: 1 week
132     paths:
133       - "*.stdout"
134       - "*.stderr"
135       - "*.info"
136       - system-info.txt
137   retry:
138     max: 2
139     when:
140       - runner_system_failure
141       - stuck_or_timeout_failure
142       - api_failure
143       - runner_unsupported
144       - stale_schedule
145       - job_execution_timeout
146       - archived_failure
147       - scheduler_failure
148       - data_integrity_failure
149
150   script:
151     # gitlab predefines CI_JOB_NAME for each job. The gitlab job usually matches the
152     # autobuild name, which means we can define a default template that runs most autobuild jobs
153     - script/autobuild.py $AUTOBUILD_JOB_NAME $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE  --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase
154
155 # Ensure when adding a new job below that you also add it to
156 # the dependencies for 'pages' below for the code coverage page
157 # generation.
158
159 others:
160   extends: .shared_template
161   script:
162     - script/autobuild.py ldb      $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/ldb
163     - script/autobuild.py pidl     $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/pidl
164     - script/autobuild.py replace  $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/replace
165     - script/autobuild.py talloc   $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/talloc
166     - script/autobuild.py tdb      $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/tdb
167     - script/autobuild.py tevent   $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/tevent
168     - script/autobuild.py samba-xc $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/samba-xc
169     - script/autobuild.py docs-xml $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase/docs-xml
170
171 .shared_template_build_only:
172   extends: .shared_template
173   timeout: 45m
174   artifacts:
175     expire_in: 1 week
176     paths:
177       - "*.stdout"
178       - "*.stderr"
179       - "*.info"
180       - system-info.txt
181       - samba-testbase.tar.gz
182   script:
183     # gitlab predefines CI_JOB_NAME for each job. The gitlab job usually matches the
184     # autobuild name, which means we can define a default template that runs most autobuild jobs
185     - script/autobuild.py $AUTOBUILD_JOB_NAME $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE  --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase
186     # On success we need to pack everything into an artifacts file
187     # which needs to be in the git checkout.
188     # As tar doesn't handle hardlink of read-only files,
189     # we remember the acls and add write permissions
190     # before creating the archive. The consumer will apply
191     # the acls again.
192     - cp -a /sha1sum.txt /tmp/samba-testbase/image-sha1sum.txt
193     - cp -a /tmp/commit.txt /tmp/samba-testbase/commit.txt
194     - pushd /tmp && getfacl -R samba-testbase > samba-testbase.acl.dump && popd
195     - chmod -R +w /tmp/samba-testbase
196     - mv /tmp/samba-testbase.acl.dump /tmp/samba-testbase/
197     - tar cfz samba-testbase.tar.gz /tmp/samba-testbase
198     - ls -la samba-testbase.tar.gz
199     - sha1sum samba-testbase.tar.gz
200
201 .shared_template_test_only:
202   extends:
203     - .shared_template
204     - .shared_runner_test
205   stage: test_only
206   script:
207     # We unpack the artifacts file created by the .shared_template_build_only
208     # run we depend on
209     - ls -la samba-testbase.tar.gz
210     - sha1sum samba-testbase.tar.gz
211     - tar xfz samba-testbase.tar.gz -C /
212     - diff -u /tmp/samba-testbase/image-sha1sum.txt /sha1sum.txt
213     - diff -u /tmp/samba-testbase/commit.txt /tmp/commit.txt
214     - mv /tmp/samba-testbase/samba-testbase.acl.dump /tmp/samba-testbase.acl.dump
215     - pushd /tmp && setfacl --restore=/tmp/samba-testbase.acl.dump && popd
216     # gitlab predefines CI_JOB_NAME for each job. The gitlab job usually matches the
217     # autobuild name, which means we can define a default template that runs most autobuild jobs
218     - script/autobuild.py $AUTOBUILD_JOB_NAME $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE --skip-dependencies --verbose --nocleanup --keeplogs --tail --full-testbase /tmp/samba-testbase
219
220 samba-def-build:
221   extends: .shared_template_build_only
222   stage: build_first
223
224 .needs_samba-def-build:
225   extends: .shared_template_test_only
226   needs:
227     - job: samba-def-build
228       artifacts: true
229
230 samba-mit-build:
231   extends: .shared_template_build_only
232   stage: build_first
233
234 .needs_samba-mit-build:
235   extends: .shared_template_test_only
236   needs:
237     - job: samba-mit-build
238       artifacts: true
239
240 samba-h5l-build:
241   extends: .shared_template_build_only
242
243 .needs_samba-h5l-build:
244   extends: .shared_template_test_only
245   needs:
246     - job: samba-h5l-build
247       artifacts: true
248
249 samba-nt4-build:
250   extends: .shared_template_build_only
251
252 .needs_samba-nt4-build:
253   extends: .shared_template_test_only
254   needs:
255     - job: samba-nt4-build
256       artifacts: true
257
258 samba-no-opath-build:
259   extends: .shared_template_build_only
260
261 .needs_samba-no-opath-build:
262   extends: .shared_template_test_only
263   needs:
264     - job: samba-no-opath-build
265       artifacts: true
266
267 samba:
268   extends: .shared_template
269
270 samba-mitkrb5:
271   extends: .shared_template
272
273 samba-minimal-smbd:
274   extends: .shared_template
275
276 samba-admem:
277   extends: .needs_samba-def-build
278
279 samba-ad-dc-2:
280   extends: .needs_samba-def-build
281
282 samba-ad-dc-3:
283   extends: .needs_samba-def-build
284
285 samba-ad-dc-4:
286   extends: .needs_samba-def-build
287
288 samba-ad-dc-5:
289   extends: .needs_samba-def-build
290
291 samba-ad-dc-6:
292   extends: .needs_samba-def-build
293
294 samba-ad-back1:
295   extends: .needs_samba-def-build
296
297 samba-ad-back2:
298   extends: .needs_samba-def-build
299
300 samba-schemaupgrade:
301   extends: .needs_samba-def-build
302
303 samba-libs:
304   extends: .shared_template
305
306 samba-fuzz:
307   extends: .shared_template
308   variables:
309     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_ubuntu1604}
310
311 ctdb:
312   extends: .shared_template
313
314 samba-ctdb:
315   extends: .shared_template
316
317 samba-ad-dc-ntvfs:
318   extends: .needs_samba-def-build
319
320 samba-admem-mit:
321   extends: .needs_samba-mit-build
322
323 samba-ad-dc-4-mitkrb5:
324   extends: .needs_samba-mit-build
325
326 # This task is run first to ensure we compile before we start the
327 # main run as it is the fastest full compile of Samba.
328 samba-fips:
329   extends: .shared_template
330   variables:
331     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora33}
332
333 .private_test_only:
334   extends: .private_runner_test
335   stage: test_private
336   only:
337     variables:
338       # These jobs are only run if the gitlab repo has private runners available.
339       # To enable private jobs, you must add the following var and value to
340       # your gitlab repo by navigating to:
341       # settings -> CI/CD -> Environment variables
342       - $SUPPORT_PRIVATE_TEST == "yes"
343
344 .needs_samba-def-build-private:
345   extends:
346     - .needs_samba-def-build
347     - .private_test_only
348
349 .needs_samba-mit-build-private:
350   extends:
351     - .needs_samba-mit-build
352     - .private_test_only
353
354 .needs_samba-h5l-build-private:
355   extends:
356     - .needs_samba-h5l-build
357     - .private_test_only
358
359 .needs_samba-nt4-build-private:
360   extends:
361     - .needs_samba-nt4-build
362     - .private_test_only
363
364 .needs_samba-no-opath-build-private:
365   extends:
366     - .needs_samba-no-opath-build
367     - .private_test_only
368
369 samba-fileserver:
370   extends: .needs_samba-h5l-build-private
371
372 samba-ad-dc-1:
373   extends: .needs_samba-def-build-private
374
375 samba-nt4:
376   extends: .needs_samba-nt4-build-private
377
378 samba-ad-dc-1-mitkrb5:
379   extends: .needs_samba-mit-build-private
380
381 samba-no-opath1:
382   extends: .needs_samba-no-opath-build-private
383
384 samba-no-opath2:
385   extends: .needs_samba-no-opath-build-private
386
387 # 'pages' is a special job which can publish artifacts in `public` dir to gitlab pages
388 pages:
389   extends: .shared_runner_build_image
390   stage: report
391   dependencies:  # tell gitlab to download artifacts for these jobs
392     - others
393     - samba
394     - samba-mitkrb5
395     - samba-admem
396     - samba-ad-dc-2
397     - samba-ad-dc-3
398     - samba-ad-dc-4
399     - samba-ad-dc-5
400     - samba-ad-dc-6
401     - samba-libs
402     - samba-minimal-smbd
403     - samba-fuzz
404     # - ctdb  # TODO
405     - samba-ctdb
406     - samba-ad-dc-ntvfs
407     - samba-admem-mit
408     - samba-ad-dc-4-mitkrb5
409     - samba-ad-back1
410     - samba-ad-back2
411     - samba-fileserver
412     - samba-ad-dc-1
413     - samba-nt4
414     - samba-schemaupgrade
415     - samba-ad-dc-1-mitkrb5
416     - samba-fips
417     - samba-no-opath1
418     - samba-no-opath2
419   script:
420     - ./configure.developer
421     - make -j
422     - lcov $(ls *.info | xargs -I{} echo -n "-a {} ") -o all.info
423     - genhtml all.info --output-directory public --prefix=$(pwd) --title "coverage report for $CI_COMMIT_REF_NAME $CI_COMMIT_SHORT_SHA"
424   artifacts:
425     expire_in: 30 days
426     paths:
427       - public
428   only:
429     variables:
430       - $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE == "--enable-coverage"
431
432 # Coverity Scan
433 coverity:
434   extends: .shared_runner_build_image
435   variables:
436     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora33}
437   stage: build
438   script:
439     - wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=$COVERITY_SCAN_PROJECT_NAME" -O /tmp/coverity_tool.tgz
440     - tar xf /tmp/coverity_tool.tgz
441     - ./configure.developer --with-cluster-support --with-system-mitkrb5 --with-experimental-mit-ad-dc
442     - cov-analysis-linux64-*/bin/cov-build --dir cov-int make -j$(nproc)
443     - tar czf cov-int.tar.gz cov-int
444     - curl
445       --form token=$COVERITY_SCAN_TOKEN
446       --form email=$COVERITY_SCAN_EMAIL
447       --form file=@cov-int.tar.gz
448       --form version="`git describe --tags`"
449       --form description="CI build"
450       https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
451   only:
452     refs:
453       - master
454       - schedules
455     variables:
456       - $COVERITY_SCAN_TOKEN != null
457       - $COVERITY_SCAN_PROJECT_NAME != null
458       - $COVERITY_SCAN_EMAIL != null
459   artifacts:
460     expire_in: 1 week
461     when: on_failure
462     paths:
463       - cov-int/*.txt
464
465 #
466 # We build samba-o3 on all supported distributions
467 #
468
469 .samba-o3-template:
470   extends: .shared_template
471   variables:
472     AUTOBUILD_JOB_NAME: samba-o3
473   only:
474     variables:
475       # do not run o3 for coverage since they are using different images
476       - $SAMBA_CI_AUTOBUILD_ENABLE_COVERAGE == ""
477
478 ubuntu1804-samba-o3:
479   extends: .samba-o3-template
480   variables:
481     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_ubuntu1804}
482
483 ubuntu2004-samba-o3:
484   extends: .samba-o3-template
485   variables:
486     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_ubuntu2004}
487
488 debian10-samba-o3:
489   extends: .samba-o3-template
490   variables:
491     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_debian10}
492
493 opensuse151-samba-o3:
494   extends: .samba-o3-template
495   variables:
496     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_opensuse151}
497
498 opensuse152-samba-o3:
499   extends: .samba-o3-template
500   variables:
501     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_opensuse152}
502
503 centos7-samba-o3:
504   extends: .samba-o3-template
505   variables:
506     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_centos7}
507     # Git on CentOS doesn't support shallow git cloning
508     GIT_DEPTH: ""
509     # We need a newer GnuTLS version on CentOS7
510     PKG_CONFIG_PATH: "/usr/lib64/compat-gnutls34/pkgconfig:/usr/lib64/compat-nettle32/pkgconfig"
511
512 centos8-samba-o3:
513   extends: .samba-o3-template
514   variables:
515     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_centos8}
516
517 fedora32-samba-o3:
518   extends: .samba-o3-template
519   variables:
520     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora32}
521
522 fedora33-samba-o3:
523   extends: .samba-o3-template
524   variables:
525     SAMBA_CI_JOB_IMAGE: ${SAMBA_CI_CONTAINER_IMAGE_fedora33}
526
527 #
528 # Keep the samba-o3 sections at the end ...
529 #