Add CI script
Change-Id: I7b448e603e90971ac5850d7388354798e8548834
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..19641c6
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,40 @@
+# use the verse rocker image, as it contains tidyverse, devtools and some texlive
+image: rocker/tidyverse
+
+# define stages of runner. at the moment,
+# just build (no test or deploy).
+stages:
+ - build
+
+build-job:
+ stage: build
+
+ cache:
+ key: revealjs
+ paths:
+ - ./cache
+
+ artifacts:
+ paths:
+ - "target/*"
+
+ before_script:
+ - source `find .. -name section_helper.sh`
+
+ - start_section install_linux_packages "Installing missing Linux packages"
+ - apt-get update
+ - apt-get install -y libu2f-udev fonts-liberation build-essential libglpk40 libcurl4-gnutls-dev libxml2-dev libsodium-dev libsecret-1-dev libfontconfig1-dev libssl-dev libxt6 libpq-dev imagemagick
+ - locale-gen de_DE.utf8 en_GB.utf8 en_US.utf8
+
+ - end_section install_linux_packages
+
+ - start_section install_r_packages "Installing missing R packages"
+ - R -e "install.packages(c('devtools', 'RKorAPClient', 'httr', 'tidytext', 'httpuv', 'scales', 'sp', 'raster', 'kableExtra', 'DT', 'svglite', 'qrcode', 'rsvg'))"
+ - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR")'
+ - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/revealjs")'
+ - end_section install_r_packages
+
+ script:
+ - start_section render "Running scripts"
+ - R_CACHE_ROOTPATH=./cache R -e "require(rmarkdown); render('examples/ids.Rmd', output_format='revealjs::revealjs_presentation', output_dir='target')"
+ - end_section render
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"
+}