1515
1616set -e
1717
18- # Setup GCP application default credentials before `set -x` echos everything out
19- if [[ $GCLOUD_SERVICE_KEY ]]; then
20- echo " $GCLOUD_SERVICE_KEY " | \
21- base64 --decode --ignore-garbage > " ${HOME} /google-cloud-service-key.json"
22- export GOOGLE_APPLICATION_CREDENTIALS=" ${HOME} /google-cloud-service-key.json"
23- fi
18+ cd " ${HOME} /project" # lv3 8/8/17
2419
2520set -x
2621# Set pipefail so that `egrep` does not eat the exit code.
2722set -o pipefail
2823shopt -s globstar
2924
25+ echo " GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS} "
26+ echo " CI_PULL_REQUEST: ${CI_PULL_REQUEST} "
27+ echo " CIRCLE_BRANCH: ${CIRCLE_BRANCH} "
28+ echo " git rev-parse HEAD: $( git rev-parse HEAD) "
29+ echo " CIRCLE_PR_NUMBER: ${CIRCLE_PR_NUMBER} "
30+ echo " CIRCLE_PR_USERNAME: ${CIRCLE_PR_USERNAME} "
3031
3132SKIP_TESTS=false
3233if [ -z " $GOOGLE_APPLICATION_CREDENTIALS " ] ; then
3536
3637# Finds the closest parent dir that encompasses all changed files, and has a
3738# pom.xml
38- travis_changed_files_parent () {
39+ changed_files_parent () {
3940 # If we're not in a PR, forget it
40- [ -z " ${TRAVIS_PULL_REQUEST- CI_PULL_REQUEST} " ] && return 0
41+ [ -z " ${CI_PULL_REQUEST} " ] && return 0
4142
4243 (
4344 set +e
4445
45- changed=" $( git diff --name-only " ${TRAVIS_COMMIT- CIRCLE_SHA1}" " ${TRAVIS_BRANCH- CIRCLE_BRANCH}" ) "
46+ changed=" $( git diff --name-only ${ CIRCLE_SHA1} ${ CIRCLE_BRANCH}) "
4647 if [ $? -ne 0 ]; then
4748 # Fall back to git head
48- changed=" $( git diff --name-only " $( git rev-parse HEAD) " " ${TRAVIS_BRANCH- CIRCLE_BRANCH}" ) "
49+ changed=" $( git diff --name-only $( git rev-parse HEAD) ${ CIRCLE_BRANCH}) "
4950 [ $? -ne 0 ] && return 0 # Give up. Just run everything.
5051 fi
5152
5253 # Find the common prefix
53- prefix=" $( echo " $changed " | \
54+ prefix=" $( echo $changed | sed -e ' N;s/^\(.*\).*\n\1.*$/\1\n\1/;D ' ) "
5455 # N: Do this for a pair of lines
5556 # s: capture the beginning of a line, that's followed by a new line
5657 # starting with that capture group. IOW - two lines that start with the
5758 # same zero-or-more characters. Replace it with just the capture group
5859 # (ie the common prefix).
5960 # D: Delete the first line of the pair, leaving the second line for the
6061 # next pass.
61- sed -e ' N;s/^\(.*\).*\n\1.*$/\1\n\1/;D' ) "
6262
6363 while [ ! -z " $prefix " ] && [ ! -r " $prefix /pom.xml" ] && [ " ${prefix%/* } " != " $prefix " ]; do
6464 prefix=" ${prefix%/* } "
@@ -70,19 +70,20 @@ travis_changed_files_parent() {
7070 )
7171}
7272
73- common_travis_dir=" $( travis_changed_files_parent) "
73+ common_dir=" $( changed_files_parent) "
74+
75+ echo " Common Dir: ${common_dir} "
7476
75- [ -z " $common_travis_dir " ] || pushd " $common_travis_dir "
77+ [ -z " ${common_dir} " ] || pushd " ${common_dir} "
7678
7779# Give Maven a bit more memory
78- # export MAVEN_OPTS='-XX:+PrintFlagsFinal -Xmx800m -Xms400m'
7980export MAVEN_OPTS=' -Xmx800m -Xms400m'
80- " ${TRAVIS_BUILD_DIR- $HOME / $CIRCLE_PROJECT_REPONAME } " /mvnw \
81+ mvn \
8182 --batch-mode clean verify -e \
8283 -DskipTests=$SKIP_TESTS | \
8384 egrep -v " (^\[INFO\] Download|^\[INFO\].*skipping)"
8485
85- [ -z " $common_travis_dir " ] || popd
86+ [ -z " $common_dir " ] || popd
8687
8788# Check that all shell scripts in this repo (including this one) pass the
8889# Shell Check linter.
@@ -99,7 +100,7 @@ test_localhost() {
99100 appengine/datastore/indexes-perfect
100101 )
101102 for testdir in " ${devserver_tests[@]} " ; do
102- if [ -z " $common_travis_dir " ] || [[ $testdir = $common_travis_dir * ]]; then
103+ if [ -z " $common_dir " ] || [[ $testdir = $common_dir * ]]; then
103104 ./java-repo-tools/scripts/test-localhost.sh appengine " ${testdir} "
104105 fi
105106 done
0 commit comments