forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab.mk
140 lines (116 loc) · 4.22 KB
/
.gitlab.mk
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
GITLAB_MAKE:=${MAKE} -f .gitlab.mk
TRAVIS_MAKE:=${MAKE} -f .travis.mk
# #####
# Utils
# #####
# Update submodules.
#
# Note: There is no --force option for `git submodule` on git
# 1.7.1, which is shiped in CentOS 6.
git_submodule_update:
git submodule update --force --recursive --init 2>/dev/null || \
git submodule update --recursive --init
# Pass *_no_deps goals to .travis.mk.
test_%: git_submodule_update
${TRAVIS_MAKE} $@
# #######################################################
# Build and push testing docker images to GitLab Registry
# #######################################################
# These images contains tarantool dependencies and testing
# dependencies to run tests in them.
#
# How to run:
#
# make GITLAB_USER=foo -f .gitlab.mk docker_bootstrap
#
# The command will prompt for a password. If two-factor
# authentication is enabled an access token with 'api' scope
# should be entered here instead of a password.
#
# When to run:
#
# When some of deps_* goals in .travis.mk are updated.
#
# Keep in a mind that the resulting image is used to run tests on
# all branches, so avoid removing packages: only add them.
GITLAB_REGISTRY?=registry.gitlab.com
DOCKER_BUILD=docker build --network=host -f - .
define DEBIAN_STRETCH_DOCKERFILE
FROM packpack/packpack:debian-stretch
COPY .travis.mk .
RUN make -f .travis.mk deps_debian
endef
export DEBIAN_STRETCH_DOCKERFILE
define DEBIAN_BUSTER_DOCKERFILE
FROM packpack/packpack:debian-buster
COPY .travis.mk .
RUN make APT_EXTRA_FLAGS="--allow-releaseinfo-change-version --allow-releaseinfo-change-suite" -f .travis.mk deps_buster_clang_8
endef
export DEBIAN_BUSTER_DOCKERFILE
IMAGE_PREFIX:=${GITLAB_REGISTRY}/tarantool/tarantool/testing
DEBIAN_STRETCH_IMAGE:=${IMAGE_PREFIX}/debian-stretch
DEBIAN_BUSTER_IMAGE:=${IMAGE_PREFIX}/debian-buster
TRAVIS_CI_MD5SUM:=$(firstword $(shell md5sum .travis.mk))
docker_bootstrap:
# Login.
docker login -u ${GITLAB_USER} ${GITLAB_REGISTRY}
# Build images.
echo "$${DEBIAN_STRETCH_DOCKERFILE}" | ${DOCKER_BUILD} \
-t ${DEBIAN_STRETCH_IMAGE}:${TRAVIS_CI_MD5SUM} \
-t ${DEBIAN_STRETCH_IMAGE}:latest
echo "$${DEBIAN_BUSTER_DOCKERFILE}" | ${DOCKER_BUILD} \
-t ${DEBIAN_BUSTER_IMAGE}:${TRAVIS_CI_MD5SUM} \
-t ${DEBIAN_BUSTER_IMAGE}:latest
# Push images.
docker push ${DEBIAN_STRETCH_IMAGE}:${TRAVIS_CI_MD5SUM}
docker push ${DEBIAN_BUSTER_IMAGE}:${TRAVIS_CI_MD5SUM}
docker push ${DEBIAN_STRETCH_IMAGE}:latest
docker push ${DEBIAN_BUSTER_IMAGE}:latest
# Clone the benchmarks repository for performance testing
perf_clone_benchs_repo:
git clone https://github.com/tarantool/bench-run.git
# Build images for performance testing
perf_prepare: perf_clone_benchs_repo
make -f bench-run/targets.mk prepare
# Remove temporary performance image from the test host
perf_cleanup: perf_clone_benchs_repo
make -f bench-run/targets.mk cleanup
# #################################
# Run tests under a virtual machine
# #################################
vms_start:
VBoxManage controlvm ${VMS_NAME} poweroff || true
VBoxManage snapshot ${VMS_NAME} restore ${VMS_NAME}
VBoxManage startvm ${VMS_NAME} --type headless
vms_test_%:
tar czf - ../tarantool | ssh ${VMS_USER}@127.0.0.1 -p ${VMS_PORT} tar xzf -
ssh ${VMS_USER}@127.0.0.1 -p ${VMS_PORT} "/bin/bash -c \
'${EXTRA_ENV} \
cd tarantool && \
${GITLAB_MAKE} git_submodule_update && \
${TRAVIS_MAKE} $(subst vms_,,$@)'"
vms_shutdown:
VBoxManage controlvm ${VMS_NAME} poweroff
# ########
# Packages
# ########
GIT_DESCRIBE=$(shell git describe HEAD)
MAJOR_VERSION=$(word 1,$(subst ., ,$(GIT_DESCRIBE)))
MINOR_VERSION=$(word 2,$(subst ., ,$(GIT_DESCRIBE)))
BUCKET="$(MAJOR_VERSION).$(MINOR_VERSION)"
package: git_submodule_update
git clone https://github.com/packpack/packpack.git packpack
PACKPACK_EXTRA_DOCKER_RUN_PARAMS='--network=host' ./packpack/packpack
deploy: package
echo ${GPG_SECRET_KEY} | base64 -d | gpg --batch --import || true
./tools/update_repo.sh -o=${OS} -d=${DIST} \
-b="${LIVE_REPO_S3_DIR}/${BUCKET}" build
if git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null ; then \
./tools/update_repo.sh -o=${OS} -d=${DIST} \
-b="${RELEASE_REPO_S3_DIR}/${BUCKET}" build ; \
fi
# ###################
# Performance testing
# ###################
perf_run:
/opt/bench-run/benchs/${BENCH}/run.sh ${ARG}