ldap: Add a database open after fork to speed-up prefork binds
[bbaumbach/samba-autobuild/.git] / bootstrap / .gitlab-ci.yml
1 services:
2   - docker:dind
3
4 .build_image_template:
5   image: docker:latest
6   stage: images
7   tags:
8     - docker
9   variables:
10     SAMBA_CI_IS_BROKEN_IMAGE: "no"
11   before_script:
12     # Ensure we are generating correct the container
13     - uname -a
14     - cat /etc/os-release
15     - echo "SAMBA_CI_CONTAINER_REGISTRY[${SAMBA_CI_CONTAINER_REGISTRY}]"
16     - echo "SAMBA_CI_CONTAINER_TAG[${SAMBA_CI_CONTAINER_TAG}]"
17     - echo "SAMBA_CI_IS_BROKEN_IMAGE[${SAMBA_CI_IS_BROKEN_IMAGE}]"
18     - echo "SAMBA_CI_REBUILD_IMAGES[${SAMBA_CI_REBUILD_IMAGES}]"
19     - echo "SAMBA_CI_REBUILD_BROKEN_IMAGES[${SAMBA_CI_REBUILD_BROKEN_IMAGES}]"
20     - echo "GITLAB_USER_LOGIN[${GITLAB_USER_LOGIN}]"
21     - echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
22     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
23   script: |
24     set -xueo pipefail
25     ci_image_name=samba-ci-${CI_JOB_NAME}
26     docker build -t ${ci_image_name} --build-arg SHA1SUM=${SAMBA_CI_CONTAINER_TAG} bootstrap/generated-dists/${CI_JOB_NAME}
27     ci_image_path="${SAMBA_CI_CONTAINER_REGISTRY}/${ci_image_name}"
28     timestamp=$(date +%Y%m%d%H%M%S)
29     docker_hash=$(docker image inspect --format='{{index .Id}}' ${ci_image_name} | cut -d : -f 2 | cut -c 1-9)
30     timestamp_tag=${SAMBA_CI_CONTAINER_TAG}-${timestamp}-${GITLAB_USER_LOGIN}-${docker_hash}
31     samba_repo_root=/home/samba/samba
32     # Ensure we are generating the correct container that we expect to be in
33     echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
34     diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
35     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
36         /bin/bash -c "echo \"${SAMBA_CI_CONTAINER_TAG}\" > /tmp/sha1sum-tag.txt; diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt"
37     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
38         diff -u bootstrap/sha1sum.txt /sha1sum.txt
39     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
40         bootstrap/template.py --sha1sum > /tmp/sha1sum-template.txt
41     diff -u bootstrap/sha1sum.txt /tmp/sha1sum-template.txt
42     # run smoke test with samba-o3
43     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
44         /bin/bash -c "sudo chown -R samba:samba ./** && script/autobuild.py samba-o3 --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase"
45     docker tag ${ci_image_name} ${ci_image_path}:${SAMBA_CI_CONTAINER_TAG}
46     docker tag ${ci_image_name} ${ci_image_path}:${timestamp_tag}
47     # We build all images, but only upload is it's not marked as broken
48     test x"${SAMBA_CI_IS_BROKEN_IMAGE}" = x"yes" || { \
49         docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY; \
50         docker push ${ci_image_path}:${SAMBA_CI_CONTAINER_TAG}; \
51         docker push ${ci_image_path}:${timestamp_tag}; \
52     }
53     echo "Success for ${ci_image_path}:${timestamp_tag}"
54     test x"${SAMBA_CI_IS_BROKEN_IMAGE}" = x"no" || { \
55          echo "The image ${CI_JOB_NAME} is marked as broken and should have failed!"; \
56          echo "Replace .build_image_template_force_broken with .build_image_template!"; \
57          echo "Add a .samba-o3-template section at the end of the main .gitlab-ci.yml!"; \
58          /bin/false; \
59     }
60   only:
61     variables:
62       #
63       # You need a custom pipeline which passes
64       # SAMBA_CI_REBUILD_IMAGES="yes".
65       #
66       # https://gitlab.com/samba-team/devel/samba/pipelines/new
67       #
68       - $SAMBA_CI_REBUILD_IMAGES == "yes"
69
70 .build_image_template_force_broken:
71   extends: .build_image_template
72   variables:
73     SAMBA_CI_IS_BROKEN_IMAGE: "yes"
74   only:
75     variables:
76       #
77       # You need a custom pipeline which passes
78       # SAMBA_CI_REBUILD_BROKEN_IMAGES="yes"
79       # in order to build broken images for debugging
80       #
81       # https://gitlab.com/samba-team/devel/samba/pipelines/new
82       #
83       - $SAMBA_CI_REBUILD_BROKEN_IMAGES == "yes"
84
85 ubuntu1804:
86   extends: .build_image_template
87
88 ubuntu1604:
89   extends: .build_image_template
90
91 ubuntu1404:
92   extends: .build_image_template_force_broken
93
94 debian9:
95   extends: .build_image_template
96
97 debian8:
98   extends: .build_image_template_force_broken
99
100 debian7:
101   extends: .build_image_template_force_broken
102
103 fedora29:
104   extends: .build_image_template
105
106 fedora28:
107   extends: .build_image_template_force_broken
108
109 centos7:
110   extends: .build_image_template
111   variables:
112     # Shallow copies are not supported by git on CentOS7
113     GIT_DEPTH: ""
114
115 centos6:
116   extends: .build_image_template_force_broken
117
118 opensuse150:
119   extends: .build_image_template