Skip to content

Commit

Permalink
GEODE-8406: Make early-return immune to the Geode dir not existing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
robbadler committed Aug 10, 2020
1 parent eb10815 commit 0e31dd1
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 44 deletions.
5 changes: 1 addition & 4 deletions ci/scripts/archive_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ci/scripts/create_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/delete_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/execute_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/execute_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/repeat-new-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/rsync_code_down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 1 addition & 3 deletions ci/scripts/rsync_code_up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
57 changes: 37 additions & 20 deletions ci/scripts/shared_utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

0 comments on commit 0e31dd1

Please sign in to comment.