From 7aadf84abe9fe6f08317c9b86b28b8193bd55d40 Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdh8d@gmail.com>
Date: Thu, 8 Nov 2018 18:02:46 +0000
Subject: [PATCH] refactoring/simplifying tests for multi-os testing

---
 .gitlab-ci.yml               | 70 +++++-------------------------------
 cicd_tests/do-build.sh       | 24 +++++++++++++
 cicd_tests/internal-tests.sh | 11 ++++++
 cicd_tests/xform-cat.sh      |  8 +++++
 cicd_tests/xform-ls.sh       | 10 ++++++
 5 files changed, 62 insertions(+), 61 deletions(-)
 create mode 100644 cicd_tests/do-build.sh
 create mode 100644 cicd_tests/internal-tests.sh
 create mode 100644 cicd_tests/xform-cat.sh
 create mode 100644 cicd_tests/xform-ls.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 973aba1..8d01b8a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,86 +3,34 @@ before_script:
 
 
 after_script:
-  - "echo Test Complete, eliding cleanup"
-  - "rm -rf /tmp/ped_ls /tmp/ls.rida /tmp/ped_cat"
+  - "echo Test Complete."
 
 
 
-do_build:
+do-build:
   stage: build
   tags:
-    - zipr
+    - ubuntu18
   script:
-    - "# gather info for debugging later, probably not necessary "
-    - "pwd"
-    - "hostname"
-    - "whoami"
-    - "env|grep CICD"
-    - ""
-    - "# puts peasoup_umbrella (and all submodules) in CICD_MODULE_WORK_DIR"
-    - "cicd_setup_module_dependency allnp/peasoup_umbrella.git"
-    - ""
-    - "# puts the version of zipr to test in peasoup_umbrella/zipr."
-    - "cicd_put_module_in_tree peasoup_umbrella/zipr"
-    - ""
-    - "# Build/run $PSZ, test result"
-    - "cd $CICD_MODULE_WORK_DIR/peasoup_umbrella"
-    - "source set_env_vars"
-    - "sudo ./get-peasoup-packages.sh all"
-    - "./build-all.sh"
-    - "dropdb $PGDATABASE 2>/dev/null || true ; ./postgres_setup.sh"
+    - ./cicd_tests/do-build.sh
 
 xform-ls:
   stage: test
   tags:
-    - zipr
+    - ubuntu18
   script:
-    - "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 --tempdir ped_ls || true"
-    - "if [[ ! -x ./ls.rida ]]; then cat ped_ls/logs/*; fi"
-    - "rm -rf ped_ls"
-    - "./ls.rida"
-    - ""
+    - ./cicd_tests/xform-ls.sh
 
 xform-cat:
   stage: test
   tags:
-    - zipr
+    - ubuntu18
   script:
-    - "cd $CICD_MODULE_WORK_DIR/peasoup_umbrella"
-    - "source set_env_vars"
-    - "cd /tmp"
-    - "rm -rf cat.rida ped_cat; $PSZ /bin/ls ./cat.rida -c rida=on -s meds_static=off --tempdir ped_cat || true"
-    - "if [[ ! -x ./cat.rida ]]; then cat ped_ls/logs/*; fi"
-    - "./cat.rida /dev/null "
-    - ""
+    - ./cicd_tests/xform-cat.sh
 
 internal-tests:
   stage: test
   tags:
     - zipr
   script:
-    - "cd $CICD_MODULE_WORK_DIR/peasoup_umbrella"
-    - "source set_env_vars"
-    - "# run zipr internal tests"
-    - "cd $ZIPR_HOME/test; scons"
-    - "for i in *.exe; do ./$i; done"
-
-
-# updating ps-analyze is now done nightly.
-#update-ps:
-#   stage: deploy
-#   only: 
-#      refs:
-#        - master
-#   when: on_success
-#   tags:
-#      - zipr
-#   script:
-#      - "cd $CICD_MODULE_WORK_DIR/peasoup_umbrella"
-#      - "git add zipr" 
-#      - "git commit -m \"submod automatic update from zipr update-ps job on $(date)\" "
-#      - "git push"
-     
+    - ./cicd_tests/internal-tests.sh
diff --git a/cicd_tests/do-build.sh b/cicd_tests/do-build.sh
new file mode 100644
index 0000000..834ed0a
--- /dev/null
+++ b/cicd_tests/do-build.sh
@@ -0,0 +1,24 @@
+#/bin/bash 
+
+set -e
+
+# gather info for debugging later, probably not necessary 
+pwd
+hostname
+whoami
+env|grep CICD
+
+# puts peasoup_umbrella (and all submodules) in CICD_MODULE_WORK_DIR
+cicd_setup_module_dependency allnp/peasoup_umbrella.git
+
+
+# puts the version of zipr to test in peasoup_umbrella/zipr.
+cicd_put_module_in_tree peasoup_umbrella/zipr
+
+# Build/run $PSZ, test result
+cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+source set_env_vars
+sudo ./get-peasoup-packages.sh all
+./build-all.sh
+dropdb $PGDATABASE 2>/dev/null || true ; ./postgres_setup.sh
+
diff --git a/cicd_tests/internal-tests.sh b/cicd_tests/internal-tests.sh
new file mode 100644
index 0000000..8a8f4f5
--- /dev/null
+++ b/cicd_tests/internal-tests.sh
@@ -0,0 +1,11 @@
+#!/bin/bash 
+
+set -e
+
+cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+source set_env_vars
+# run zipr internal tests
+cd $ZIPR_HOME/test; scons
+for i in *.exe; do ./$i; done
+
+
diff --git a/cicd_tests/xform-cat.sh b/cicd_tests/xform-cat.sh
new file mode 100644
index 0000000..12d9556
--- /dev/null
+++ b/cicd_tests/xform-cat.sh
@@ -0,0 +1,8 @@
+cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
+
+set -e
+source set_env_vars
+cd /tmp
+rm -rf cat.rida ped_cat; $PSZ $(which cat) ./cat.rida -c rida=on -s meds_static=off --tempdir ped_cat || true
+if [[ ! -x ./cat.rida ]]; then cat ped_ls/logs/*; fi
+./cat.rida /dev/null 
diff --git a/cicd_tests/xform-ls.sh b/cicd_tests/xform-ls.sh
new file mode 100644
index 0000000..9b52f61
--- /dev/null
+++ b/cicd_tests/xform-ls.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -e
+
+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 --tempdir ped_ls || true
+if [[ ! -x ./ls.rida ]]; then cat ped_ls/logs/*; fi
+rm -rf ped_ls
+./ls.rida
-- 
GitLab