Add gitlab ci script

Change-Id: I826d7b22ebe8c1185f03b6cf3c744c323b87f989
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..a40a87c
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,58 @@
+image: metacpan/metacpan-api
+
+build-and-test:
+  stage: build
+  before_script:
+    - pwd
+    - source `find .. -name section_helper.sh`
+
+    - start_section install_linux_packages "Installing missing Linux packages"
+    - apt update && apt -y install cmake libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
+    - end_section install_linux_packages
+
+    - start_section install_rocksdb_static "Building and installing rocksdb-static"
+    - curl -L https://github.com/facebook/rocksdb/archive/refs/tags/v5.11.3.tar.gz | tar zx
+    - cd rocksdb-5.11.3
+    - export PROCS=$(cat /proc/cpuinfo | grep -c processor)
+    - make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
+    - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
+    - end_section install_rocksdb_static
+
+    - start_section install_rocksdb_shared "Building and installing rocksdb-shared"
+    - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
+    - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
+    - ldconfig
+    - cd ..
+    - end_section rocksdb_shared
+
+    - start_section install_collocatordb "Building and installing collocatordb"
+    - git clone "https://korap.ids-mannheim.de/gerrit/private/collocatordb"
+    - cd collocatordb
+    - mkdir -p build
+    - cd build
+    - cmake ..
+    - make
+    - make install # && ctest --extra-verbose
+    - ldconfig
+    - end_section install_collocatordb
+    - cd ../..
+
+  script:
+    - start_section build_perl_dependencies "Installing Perl dependencies"
+    - cpanm https://github.com/Akron/Mojolicious-Plugin-Localize.git
+    - cpanm --installdeps .
+    - end_section build_perl_dependencies
+
+    - start_section  build_derekovecs-server "Building DeReKoVecs server"
+    - perl Makefile.PL
+    - make
+    - make install
+    - end_section build_derekovecs-server
+
+    - start_section run_derekovecs-server "Running DeReKoVecs server"
+    - morbo script/derekovecs-server &
+    - DVPID=$!
+    - sleep 40
+    - kill $DVPID || true
+    - end_section run_derekovecs-server
+
diff --git a/ci/section_helper.sh b/ci/section_helper.sh
new file mode 100644
index 0000000..ddefe0d
--- /dev/null
+++ b/ci/section_helper.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Reference: https://docs.gitlab.com/ee/ci/jobs/#custom-collapsible-sections
+
+#
+# Takes 2 Parameters a new section id and a heading/title
+#
+function start_section() {
+  id=$1
+  title=$2
+  echo -e "\e[0Ksection_start:$(date +%s):${id}[collapsed=true]\r\e[0K\e[36;1m${title}\e[0m"
+}
+
+#
+# Takes 1 Parameter, the unique section id of the section that should end
+#
+function end_section() {
+  id=$1
+  echo -e "\e[0Ksection_end:$(date +%s):${id}\r\e[0K"
+}