[Tarantool-patches] [PATCH docker v1 1/4] Add into Gitlab-CI testing

Alexander V. Tikhonov avtikhon at tarantool.org
Tue Jan 14 15:14:14 MSK 2020


Refactored the Gitlab-CI testing script. Made
available images rebuild only for the changed
appropriate directories/files. Reused the
previously set images repository:
  registry.gitlab.com/tarantool/docker
---
 .gitlab-ci.yml | 60 ++++++++++++++++++++++++++++++--------------------
 .gitlab.mk     |  7 ++++++
 2 files changed, 43 insertions(+), 24 deletions(-)
 create mode 100644 .gitlab.mk

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e815c21..508e250 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,35 +1,47 @@
 stages:
- - build
- - release
+  - build
 
 variables:
   REGISTRY: registry.gitlab.com
   IMAGE: ${REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
 
 before_script:
- # Enable GitLab registry
- - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${REGISTRY}
+  # Enable GitLab registry
+  - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${REGISTRY}
 
-#
-# Build Docker image and publish as IMAGE:BRANCH
-#
-docker-build:
+.build_template: &build_definition
   stage: build
-  variables:
-    TAG: 1.7-centos7
   script:
-   - docker build -t ${IMAGE}:${TAG}-${CI_COMMIT_REF_SLUG} ${TAG}/
-   - docker push ${IMAGE}:${TAG}-${CI_COMMIT_REF_SLUG}
-
-#
-# Tag IMAGE:BRANCH as image:latest for release branches (master)
-#
-docker-tag:
-  stage: release
+    - >
+      if git diff origin/master --name-only | grep "^${DIR}/" ; then
+        make -f .gitlab.mk build
+      fi;
+
+'1.x':
+  <<: *build_definition
   variables:
-    TAG: 1.7-centos7
-  script:
-   - docker tag ${IMAGE}:${TAG}-${CI_COMMIT_REF_SLUG} ${IMAGE}:${TAG}
-   - docker push ${IMAGE}:${TAG}
-  only:
-   - master
+    TAG: '1'
+    DIR: '1.x'
+    PORT: 3301
+
+'2.x':
+  <<: *build_definition
+  variables:
+    TAG: '2'
+    DIR: '2.x'
+    PORT: 3302
+
+'2.1':
+  <<: *build_definition
+  variables:
+    TAG: '2.1'
+    DIR: '2.1'
+    PORT: 3321
+
+'2.2':
+  <<: *build_definition
+  variables:
+    TAG: '2.2'
+    DIR: '2.2'
+    PORT: 3322
+
diff --git a/.gitlab.mk b/.gitlab.mk
new file mode 100644
index 0000000..5589177
--- /dev/null
+++ b/.gitlab.mk
@@ -0,0 +1,7 @@
+build:
+	docker build --network=host -t ${IMAGE}:${TAG} ${DIR}/
+	docker run --rm --name tarantool_${TAG} -p ${PORT}:${PORT} -d ${IMAGE}:${TAG}
+	docker exec -t tarantool_${TAG} tarantool_is_up
+	docker stop tarantool_${TAG}
+	docker push ${IMAGE}:${TAG}
+
-- 
2.17.1



More information about the Tarantool-patches mailing list