Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking change #796

Merged
merged 21 commits into from
Aug 9, 2017
Prev Previous commit
Next Next commit
more rookie errors
  • Loading branch information
Les Vogel committed Aug 9, 2017
commit d00374976cff12942877918837be62d4483a6f17
30 changes: 12 additions & 18 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ set -e

cd "${HOME}/project" # lv3 8/8/17

# Setup GCP application default credentials before `set -x` echos everything out
if [[ $GCLOUD_SERVICE_KEY ]]; then
echo "$GCLOUD_SERVICE_KEY" | \
base64 --decode --ignore-garbage > "${HOME}/google-cloud-service-key.json"
export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/google-cloud-service-key.json"
fi

set -x
# Set pipefail so that `egrep` does not eat the exit code.
set -o pipefail
shopt -s globstar

echo "GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}"

SKIP_TESTS=false
if [ -z "$GOOGLE_APPLICATION_CREDENTIALS" ] ; then
Expand All @@ -37,25 +31,25 @@ fi

# Finds the closest parent dir that encompasses all changed files, and has a
# pom.xml
travis_changed_files_parent() {
changed_files_parent() {
# If we're not in a PR, forget it
echo "CI_PULL_REQUEST: ${CI_PULL_REQUEST}"
echo "CIRCLE_BRANCH: ${CIRCLE_BRANCH}"
echo "git rev-parse HEAD: $(git rev-parse HEAD)"
[ -z "${TRAVIS_PULL_REQUEST-CI_PULL_REQUEST}" ] && return 0
[ -z "${CI_PULL_REQUEST}" ] && return 0

(
set +e

changed="$(git diff --name-only "${TRAVIS_COMMIT-CIRCLE_SHA1}" "${TRAVIS_BRANCH-CIRCLE_BRANCH}")"
changed="$(git diff --name-only '${CIRCLE_SHA1}' '${CIRCLE_BRANCH}')"
if [ $? -ne 0 ]; then
# Fall back to git head
changed="$(git diff --name-only "$(git rev-parse HEAD)" "${TRAVIS_BRANCH-CIRCLE_BRANCH}")"
changed="$(git diff --name-only '$(git rev-parse HEAD)' '${CIRCLE_BRANCH}')"
[ $? -ne 0 ] && return 0 # Give up. Just run everything.
fi

# Find the common prefix
prefix="$(echo "$changed" | \
prefix="$(echo '$changed' | \
# N: Do this for a pair of lines
# s: capture the beginning of a line, that's followed by a new line
# starting with that capture group. IOW - two lines that start with the
Expand All @@ -75,21 +69,21 @@ travis_changed_files_parent() {
)
}

common_travis_dir="$(travis_changed_files_parent)"
common_dir="$(changed_files_parent)"

echo "Common Dir: ${common_travis_dir}"
echo "Common Dir: ${common_dir}"

[ -z "$common_travis_dir" ] || pushd "$common_travis_dir"
[ -z "$common_dir" ] || pushd "$common_dir"

# Give Maven a bit more memory
#export MAVEN_OPTS='-XX:+PrintFlagsFinal -Xmx800m -Xms400m'
export MAVEN_OPTS='-Xmx800m -Xms400m'
"mvn \
mvn \
--batch-mode clean verify -e \
-DskipTests=$SKIP_TESTS | \
egrep -v "(^\[INFO\] Download|^\[INFO\].*skipping)"

[ -z "$common_travis_dir" ] || popd
[ -z "$common_dir" ] || popd

# Check that all shell scripts in this repo (including this one) pass the
# Shell Check linter.
Expand All @@ -106,7 +100,7 @@ test_localhost() {
appengine/datastore/indexes-perfect
)
for testdir in "${devserver_tests[@]}" ; do
if [ -z "$common_travis_dir" ] || [[ $testdir = $common_travis_dir* ]]; then
if [ -z "$common_dir" ] || [[ $testdir = $common_dir* ]]; then
./java-repo-tools/scripts/test-localhost.sh appengine "${testdir}"
fi
done
Expand Down