From d4ad83539882db1ca95631652fffd226f053097d Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 23 Jul 2021 12:35:06 +0200
Subject: [PATCH] add trigger for inttest pipeline

---
 .docker/Dockerfile |  8 +++++---
 .gitlab-ci.yml     | 44 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index 6eea39d..27f2d5a 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -25,8 +25,10 @@ RUN unzip MOxUnit-master.zip
 WORKDIR /MOxUnit-master/
 RUN make install
 
-COPY doc/requirements.txt doc-requirements.txt
-RUN pip3 install -r doc-requirements.txt
 
-COPY dev-requirements.txt dev-requirements.txt
+COPY . /caosdb-octavelib
+WORKDIR /caosdb-octavelib
+RUN rm -rf .git
+
+RUN pip3 install -r doc/requirements.txt
 RUN pip3 install -r dev-requirements.txt
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9c4f15b..5166407 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,6 +26,8 @@ variables:
   OCTAVE_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE/testenv:$CI_COMMIT_REF_NAME
   CPPLIB_BRANCH: dev
 
+  OCTAVEINTTEST_PIPELINE: https://gitlab.indiscale.com/api/v4/projects/121/trigger/pipeline
+
 
 image: $OCTAVE_REGISTRY_IMAGE
 
@@ -70,14 +72,20 @@ code_style_cpp:
     - clang-format-11 --dry-run --verbose --Werror $(find test/ src/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in")
   allow_failure: true
 
-# Unit tests
-test:
+unit_tests:
   tags: [ docker ]
   stage: test
   script:
     - octave -v
     - make test
 
+package_tests:
+  tags: [ docker ]
+  stage: test
+  script:
+    - octave -v
+    - make pkg-test
+
 # Linting with miss_hit
 linting_octave:
   tags: [ docker ]
@@ -96,6 +104,38 @@ linting_cpp:
     - cmake -D LINTING=On ..
     - cmake --build .
 
+# trigger the integration tests
+trigger_inttest:
+  tags: [ docker ]
+  stage: deploy
+  script:
+
+    ## Determine the octaveinttest branch...
+    # ... use an f-branch if posible...
+    - if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then
+        OCTAVEINT_REF=$CI_COMMIT_REF_NAME ;
+      fi;
+    # ... or use main if possible...
+    - if [[ "$CI_COMMIT_REF_NAME" == "main" ]] ; then
+        OCTAVEINT_REF=main ;
+      fi
+    # ... and fall-back to dev
+    - OCTAVEINT_REF=${OCTAVEINT_REF:-dev}
+    - F_BRANCH=$CI_COMMIT_REF_NAME
+
+    - echo "Triggering caosdb-octaveinttest@${OCTAVEINT_REF} (F_BRANCH=$F_BRANCH)"
+    - curl -w "%{stderr}HTTPCODE=%{http_code}" -X POST
+      -F token=$CI_JOB_TOKEN
+      -F "variables[TRIGGERED_BY_REPO]=$TRIGGERED_BY_REPO"
+      -F "variables[TRIGGERED_BY_REF]=$TRIGGERED_BY_REF"
+      -F "variables[TRIGGERED_BY_HASH]=$TRIGGERED_BY_HASH"
+      -F "variables[OCTAVELIB_REGISTRY_IMAGE]=$OCTAVELIB_REGISTRY_IMAGE"
+      -F "variables[F_BRANCH]=${F_BRANCH}"
+      -F ref=${OCTAVEINT_REF} $OCTAVEINTTEST_PIPELINE 2>HTTPCODE
+
+    # fail if the request failed
+    - grep -c "HTTPCODE=2" HTTPCODE
+
 # Build the sphinx documentation and make it ready for deployment by Gitlab Pages
 # Special job for serving a static website. See https://docs.gitlab.com/ee/ci/yaml/README.html#pages
 .pages_prepare: &pages_prepare
-- 
GitLab