You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rh...@apache.org on 2020/08/10 23:29:00 UTC

[geode] branch develop updated: GEODE-8406: Make early-return immune to the Geode dir not existing (#5440)

This is an automated email from the ASF dual-hosted git repository.

rhoughton pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0e31dd1  GEODE-8406: Make early-return immune to the Geode dir not existing (#5440)
0e31dd1 is described below

commit 0e31dd1fd9c421c62c4aa24705834a0899c496cf
Author: Robert Houghton <rh...@pivotal.io>
AuthorDate: Mon Aug 10 16:27:51 2020 -0700

    GEODE-8406: Make early-return immune to the Geode dir not existing (#5440)
---
 ci/scripts/archive_results.sh  |  5 +---
 ci/scripts/create_instance.sh  |  5 ++--
 ci/scripts/delete_instance.sh  |  4 +--
 ci/scripts/execute_build.sh    |  4 +--
 ci/scripts/execute_tests.sh    |  4 +--
 ci/scripts/repeat-new-tests.sh |  4 +--
 ci/scripts/rsync_code_down.sh  |  4 +--
 ci/scripts/rsync_code_up.sh    |  4 +--
 ci/scripts/shared_utilities.sh | 57 +++++++++++++++++++++++++++---------------
 9 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/ci/scripts/archive_results.sh b/ci/scripts/archive_results.sh
index 0814725..81dc3e2 100755
--- a/ci/scripts/archive_results.sh
+++ b/ci/scripts/archive_results.sh
@@ -31,10 +31,7 @@ SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
 source ${BASE_DIR}/concourse-metadata-resource/concourse_metadata
 source ${SCRIPTDIR}/shared_utilities.sh
-
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 BUILDROOT=$(pwd)
 DEST_DIR=${BUILDROOT}/geode-results
diff --git a/ci/scripts/create_instance.sh b/ci/scripts/create_instance.sh
index efa1e47..531058e 100755
--- a/ci/scripts/create_instance.sh
+++ b/ci/scripts/create_instance.sh
@@ -48,10 +48,11 @@ if [[ -z "${IMAGE_FAMILY_NAME}" ]]; then
   exit 1
 fi
 
+. ${SCRIPTDIR}/shared_utilities.sh
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
+
 if [[ -d geode ]]; then
   pushd geode
-    . ${SCRIPTDIR}/shared_utilities.sh
-    is_source_from_pr_testable || exit 0
 
     GEODE_SHA=$(git rev-parse --verify HEAD)
   popd
diff --git a/ci/scripts/delete_instance.sh b/ci/scripts/delete_instance.sh
index 36ea4b7..fa9f3a0 100755
--- a/ci/scripts/delete_instance.sh
+++ b/ci/scripts/delete_instance.sh
@@ -30,9 +30,7 @@ done
 SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
 . ${SCRIPTDIR}/shared_utilities.sh
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 INSTANCE_NAME="$(cat instance-data/instance-name)"
 PERMITTED_ZONES=($(gcloud compute zones list --filter="name~'us-central.*'" --format=json | jq -r .[].name))
diff --git a/ci/scripts/execute_build.sh b/ci/scripts/execute_build.sh
index 1b3de96..b812dca 100755
--- a/ci/scripts/execute_build.sh
+++ b/ci/scripts/execute_build.sh
@@ -30,9 +30,7 @@ done
 SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 source ${SCRIPTDIR}/shared_utilities.sh
 
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 if [[ -z "${GRADLE_TASK}" ]]; then
   echo "GRADLE_TASK must be set. exiting..."
diff --git a/ci/scripts/execute_tests.sh b/ci/scripts/execute_tests.sh
index 8aeba36..da98e39 100755
--- a/ci/scripts/execute_tests.sh
+++ b/ci/scripts/execute_tests.sh
@@ -35,9 +35,7 @@ if [[ -z "${GRADLE_TASK}" ]]; then
 fi
 
 . ${SCRIPTDIR}/shared_utilities.sh
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 REPODIR=$(cd geode; git rev-parse --show-toplevel)
 
diff --git a/ci/scripts/repeat-new-tests.sh b/ci/scripts/repeat-new-tests.sh
index fa965ca..7a8e7a1 100755
--- a/ci/scripts/repeat-new-tests.sh
+++ b/ci/scripts/repeat-new-tests.sh
@@ -29,9 +29,7 @@ SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
 . ${SCRIPTDIR}/shared_utilities.sh
 
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 function changes_for_path() {
   pushd geode >> /dev/null
diff --git a/ci/scripts/rsync_code_down.sh b/ci/scripts/rsync_code_down.sh
index f27b058..55b61d8 100755
--- a/ci/scripts/rsync_code_down.sh
+++ b/ci/scripts/rsync_code_down.sh
@@ -30,9 +30,7 @@ done
 SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
 . ${SCRIPTDIR}/shared_utilities.sh
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 SSHKEY_FILE="instance-data/sshkey"
 
diff --git a/ci/scripts/rsync_code_up.sh b/ci/scripts/rsync_code_up.sh
index b0200c2..55cafa9 100755
--- a/ci/scripts/rsync_code_up.sh
+++ b/ci/scripts/rsync_code_up.sh
@@ -32,9 +32,7 @@ SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 REPODIR=$(cd geode; git rev-parse --show-toplevel)
 
 . ${SCRIPTDIR}/shared_utilities.sh
-pushd geode 2>&1 >> /dev/null
-  is_source_from_pr_testable || exit 0
-popd 2>&1 >> /dev/null
+is_source_from_pr_testable "geode" "$(get_geode_pr_exclusion_dirs)" || exit 0
 
 SSHKEY_FILE="instance-data/sshkey"
 SSH_OPTIONS="-i ${SSHKEY_FILE} -o ConnectionAttempts=60 -o StrictHostKeyChecking=no"
diff --git a/ci/scripts/shared_utilities.sh b/ci/scripts/shared_utilities.sh
index 8f8c2ea..b8f6786 100644
--- a/ci/scripts/shared_utilities.sh
+++ b/ci/scripts/shared_utilities.sh
@@ -76,29 +76,46 @@ get-full-version() {
   echo ${FULL_PRODUCT_VERSION}
 }
 
+get_geode_pr_exclusion_dirs() {
+  local exclude_dirs="ci dev-tools etc geode-book geode-docs"
+  echo "${exclude_dirs}"
+}
+
 is_source_from_pr_testable() {
-  local base_dir=$(git rev-parse --show-toplevel)
-  local github_pr_dir="${base_dir}/.git/resource"
-  pushd ${base_dir} 2>&1 >> /dev/null
-    local return_code=0
-    if [ -d "${github_pr_dir}" ]; then
-      # Modify this path list with directories to exclude
-      local exclude_dirs="ci dev-tools etc geode-book geode-docs"
-      for d in $(echo ${exclude_dirs}); do
-        local exclude_pathspec="${exclude_pathspec} :(exclude,glob)${d}/**"
-      done
-      pushd ${base_dir} &> /dev/null
-        local files=$(git diff --name-only $(cat "${github_pr_dir}/base_sha") $(cat "${github_pr_dir}/head_sha") -- . $(echo ${exclude_pathspec}))
-      popd &> /dev/null
-      if [[ -z "${files}" ]]; then
-        >&2 echo "Code changes are from CI only"
-        return_code=1
+  if [[ $# -ne 2 ]]; then
+    >&2 echo "Invalid args. Try ${0} \"<repo_path>\" \"<list of exclusion dirs>\""
+    exit 1
+  fi
+  local repo_dir="${1}"
+  if [[ ! -d "${repo_dir}" ]]; then
+    # If the repo_dir does not exist, assume call from non-PR
+    return 0;
+  fi
+
+  pushd "${repo_dir}" 2>&1 >> /dev/null
+    local base_dir=$(git rev-parse --show-toplevel)
+    local github_pr_dir="${base_dir}/.git/resource"
+    pushd ${base_dir} 2>&1 >> /dev/null
+      local return_code=0
+      if [ -d "${github_pr_dir}" ]; then
+        # Modify this path list with directories to exclude
+        local exclude_dirs="${2}"
+        for d in $(echo ${exclude_dirs}); do
+          local exclude_pathspec="${exclude_pathspec} :(exclude,glob)${d}/**"
+        done
+        pushd ${base_dir} &> /dev/null
+          local files=$(git diff --name-only $(cat "${github_pr_dir}/base_sha") $(cat "${github_pr_dir}/head_sha") -- . $(echo ${exclude_pathspec}))
+        popd &> /dev/null
+        if [[ -z "${files}" ]]; then
+          >&2 echo "Code changes are from CI only"
+          return_code=1
+        else
+          >&2 echo "real code change here!"
+        fi
       else
-        >&2 echo "real code change here!"
+        >&2 echo "repo is not from a PR"
       fi
-    else
-      >&2 echo "repo is not from a PR"
-    fi
+    popd 2>&1 >> /dev/null
   popd 2>&1 >> /dev/null
   return ${return_code}
 }