From 21f7d2ed7e22a99d07f7629cf355baee2764627b Mon Sep 17 00:00:00 2001
From: Stephan Schulz <stephan.schulz-x2q@rub.de>
Date: Wed, 27 Jan 2021 11:40:31 +0100
Subject: [PATCH] add CI scripts for example projects (VTK must be found
 somehow still)

---
 ci/ci_funcs.sh                  | 10 ++++++++++
 ci/test_project_cmake.sh        | 22 ++++++++++++++++++++++
 ci/test_project_cmake_subdir.sh | 19 +++++++++++++++++++
 ci/test_project_makefile.sh     | 22 ++++++++++++++++++++++
 4 files changed, 73 insertions(+)
 create mode 100755 ci/test_project_cmake.sh
 create mode 100755 ci/test_project_cmake_subdir.sh
 create mode 100755 ci/test_project_makefile.sh

diff --git a/ci/ci_funcs.sh b/ci/ci_funcs.sh
index 81dce18..0177645 100644
--- a/ci/ci_funcs.sh
+++ b/ci/ci_funcs.sh
@@ -35,6 +35,16 @@ function load_MPI {
     echo "load MPI libs"
 }
 
+function find_ALL {
+	ALL_ROOT_DIR="$CI_SCRIPT_PATH/.."
+}
+
+function find_VTK {
+	# todo(s.schulz): This must be adapted for docker images! Right now this
+	# is only correct on my own machine.
+	VTK_DIR="$CI_SCRIPT_PATH/../../vtk_bin"
+}
+
 # push badge to tmp-branch and exit
 function pushbadge_exit {
     local CP_FILE=$1
diff --git a/ci/test_project_cmake.sh b/ci/test_project_cmake.sh
new file mode 100755
index 0000000..3f61c20
--- /dev/null
+++ b/ci/test_project_cmake.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
+source $SCRIPT_DIR/ci_funcs.sh
+set -euxo pipefail
+
+find_ALL #sets ALL_ROOT_DIR
+find_VTK #sets VTK_DIR
+
+TEMP=$(mktemp -d)
+
+rsync -aLK ../example/CMakeProject/ "$TEMP"
+cd "$TEMP"
+sed -i\
+	-e "/^ALL_ROOT_DIR=/c\\\nALL_ROOT_DIR=\"$ALL_ROOT_DIR\"\n"\
+	-e "/^VTK_DIR=/c\\\nVTK_DIR=\"$VTK_DIR\"\n"\
+	build_all.sh
+cat build_all.sh
+./build_all.sh
+
+
+rm -rf "$TEMP"
diff --git a/ci/test_project_cmake_subdir.sh b/ci/test_project_cmake_subdir.sh
new file mode 100755
index 0000000..bdab524
--- /dev/null
+++ b/ci/test_project_cmake_subdir.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
+source $SCRIPT_DIR/ci_funcs.sh
+set -euxo pipefail
+
+find_ALL #sets ALL_ROOT_DIR
+find_VTK #sets VTK_DIR
+
+TEMP=$(mktemp -d)
+
+rsync -aLK ../example/CMakeProjectSubdir/ "$TEMP"
+cd "$TEMP"
+ln -s "$ALL_ROOT_DIR" all
+ln -s "$VTK_DIR" vtk_bin
+./build_all.sh
+
+
+rm -rf "$TEMP"
diff --git a/ci/test_project_makefile.sh b/ci/test_project_makefile.sh
new file mode 100755
index 0000000..d89ef08
--- /dev/null
+++ b/ci/test_project_makefile.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
+source $SCRIPT_DIR/ci_funcs.sh
+set -euxo pipefail
+
+find_ALL #sets ALL_ROOT_DIR
+find_VTK #sets VTK_DIR
+
+TEMP=$(mktemp -d)
+
+rsync -aLK ../example/MakefileProject/ "$TEMP"
+cd "$TEMP"
+sed -i\
+	-e "/^ALL_SOURCE=/c\\\nALL_SOURCE=\"$ALL_ROOT_DIR\"\n"\
+	-e "/^VTK_DIR=/c\\\nVTK_DIR=\"$VTK_DIR\"\n"\
+	Makefile
+cat Makefile
+make
+
+
+rm -rf "$TEMP"
-- 
GitLab