summaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2019-03-14 17:15:47 +1300
committerStefan Metzmacher <metze@samba.org>2019-04-18 12:09:34 +0000
commit2300a38de36bab9980dc0ea1d8e55997946a0d19 (patch)
treeaef14ab6bbe16ccabe0e375ab110f35ef69fbe18 /bootstrap
parentf1b1bba5c32f8066845c900536e0f812882cddb1 (diff)
downloadsamba-2300a38de36bab9980dc0ea1d8e55997946a0d19.tar.gz
bootstrap/.gitlab-ci.yml: add ci file to trigger image auto build
Depending on 'SAMBA_CI_REBUILD_IMAGES=yes' (and 'SAMBA_CI_REBUILD_BROKEN_IMAGES=yes') as environment variables on a custom gitlab ci pipeline we'll generate und upload container images. bootstrap/README.md will get more details in the next commits. Please note ci in this file did NOT add the `latest` tag, since we want main ci to always use a fixed image based on the sha1sum of everything under bootstrap/ from now on. This also implies the new built image will not replace/break anything. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/.gitlab-ci.yml116
1 files changed, 116 insertions, 0 deletions
diff --git a/bootstrap/.gitlab-ci.yml b/bootstrap/.gitlab-ci.yml
new file mode 100644
index 00000000000..f6bbd9e0285
--- /dev/null
+++ b/bootstrap/.gitlab-ci.yml
@@ -0,0 +1,116 @@
+services:
+ - docker:dind
+
+.build_image_template:
+ image: docker:latest
+ stage: images
+ tags:
+ - docker
+ variables:
+ SAMBA_CI_IS_BROKEN_IMAGE: "no"
+ before_script:
+ # Ensure we are generating correct the container
+ - uname -a
+ - cat /etc/os-release
+ - echo "SAMBA_CI_CONTAINER_REGISTRY[${SAMBA_CI_CONTAINER_REGISTRY}]"
+ - echo "SAMBA_CI_CONTAINER_TAG[${SAMBA_CI_CONTAINER_TAG}]"
+ - echo "SAMBA_CI_IS_BROKEN_IMAGE[${SAMBA_CI_IS_BROKEN_IMAGE}]"
+ - echo "SAMBA_CI_REBUILD_IMAGES[${SAMBA_CI_REBUILD_IMAGES}]"
+ - echo "SAMBA_CI_REBUILD_BROKEN_IMAGES[${SAMBA_CI_REBUILD_BROKEN_IMAGES}]"
+ - echo "GITLAB_USER_LOGIN[${GITLAB_USER_LOGIN}]"
+ - echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
+ - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
+ script: |
+ set -xueo pipefail
+ ci_image_name=samba-ci-${CI_JOB_NAME}
+ docker build -t ${ci_image_name} --build-arg SHA1SUM=${SAMBA_CI_CONTAINER_TAG} bootstrap/generated-dists/${CI_JOB_NAME}
+ ci_image_path="${SAMBA_CI_CONTAINER_REGISTRY}/${ci_image_name}"
+ timestamp=$(date +%Y%m%d%H%M%S)
+ docker_hash=$(docker image inspect --format='{{index .Id}}' ${ci_image_name} | cut -d : -f 2 | cut -c 1-9)
+ timestamp_tag=${SAMBA_CI_CONTAINER_TAG}-${timestamp}-${GITLAB_USER_LOGIN}-${docker_hash}
+ samba_repo_root=/home/samba/samba
+ # Ensure we are generating the correct container that we expect to be in
+ echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
+ diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
+ docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
+ /bin/bash -c "echo \"${SAMBA_CI_CONTAINER_TAG}\" > /tmp/sha1sum-tag.txt; diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt"
+ docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
+ diff -u bootstrap/sha1sum.txt /sha1sum.txt
+ docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
+ bootstrap/template.py --sha1sum > /tmp/sha1sum-template.txt
+ diff -u bootstrap/sha1sum.txt /tmp/sha1sum-template.txt
+ # run smoke test with samba-o3
+ docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${ci_image_name} \
+ /bin/bash -c "sudo chown -R samba:samba ./** && script/autobuild.py samba-o3 --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase"
+ docker tag ${ci_image_name} ${ci_image_path}:${SAMBA_CI_CONTAINER_TAG}
+ docker tag ${ci_image_name} ${ci_image_path}:${timestamp_tag}
+ # We build all images, but only upload is it's not marked as broken
+ test x"${SAMBA_CI_IS_BROKEN_IMAGE}" = x"yes" || { \
+ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY; \
+ docker push ${ci_image_path}:${SAMBA_CI_CONTAINER_TAG}; \
+ docker push ${ci_image_path}:${timestamp_tag}; \
+ }
+ echo "Success for ${ci_image_path}:${timestamp_tag}"
+ test x"${SAMBA_CI_IS_BROKEN_IMAGE}" = x"no" || { \
+ echo "The image ${CI_JOB_NAME} is marked as broken and should have failed!"; \
+ echo "Replace .build_image_template_force_broken with .build_image_template!"; \
+ echo "Add a .samba-o3-template section at the end of the main .gitlab-ci.yml!"; \
+ /bin/false; \
+ }
+ only:
+ variables:
+ #
+ # You need a custom pipeline which passes
+ # SAMBA_CI_REBUILD_IMAGES="yes".
+ #
+ # https://gitlab.com/samba-team/devel/samba/pipelines/new
+ #
+ - $SAMBA_CI_REBUILD_IMAGES == "yes"
+
+.build_image_template_force_broken:
+ extends: .build_image_template
+ variables:
+ SAMBA_CI_IS_BROKEN_IMAGE: "yes"
+ only:
+ variables:
+ #
+ # You need a custom pipeline which passes
+ # SAMBA_CI_REBUILD_BROKEN_IMAGES="yes"
+ # in order to build broken images for debugging
+ #
+ # https://gitlab.com/samba-team/devel/samba/pipelines/new
+ #
+ - $SAMBA_CI_REBUILD_BROKEN_IMAGES == "yes"
+
+ubuntu1804:
+ extends: .build_image_template
+
+ubuntu1604:
+ extends: .build_image_template
+
+ubuntu1404:
+ extends: .build_image_template
+
+debian9:
+ extends: .build_image_template
+
+debian8:
+ extends: .build_image_template_force_broken
+
+debian7:
+ extends: .build_image_template_force_broken
+
+fedora29:
+ extends: .build_image_template_force_broken
+
+fedora28:
+ extends: .build_image_template_force_broken
+
+centos7:
+ extends: .build_image_template_force_broken
+
+centos6:
+ extends: .build_image_template_force_broken
+
+opensuse150:
+ extends: .build_image_template