From 3ab4f95bbcacb0f3de882c27cd77034af02aeef0 Mon Sep 17 00:00:00 2001
From: Alexander Diewald <diewald@fortiss.org>
Date: Sun, 26 Jan 2020 14:19:13 +0100
Subject: [PATCH] CI: Fixup the test stage

* Use a custom docker image that has the required libraries installed.
  It is based on the official maven image.
* Fixup caching (define the key).
* Start Xvfb before launching the tests. Required to get a fake display
  that allows starting up the eclipse application.

Signed-off-by: Alexander Diewald <diewald@fortiss.org>
---
 .gitlab-ci.yml | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b259cc5..9dd28be 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: maven:latest
+image: maven_eclipse:latest
 
 stages:
   - build
@@ -8,38 +8,39 @@ variables:
   # recursive should work here, but gitlab-runner does not pull the latest remote
   # for submodules: https://gitlab.com/gitlab-org/gitlab-runner/issues/3011
   GIT_SUBMODULE_STRATEGY: none
+  GIT_SUBMODULE_OPTS: "--remote --recursive --init --recommend-shallow"
   MAVEN_CLI_OPTS: "--batch-mode"
   MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
   MAVEN_BUILD_OPTS: "-Dbuild.tooling=true -Dbuild.af3=true -Dbuild.emf=true"
   MAVEN_TEST_OPTS: "-Dbuild.tests=true"
+  MAVEN_BUILD_DIR: "-Duser.dir=/builds/$CI_PROJECT_PATH"
 
 
-before_script:
-
 cache:
+  key: Default
   paths:
     - .m2/repository/
-    - target/
 
 build:
   stage: build
+  cache:
+    key: Default
   before_script:
-    - git submodule update --remote --recursive --init
+    - git submodule update $GIT_SUBMODULE_OPTS
   script:
     - mvn $MAVEN_CLI_OPTS $MAVEN_BUILD_OPTS verify
   artifacts:
     paths:
       - releng/org.fortiss.af3.update/target/repository/
       - releng/org.fortiss.tooling.update/target/repository/
+      - products/af3/org.fortiss.af3.phoenix.product/target/extraArtifacts/
 
 test:
   stage: test
+  cache:
+    key: Default
   before_script:
-    - git submodule update --remote --recursive --init
-    #- git submodule update --remote --recursive --init releng/org.fortiss.af3.target
-    #- git submodule update --remote --recursive --init tests/af3
+    - git submodule update $GIT_SUBMODULE_OPTS
+    - xvfb.sh # Setup of a virtual display needed for bringing up eclipse
   script:
-    - mvn $MAVEN_CLI_OPTS $MAVEN_TEST_OPTS -Duser.dir=/builds/$CI_PROJECT_PATH integration-test
-  artifacts:
-    paths:
-      - tests/af3/org.fortiss.af3.phoenix.product.tests/target/work/data/.metadata/.log
+    - mvn $MAVEN_CLI_OPTS $MAVEN_TEST_OPTS $MAVEN_BUILD_DIR integration-test
-- 
GitLab