From aa089f4cd95b825f6ceaeebf5cdadc0d63d87781 Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdhiser@gmail.com>
Date: Wed, 14 Nov 2018 18:23:27 +0000
Subject: [PATCH] nightly pipelines

Former-commit-id: 55984a0ef682ea66d19280cb97d002240817492d
---
 .gitlab-ci.yml          | 149 ++++++++++++++++++++++++++++++++++++++++
 cicd_tests/.gitignore   |   1 +
 cicd_tests/do-build.sh  |  40 +++++++++++
 cicd_tests/do-clean.sh  |  22 ++++++
 cicd_tests/xform-cat.sh |  12 ++++
 cicd_tests/xform-ls.sh  |  14 ++++
 6 files changed, 238 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 cicd_tests/.gitignore
 create mode 100755 cicd_tests/do-build.sh
 create mode 100755 cicd_tests/do-clean.sh
 create mode 100755 cicd_tests/xform-cat.sh
 create mode 100755 cicd_tests/xform-ls.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 000000000..3390e960a
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,149 @@
+before_script:
+  - "source ~gitlab-runner/cicd_support/cicd_support.shinc" 
+
+
+after_script:
+  - "echo Test Complete."
+
+stages:
+  - clean
+  - build
+  - test
+
+
+
+#
+# Cleaning
+#
+
+#template 
+.do-clean: &do-nightly-clean
+  stage: clean
+  script:
+    - ./cicd_tests/do-clean.sh
+
+# per os items
+do-nightly-clean-ubuntu18:
+  <<: *do-nightly-clean
+  tags:
+    - ubuntu18
+  variables:
+    OS: 'ubuntu18'  
+
+# per os items
+do-nightly-clean-ubuntu16:
+  <<: *do-nightly-clean
+  tags:
+    - ubuntu16
+  variables:
+    OS: 'ubuntu16'  
+
+# per os items
+do-nightly-clean-centos75:
+  <<: *do-nightly-clean
+  tags:
+    - centos75
+  variables:
+    OS: 'centos75'  
+
+
+#
+# building 
+#
+
+
+# template
+.do-build: &do-build
+  stage: build
+  script:
+    - ./cicd_tests/do-build.sh
+
+
+# per os items
+do-build-ubuntu18:
+  <<: *do-build
+  tags:
+    - ubuntu18
+  variables:
+    OS: 'ubuntu18'  
+
+
+do-build-ubuntu16:
+  <<: *do-build
+  tags:
+    - ubuntu16
+  variables:
+    OS: 'ubuntu16'  
+
+
+do-build-centos75:
+  <<: *do-build
+  tags:
+    - centos75
+  variables:
+    OS: 'centos75'  
+
+
+#
+# $PSZ ls
+#
+
+# template
+.xform-ls: &xform-ls
+  stage: test
+  script:
+    - ./cicd_tests/xform-ls.sh
+
+#per OS
+xform-ls-ubuntu18:
+  <<: *xform-ls
+  tags:
+    - ubuntu18
+  variables:
+    OS: 'ubuntu18'  
+
+xform-ls-ubuntu16:
+  <<: *xform-ls
+  tags:
+    - ubuntu16
+  variables:
+    OS: 'ubuntu16'  
+
+xform-ls-centos75:
+  <<: *xform-ls
+  tags:
+    - centos75
+  variables:
+    OS: 'centos75'  
+
+#
+# $PSZ cat
+#
+
+# template
+.xform-cat: &xform-cat
+  stage: test
+  script:
+    - ./cicd_tests/xform-cat.sh
+
+xform-cat-ubuntu18:
+  <<: *xform-cat
+  tags:
+    - ubuntu18
+  variables:
+    OS: 'ubuntu18'  
+    
+xform-cat-ubuntu16:
+  <<: *xform-cat
+  tags:
+    - ubuntu16
+  variables:
+    OS: 'ubuntu16'  
+
+xform-cat-centos75:
+  <<: *xform-cat
+  tags:
+    - centos75
+  variables:
+    OS: 'centos75'  
+
diff --git a/cicd_tests/.gitignore b/cicd_tests/.gitignore
new file mode 100644
index 000000000..53a7cf9fa
--- /dev/null
+++ b/cicd_tests/.gitignore
@@ -0,0 +1 @@
+mylib.so
diff --git a/cicd_tests/do-build.sh b/cicd_tests/do-build.sh
new file mode 100755
index 000000000..bd0c72336
--- /dev/null
+++ b/cicd_tests/do-build.sh
@@ -0,0 +1,40 @@
+#/bin/bash 
+
+set -e
+set -x
+
+main()
+{
+
+	# gather info for debugging later, probably not necessary 
+	pwd
+	hostname
+	whoami
+	env|grep "^CICD"
+
+	git submodule sync 
+	git submodule update --init --recursive
+
+	local orig_dir=$(pwd)
+
+	# puts peasoup_umbrella (and all submodules) in CICD_MODULE_WORK_DIR
+	cicd_setup_module_dependency allnp/peasoup_umbrella.git
+
+
+	# puts the version of irdb_transforms to test in peasoup_umbrella/irdb_transfroms
+	cicd_put_module_in_tree peasoup_umbrella/irdb_transforms
+
+	# Build/run $PSZ, test result
+	cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+	source set_env_vars
+	sudo ./get-peasoup-packages.sh all
+
+	# remove pedi files so that rebuilding includes re-doing pedi setup.
+	$PEDI_HOME/pedi -c -m manifest.txt || true # ignore errors in cleanup
+	./build-all.sh
+	dropdb $PGDATABASE 2>/dev/null || true ; ./postgres_setup.sh
+
+	cd $orig_dir
+}
+
+main "$@"
diff --git a/cicd_tests/do-clean.sh b/cicd_tests/do-clean.sh
new file mode 100755
index 000000000..95dc3b04b
--- /dev/null
+++ b/cicd_tests/do-clean.sh
@@ -0,0 +1,22 @@
+#/bin/bash 
+
+set -e
+set -x
+
+main()
+{
+
+	# gather info for debugging later, probably not necessary 
+	pwd
+	hostname
+	whoami
+	env|grep "^CICD"
+
+
+	if [[ $CICD_NIGHTLY == 1 ]] ; then
+		rm -rf $CICD_MODULE_WORK_DIR/peasoup_umbrella
+	fi
+
+}
+
+main "$@"
diff --git a/cicd_tests/xform-cat.sh b/cicd_tests/xform-cat.sh
new file mode 100755
index 000000000..56d53520b
--- /dev/null
+++ b/cicd_tests/xform-cat.sh
@@ -0,0 +1,12 @@
+cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+
+set -e
+set -x
+
+source set_env_vars
+cd /tmp
+rm -rf cat.rida ped_cat; 
+$PSZ $(which cat) ./cat.rida -c rida=on -s meds_static=off -c p1transform=on --tempdir ped_cat || true
+if [[ ! -x ./cat.rida ]]; then cat ped_cat/logs/*; fi
+./cat.rida /dev/null 
+
diff --git a/cicd_tests/xform-ls.sh b/cicd_tests/xform-ls.sh
new file mode 100755
index 000000000..748f01c5f
--- /dev/null
+++ b/cicd_tests/xform-ls.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+set -e
+set -x
+
+cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+source set_env_vars
+cd /tmp
+rm -rf ls.rida ped_ls
+$PSZ /bin/ls ./ls.rida -c rida=on -s meds_static=off -c p1transform=on --tempdir ped_ls || true
+if [[ ! -x ./ls.rida ]]; then cat ped_ls/logs/*; fi
+rm -rf ped_ls
+./ls.rida
+
+
-- 
GitLab