-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
201 lines (187 loc) · 6.17 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
image: $LINBIT_DOCKER_REGISTRY/build-helpers:$BUILD_HELPERS_VERSION
variables:
BUILD_HELPERS_VERSION: 164e0fc5dceacb32184e3a6037758bb9472372be
DRBD_TEST_DOCKER_IMAGE: $LINBIT_DOCKER_REGISTRY/drbd9-tests:latest
DRBD_TEST_COUNT: 1
VMSHED_ARGS: ""
DRBD_TEST_SERIES: "none" # To distinguish regular stability tests from other scheduled tests.
DRBD_TESTS_DIR: "tests"
DRBD_VERSION: 9.1.0.latest
DRBD_VERSION_OTHER: "" # For compatibility testing. For example: 8.4.12
DRBD_UTILS_VERSION: 9.0.0.latest-*
stages:
- base_image
- build
- test
- publish
.cache-download:
cache:
key:
prefix: download
files:
- virter/version.env
paths:
- download
prepare:base_image:
extends: .cache-download
stage: base_image
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
- if: $CI_COMMIT_BRANCH == 'master'
when: manual
needs: []
tags:
- libvirt
# avoid blocking the pipeline with a manual job
allow_failure: true
script:
- ln -snf $DOCKER_AUTH_CONFIG_FILE $HOME/.docker/config.json
- . virter/version.env
- curl -sSfL -u gitlab-ci-token:$CI_JOB_TOKEN $CI_SERVER_URL/linbit/build-helpers/-/archive/$BUILD_HELPERS_VERSION/ignored.tar.gz | tar -xvzf -
- mv build-helpers-* build-helpers
- . build-helpers/gitlab-utils.sh
- |
ci_prepare_tools
ci_fetch_rq
ci_fetch_binary virter virter-$VIRTER_VERSION https://github.com/LINBIT/virter/releases/download/$VIRTER_VERSION/virter-linux-amd64
- |
pushd virter
virter registry update
make pull_source_images
mkdir -p base-image-build-log
build_rc=0
make -s print_base_images | \
parallel --line-buffer --tag --joblog parallel.log \
./build-push-base-image.sh '{%}' '{}' \
|| build_rc=$?
popd
./build-helpers/parse_joblog.py build-push-base-image virter/parallel.log
if [ "$build_rc" -ne 0 ]; then
exit $build_rc
fi
artifacts:
paths:
- virter/base-image-build-log
when: always
expire_in: 1 week
build:rebuild_drbd:
stage: base_image
image: registry.gitlab.com/finestructure/pipeline-trigger
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
- if: $CI_COMMIT_BRANCH == 'master'
when: manual
needs: []
# avoid blocking the pipeline with a manual job
allow_failure: true
script:
- apk add parallel
- |
parallel --will-cite --line-buffer --tag \
trigger -h https://gitlab.at.linbit.com -a $LINBOT_API_TOKEN -p $CI_JOB_TOKEN -t {} -e DRBD9_TESTS_REF=$CI_COMMIT_REF_NAME drbd/drbd \
::: drbd-9.1 master
build:drbd:
stage: build
image: registry.gitlab.com/finestructure/pipeline-trigger
rules:
- if: $DRBD_REF
needs: []
script:
# Work around misplaced module in image
- cp /usr/local/lib/python3*/site-packages/trigger.py "$(python3 -c 'import site; print(site.getsitepackages()[0])')"
# Run our wrapper for 'trigger'
- >
.gitlab/trigger_for_artifact.py -h https://gitlab.at.linbit.com
-a $LINBOT_API_TOKEN -p $CI_JOB_TOKEN
-t $DRBD_REF
-e DRBD_BUILD_CONDITIONAL=true
-e DRBD9_TESTS_REF=$CI_COMMIT_REF_NAME
drbd/drbd
artifacts:
reports:
dotenv: downstream.env
build:docker:
stage: build
tags:
- shell
rules:
# Build "latest" image only on push to master
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == 'push'
variables:
NOCACHE: "true"
# Build image for this commit in any relevant pipeline on a branch which makes changes to the docker sources
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && ($CI_MERGE_REQUEST_ID || $CI_PIPELINE_SOURCE == 'api' || $CI_PIPELINE_SOURCE == 'schedule')
changes:
paths:
- docker/**/*
# $CI_DEFAULT_BRANCH does not work here: https://gitlab.com/gitlab-org/gitlab/-/issues/369916
compare_to: master
variables:
DRBD_TEST_DOCKER_IMAGE: $LINBIT_DOCKER_REGISTRY/drbd9-tests:$CI_COMMIT_SHA
NOCACHE: "false"
needs: []
script:
- ln -snf $DOCKER_AUTH_CONFIG_FILE $HOME/.docker/config.json
- make NOCACHE=$NOCACHE DOCKER_IMAGE_NAME=$DRBD_TEST_DOCKER_IMAGE docker
- docker push $DRBD_TEST_DOCKER_IMAGE
- echo "DRBD_TEST_DOCKER_IMAGE=$DRBD_TEST_DOCKER_IMAGE" >> build.env
artifacts:
reports:
dotenv: build.env
.test:
tags:
- libvirt
before_script:
- |
set -e
run_test() {
. virter/version.env
curl -sSfL -u gitlab-ci-token:$CI_JOB_TOKEN $CI_SERVER_URL/linbit/build-helpers/-/archive/$BUILD_HELPERS_VERSION/ignored.tar.gz | tar -xvzf -
mv build-helpers-* build-helpers
. build-helpers/gitlab-utils.sh
ci_prepare_tools
ci_fetch_rq
ci_fetch_binary virter virter-$VIRTER_VERSION https://github.com/LINBIT/virter/releases/download/$VIRTER_VERSION/virter-linux-amd64
ci_fetch_binary vmshed vmshed-$VMSHED_VERSION https://github.com/LINBIT/vmshed/releases/download/$VMSHED_VERSION/vmshed-linux-amd64
docker image pull $DRBD_TEST_DOCKER_IMAGE
export DRBD9_TESTS_VERSION=$CI_COMMIT_SHA
./virter/run-test.sh "$@"
}
needs:
- job: build:docker
# Use the overridden value of $DRBD_TEST_DOCKER_IMAGE if an image was built,
# keep the default value otherwise.
optional: true
- job: build:drbd
optional: true
artifacts:
# provide a convenient name so that the downloaded artifacts can be identified
name: $CI_PROJECT_NAME-$CI_JOB_ID
paths:
- tests-out/
when: always
expire_in: 1 week
test:merge_request:
stage: test
extends: [ .cache-download, .test ]
rules:
- if: $CI_MERGE_REQUEST_ID
script: run_test
artifacts:
reports:
junit: tests-out/test-results/*.xml
test:generic:
stage: test
extends: [ .cache-download, .test ]
rules:
- if: $CI_PIPELINE_SOURCE == 'schedule'
- if: $CI_PIPELINE_SOURCE == 'api'
timeout: 12h
variables:
VMSHED_TEST_SELECTION: all
script:
- export DRBD9_TESTS_REF=$CI_COMMIT_REF_NAME
- run_test --repeats="$DRBD_TEST_COUNT" --error-details=false $VMSHED_ARGS || true
- ./virter/elasticsearch/elasticsearch-insert.sh https://es01.at.linbit.com tests-out/results.json