debug bootstrap/.gitlab-ci.yml sha1
[slow/samba.git] / bootstrap / .gitlab-ci.yml
1 services:
2   - docker:dind
3
4 .job_template:
5   image: docker:latest
6   stage: images
7   tags:
8     - docker
9     - shared
10   before_script:
11     # Ensure we are generating correct the container
12     - uname -a
13     - cat /etc/os-release
14     - echo "SAMBA_CI_CONTAINER_REGISTRY_HOST[${SAMBA_CI_CONTAINER_REGISTRY_HOST}]"
15     - echo "SAMBA_CI_CONTAINER_REGISTRY_PATH[${SAMBA_CI_CONTAINER_REGISTRY_PATH}]"
16     - echo "SAMBA_CI_CONTAINER_IMAGE_DIST[${SAMBA_CI_CONTAINER_IMAGE_DIST}]"
17     - echo "SAMBA_CI_CONTAINER_TAG[${SAMBA_CI_CONTAINER_TAG}]"
18     - echo "SAMBA_CI_CONTAINER_IMAGE[${SAMBA_CI_CONTAINER_IMAGE}]"
19     - echo "CI_REGISTRY_IMAGE[${CI_REGISTRY_IMAGE}]"
20     - echo "CI_REGISTRY_USER[${CI_REGISTRY_USER}]"
21     - echo "CI_REGISTRY[${CI_REGISTRY}]"
22     - echo "GIT_STRATEGY[${GIT_STRATEGY}]"
23     - echo "GIT_DEPTH[${GIT_DEPTH}]"
24     - echo "${SAMBA_CI_CONTAINER_TAG}" > /tmp/sha1sum-tag.txt
25     - diff -u bootstrap/sha1sum.txt /tmp/sha1sum-tag.txt
26   script: |
27     set -xueo pipefail
28     base_name=samba-ci-${CI_JOB_NAME}
29     sha1sum=$(cat bootstrap/sha1sum.txt)
30     docker build -t ${base_name} --build-arg SHA1SUM=${sha1sum} bootstrap/dists/${CI_JOB_NAME}
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} ${base_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} ${base_name} \
38         diff -u bootstrap/sha1sum.txt /sha1sum.txt
39     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
40         bootstrap/template.py --sha1sum --debug
41     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
42         /bin/bash -c "pwd;git clean -xdn ; git status; git log -1 ; git clean -xdf; git reset --hard HEAD; git status"
43     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
44         bootstrap/template.py --sha1sum --debug
45     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
46         bootstrap/template.py --sha1sum > /tmp/sha1sum-template.txt
47     diff -u bootstrap/sha1sum.txt /tmp/sha1sum-template.txt
48     # run smoke test with samba-o3
49     samba_repo_root=/home/samba/samba
50     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
51         /bin/bash -c "sudo chown -R samba:samba ./** && script/autobuild.py samba-o3 --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase"
52     docker run --volume $(pwd):${samba_repo_root} --workdir ${samba_repo_root} ${base_name} \
53         /bin/bash -c "pwd;git clean -xdn ; git status; git log -1 ; git clean -xdf; git reset --hard HEAD; git status";
54     full_name=${CI_REGISTRY_IMAGE}/${base_name}
55     timestamp=$(date +%Y%m%d%H%M%S)
56     hash=$(docker image inspect --format='{{index .Id}}' ${base_name} | cut -d : -f 2 | cut -c 1-9)
57     tag=${sha1sum}-${timestamp}-${hash}
58     docker tag ${base_name} ${full_name}:${tag}
59     docker tag ${base_name} ${full_name}:${sha1sum}
60     docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
61     docker push ${full_name}:${tag}
62     docker push ${full_name}:${sha1sum}
63     #  except:
64     #    variables:
65     #      #
66     #      # You need a custom pipeline which passes
67     #      # SAMBA_CI_REBUILD_IMAGE="yes".
68     #      #
69     #      # https://gitlab.com/samba-team/devel/samba/pipelines/new
70     #      #
71     #      #- $SAMBA_CI_REBUILD_IMAGE == null
72     #      - $SAMBA_CI_REBUILD_IMAGE == ""
73     #      - $SAMBA_CI_REBUILD_IMAGE == "0"
74     #      - $SAMBA_CI_REBUILD_IMAGE == "no"
75     #  only:
76     #    variables:
77     #      #
78     #      # In addition to SAMBA_CI_REBUILD_IMAGE="yes",
79     #      # we only build the SAMBA_CI_CONTAINER_IMAGE_DIST
80     #      # image (see ../.gitlab-ci.yml)
81     #      #
82     #      # The 2nd "variables:" blocks forms an AND logic.
83     #      #
84     #      # When you pass SAMBA_CI_REBUILD_ALL_IMAGES="yes"
85     #      # all images are rebuild.
86     #      #
87     #      # Only one of the two conditions below needs to be true
88     #      # (They form an OR logic)
89     #      #
90     #      - $SAMBA_CI_REBUILD_ALL_IMAGES == "yes"
91     #      - $SAMBA_CI_CONTAINER_IMAGE_DIST == $CI_JOB_NAME
92
93
94 # current ci image is based on ubuntu1404
95 # we'll move to new ubuntu1404 image first
96 # then migrate to new ubuntu1804 next
97 # and make the other images pass ci later
98
99 ubuntu1804:
100   extends: .job_template
101
102 ubuntu1604:
103   extends: .job_template
104
105 ubuntu1404:
106   extends: .job_template
107
108 debian9:
109   extends: .job_template
110
111 debian8:
112   extends: .job_template
113
114 debian7:
115   extends: .job_template
116
117 fedora29:
118   extends: .job_template
119
120 fedora28:
121   extends: .job_template
122
123 centos7:
124   extends: .job_template
125
126 centos6:
127   extends: .job_template