From aaa370b4be2cd21dbeac5cf7daa9c76e1100df3c Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Tue, 10 Nov 2020 23:10:24 -0600
Subject: [PATCH] Cleaned up  and simplified the config/env.sh and
 util/build.sh

 - We should limit the number of new environment variables. They
 increase complexity which should be mostly absorbed by using containers.
 - Any new environment variables should be set via the ci yml file
 or defined the UI. https://docs.gitlab.com/ee/ci/variables/README.html#custom-environment-variables
 - Removed dummies
---
 .gitlab-ci.yml           |  3 +--
 config/env.sh            | 15 ++++++++-------
 dis/dis.sh               |  3 +--
 dummy/.gitignore         |  0
 dummy/config.yml         | 24 ------------------------
 dummy/dummy_fail_test.sh |  7 -------
 dummy/dummy_test.sh      |  7 -------
 dummy/dummy_test2.sh     |  7 -------
 util/build_detector.sh   | 20 +++++++++++++++-----
 9 files changed, 25 insertions(+), 61 deletions(-)
 delete mode 100644 dummy/.gitignore
 delete mode 100644 dummy/config.yml
 delete mode 100755 dummy/dummy_fail_test.sh
 delete mode 100755 dummy/dummy_test.sh
 delete mode 100755 dummy/dummy_test2.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 49d71255..01da6a16 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,11 +15,10 @@ stages:
 
 include:
   - local: 'dis/config.yml'
-  - local: 'dummy/config.yml'
   - local: 'dvmp/config.yml'
 
 summary:
   stage: finish
-  needs: ["dis:results", "dummy:results", "dvmp:results"]
+  needs: ["dis:results", "dvmp:results"]
   script:
     - echo "All benchmarks passed"
diff --git a/config/env.sh b/config/env.sh
index e2b34a24..0177dabc 100755
--- a/config/env.sh
+++ b/config/env.sh
@@ -12,17 +12,18 @@ if [[ ! -n  "${JUGGLER_INSTALL_PREFIX}" ]] ; then
   export JUGGLER_INSTALL_PREFIX="/usr/local"
 fi
 
+# not sure this is needed
 if [[ ! -n "${DETECTOR_PREFIX}" ]]; then
-  export DETECTOR_PREFIX=detector
+  # reuse the custom juggler install prefix for detector
+  export DETECTOR_INSTALL_PREFIX=${JUGGLER_INSTALL_PREFIX}
 fi
 
 ## ensure absolute paths
+# not sure this is needed either 
 export JUGGLER_INSTALL_PREFIX=`realpath ${JUGGLER_INSTALL_PREFIX}`
-export DETECTOR_PREFIX=`realpath ${DETECTOR_PREFIX}`
-
-## setup detector paths
-export LD_LIBRARY_PATH=${DETECTOR_PREFIX}/lib:$LD_LIBRARY_PATH
-export DETECTOR_SOURCE_PATH=${DETECTOR_PREFIX}/src
+export DETECTOR_INSTALL_PREFIX=`realpath ${DETECTOR_INSTALL_PREFIX}`
 
 ## setup root results artifact path
-export RESULTS_PATH=`realpath results`
+# this should be in the CI File instead
+# https://docs.gitlab.com/ee/ci/yaml/README.html#variables
+# export RESULTS_PATH=`realpath results`
diff --git a/dis/dis.sh b/dis/dis.sh
index 657c9b80..8bdaffbd 100644
--- a/dis/dis.sh
+++ b/dis/dis.sh
@@ -60,7 +60,6 @@ fi
 # Need to figure out how to pass file name to juggler from the commandline
 xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv \
   gaudirun.py ../options/tracker_reconstruction.py
-
 if [[ "$?" -ne "0" ]] ; then
   echo "ERROR running juggler"
   exit 1
@@ -78,6 +77,6 @@ if [[ "$?" -ne "0" ]] ; then
 fi
 
 if [[ "${JUGGLER_N_EVENTS}" -lt "500" ]] ; then 
-cp ${JUGGLER_DETECTOR}/${JUGGLER_REC_FILE} results/.
+cp ${JUGGLER_DETECTOR}/${JUGGLER_REC_FILE} results/dis/.
 fi
 
diff --git a/dummy/.gitignore b/dummy/.gitignore
deleted file mode 100644
index e69de29b..00000000
diff --git a/dummy/config.yml b/dummy/config.yml
deleted file mode 100644
index 80e0b60a..00000000
--- a/dummy/config.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-dummy:dummy_test:
-  stage: analyze
-  timeout: 1 hours
-  script:
-    - dummy/dummy_test.sh
-
-dummy:dummy_test2:
-  stage: analyze
-  timeout: 1 hours
-  script:
-    - dummy/dummy_test2.sh
-
-dummy:dummy_fail_test:
-  stage: analyze
-  timeout: 1 hours
-  allow_failure: true
-  script:
-    - dummy/dummy_fail_test.sh
-
-dummy:results:
-  stage: collect
-  needs: ["dummy:dummy_test", "dummy:dummy_test2", "dummy:dummy_fail_test"]
-  script:
-    - echo "All DIS benchmarks successful"
diff --git a/dummy/dummy_fail_test.sh b/dummy/dummy_fail_test.sh
deleted file mode 100755
index f8c506b3..00000000
--- a/dummy/dummy_fail_test.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "Dummy Test..."
-echo "..."
-echo "Fails!"
-
-exit 1
diff --git a/dummy/dummy_test.sh b/dummy/dummy_test.sh
deleted file mode 100755
index 5af1dc34..00000000
--- a/dummy/dummy_test.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "Dummy Test..."
-echo "..."
-echo "Passes!"
-
-#exit 1
diff --git a/dummy/dummy_test2.sh b/dummy/dummy_test2.sh
deleted file mode 100755
index dfede272..00000000
--- a/dummy/dummy_test2.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "Dummy Test number 2..."
-echo "..."
-echo "Passes!"
-
-#exit 1
diff --git a/util/build_detector.sh b/util/build_detector.sh
index 7a1477f8..3d08a73c 100755
--- a/util/build_detector.sh
+++ b/util/build_detector.sh
@@ -4,15 +4,25 @@
 source config/env.sh
 
 ## Build and install the detector plugins.
-if [[ ! -d ${DETECTOR_SOURCE_PATH} ]]; then
-  git clone https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git ${DETECTOR_SOURCE_PATH}
+if [[ ! -d ${JUGGLER_DETECTOR} ]]; then
+  git clone https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git
+  # this might be temporary. There are multiple solutions here but this is the simple pattern for now
+  # I do not want to use git submodules here -whit
+  git clone https://eicweb.phy.anl.gov/EIC/detectors/accelerator.git
+  pushd ${JUGGLER_DETECTOR}
+  ln -s ../accelerator/eic
+  popd
 else
-  pushd ${DETECTOR_SOURCE_PATH}
+  pushd ${JUGGLER_DETECTOR}
+  git pull --ff-only
+  popd
+  pushd accelerator
   git pull --ff-only
   popd
 fi
 mkdir -p detector-build
 pushd detector-build
-echo cmake ${DETECTOR_SOURCE_PATH} -DCMAKE_INSTALL_PREFIX=${DETECTOR_PREFIX} && make -j30 install
-cmake ${DETECTOR_SOURCE_PATH} -DCMAKE_INSTALL_PREFIX=${DETECTOR_PREFIX} && make -j30 install
+# Always keep the detector directory at the top level.
+echo cmake ../${JUGGLER_DETECTOR} -DCMAKE_INSTALL_PREFIX=${DETECTOR_INSTALL_PREFIX} && make -j30 install
+cmake ../${JUGGLER_DETECTOR} -DCMAKE_INSTALL_PREFIX=${DETECTOR_INSTALL_PREFIX} && make -j30 install
 popd
-- 
GitLab