forked from LINBIT/drbd-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
111 lines (102 loc) · 3.95 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
stages:
- build
- test
variables:
BUILD_HELPERS_VERSION: 6959b310000055d1e941f948aeba00b30a4e3b73
DRBD9_TESTS_REF: master
# we have to change the way GitLab CI clones the repository.
# by default, it is shallow, which gives us a wrong commit count when
# we do `git rev-list --count origin/master` below.
GIT_DEPTH: 0
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: normal
.setup-lbbuild:
before_script:
- . .gitlab/gitlab-utils.sh
- drbd_prepare_tools
- drbd_fetch_lbbuildctl
- git clone --branch ${DRBD9_TESTS_REF} https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/drbd/drbd9-tests.git
- |
drbd_utils_build () {
local version="$1"
local release="$2"
dummy-release.sh drbd-utils "$version" "$release" drbd.spec.in
sed -i "s/^AC_INIT.*/AC_INIT(DRBD, $version, [[email protected]])/" configure.ac
git config --global user.email "invalid@linbit"
git config --global user.name "Dummy"
git commit -am "CI $version - $release"
./autogen.sh
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --without-83support --without-manual
install /dev/null $(which lbvers.py)
make debrelease VERSION="$version" FORCE=1
curl -isSf -u $LINBIT_REGISTRY_USER:$LINBIT_REGISTRY_PASSWORD --upload-file drbd-utils-*.tar.gz $LINBIT_REGISTRY_URL/repository/lbbuild-upstream/
# distributions, with rhelX.y replaced by rhelX.0, comma separated
local dists=$(rq -t < drbd9-tests/virter/vms.toml | jq -r '[
.vms[].metadata.BuildDistribution
| sub("rhel(?<major>\\d)\\.\\d"; "rhel\(.major).0")
] | unique | join(",")')
lbbuildctl build drbd-utils --arch amd64 --ci -v "$DRBD_UTILS_VERSION" -l \
-e LINBIT_REGISTRY_USER=$LINBIT_REGISTRY_USER \
-e LINBIT_REGISTRY_PASSWORD=$LINBIT_REGISTRY_PASSWORD \
-e LINBIT_REGISTRY_URL=$LINBIT_REGISTRY_URL \
-d $dists
}
# rules clause determining whether to build
.rules-build:
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
build:
stage: build
extends: [ .rules-build, .setup-lbbuild ]
image: $LINBIT_DOCKER_REGISTRY/build-helpers:$BUILD_HELPERS_VERSION
cache:
paths:
- download
script:
- if [ "$CI_COMMIT_BRANCH" = master ]; then
- DRBD_UTILS_VERSION=9.0.0.latest
- DRBD_UTILS_RELEASE=$(git rev-list --count origin/master)
- else
- DRBD_UTILS_VERSION=9.0.0.$CI_COMMIT_SHA
- DRBD_UTILS_RELEASE=1
- fi
- drbd_utils_build $DRBD_UTILS_VERSION $DRBD_UTILS_RELEASE
drbd-tests:
stage: test
rules:
- if: $CI_MERGE_REQUEST_ID
tags:
- libvirt
cache:
paths:
- download
before_script:
- git clone --branch ${DRBD9_TESTS_REF} https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/drbd/drbd9-tests.git
script:
- . drbd9-tests/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 $LINBIT_DOCKER_REGISTRY/drbd9-tests:latest
- |
export DRBD_VERSION=9.1.0.latest
export DRBD_UTILS_VERSION=9.0.0.$CI_COMMIT_SHA-1
export DRBD9_TESTS_VERSION=latest
cd drbd9-tests
./virter/run-test.sh --out-dir=../tests-out
dependencies:
- build
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
reports:
junit: tests-out/test-results/*.xml