From 06f20da227115fd73f990739d8127ad5c3e70240 Mon Sep 17 00:00:00 2001
From: Henrik tom Woerden <henrik.tom-woerden@ds.mpg.de>
Date: Fri, 19 Jul 2019 10:36:00 +0200
Subject: [PATCH] F ci

---
 .gitlab-ci.yml         | 74 ++++++++++++++++++++++++++++++------------
 makefile               |  4 +--
 test/docker/Dockerfile |  7 ++++
 3 files changed, 62 insertions(+), 23 deletions(-)
 create mode 100644 test/docker/Dockerfile

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index be6348ff..c751db1d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,6 +21,32 @@
 # ** end header
 #
 
+variables:
+   CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb-webui-testenv
+   # When using dind service we need to instruct docker, to talk with the
+   # daemon started inside of the service. The daemon is available with
+   # a network connection instead of the default /var/run/docker.sock socket.
+   #
+   # The 'docker' hostname is the alias of the service container as described at
+   # https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services
+   #
+   # Note that if you're using the Kubernetes executor, the variable should be set to
+   # tcp://localhost:2375/ because of how the Kubernetes executor connects services
+   # to the job container
+   # DOCKER_HOST: tcp://localhost:2375/
+   #
+   # For non-Kubernetes executors, we use tcp://docker:2375/
+   DOCKER_HOST: tcp://docker:2375/
+   # When using dind, it's wise to use the overlayfs driver for
+   # improved performance.
+   DOCKER_DRIVER: overlay2
+
+services:
+   - docker:dind
+
+image: $CI_REGISTRY_IMAGE:latest
+
+
 stages:
     - setup
     - linting
@@ -31,24 +57,7 @@ stages:
 # setup
 #######
 
-# install pylint
-setup:install-pylint:
-    stage: setup
-    tags: [ py36 ]
-    script:
-        - pip3 install pylint --user
-
-#########
-# linting
-#########
-
-# pylint everything
-linting:pylint:python3:
-    stage: linting
-    tags: [ py36 ]
-    script:
-        - make pylint
-
+###  TODO !!! use respective docker image
 ######
 # test
 ######
@@ -56,18 +65,41 @@ linting:pylint:python3:
 # run qunit tests
 test:qunit:
     stage: test
-    tags: [ py36 ]
+    #tags: [ py36 ]
     artifacts:
         paths:
             - public/qunit.log
             - screenlog.*
     script:
-        - make run-qunit
+        - make pylint
+# TODO fix the following
+#        - make run-qunit
           
 trigger_build:
   stage: deploy
   script:
+    - echo $TOKEN     
     - /usr/bin/curl -X POST
        -F token=$TOKEN
-       -F "variables[PYLIB]=$CI_COMMIT_REF_NAME"
+       -F "variables[WEBUI]=$CI_COMMIT_REF_NAME"
        -F ref=master https://gitlab.indiscale.com/api/v4/projects/14/trigger/pipeline
+
+build-testenv:
+    image: docker:latest
+    stage: setup
+    script: 
+        - echo $TRIGGERED_BY
+        - echo $MYSQLBACKEND
+        - ping -4 -c 3 registry.indiscale.com
+        - echo $PYLIB
+        - cd test/docker
+        - echo $CI_REGISTRY_PASSWORD 
+        - echo $CI_REGISTRY
+        - docker login -u testuser -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+          # use here general latest or specific branch latest...
+        - docker pull $CI_REGISTRY_IMAGE:latest || true
+        - docker build 
+          --pull
+          --cache-from $CI_REGISTRY_IMAGE:latest 
+          -t $CI_REGISTRY_IMAGE:latest .
+        - docker push $CI_REGISTRY_IMAGE:latest
diff --git a/makefile b/makefile
index 0ac93add..0aaadadb 100644
--- a/makefile
+++ b/makefile
@@ -173,11 +173,11 @@ unzip:
 	for f in $(LIBS_ZIP); do unzip -o -d libs $$f; done
 
 
-PYLINT = pylint -d all -e E,F
+PYLINT = pylint3 -d all -e E,F
 PYTHON_FILES = $(subst $(ROOT_DIR)/,,$(shell find $(ROOT_DIR)/ -iname "*.py"))
 pylint: $(PYTHON_FILES)
 	for f in $(PYTHON_FILES); do $(PYLINT) $$f || exit 1; done
 
-PYLINT_LOCAL = /usr/bin/pylint -d all -e E,F
+PYLINT_LOCAL = /usr/bin/pylint3 -d all -e E,F
 pylint-local: $(PYTHON_FILES)
 	for f in $(PYTHON_FILES); do $(PYLINT_LOCAL) $$f || exit 1; done
diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile
new file mode 100644
index 00000000..3d053e62
--- /dev/null
+++ b/test/docker/Dockerfile
@@ -0,0 +1,7 @@
+FROM debian:latest
+RUN apt-get update && \
+	apt-get install firefox-esr pylint3 python3-pip python3-httpbin git \
+	curl -y
+RUN git clone -b dev https://gitlab.gwdg.de/bmp-caosdb/caosdb-pylib.git && \
+    cd caosdb-pylib && pip3 install .
+
-- 
GitLab