15
15
16
16
set -e
17
17
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
24
19
25
20
set -x
26
21
# Set pipefail so that `egrep` does not eat the exit code.
27
22
set -o pipefail
28
23
shopt -s globstar
29
24
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} "
30
31
31
32
SKIP_TESTS=false
32
33
if [ -z " $GOOGLE_APPLICATION_CREDENTIALS " ] ; then
35
36
36
37
# Finds the closest parent dir that encompasses all changed files, and has a
37
38
# pom.xml
38
- travis_changed_files_parent () {
39
+ changed_files_parent () {
39
40
# 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
41
42
42
43
(
43
44
set +e
44
45
45
- changed=" $( git diff --name-only " ${TRAVIS_COMMIT- CIRCLE_SHA1}" " ${TRAVIS_BRANCH- CIRCLE_BRANCH}" ) "
46
+ changed=" $( git diff --name-only ${ CIRCLE_SHA1} ${ CIRCLE_BRANCH}) "
46
47
if [ $? -ne 0 ]; then
47
48
# 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}) "
49
50
[ $? -ne 0 ] && return 0 # Give up. Just run everything.
50
51
fi
51
52
52
53
# Find the common prefix
53
- prefix=" $( echo " $changed " | \
54
+ prefix=" $( echo $changed | sed -e ' N;s/^\(.*\).*\n\1.*$/\1\n\1/;D ' ) "
54
55
# N: Do this for a pair of lines
55
56
# s: capture the beginning of a line, that's followed by a new line
56
57
# starting with that capture group. IOW - two lines that start with the
57
58
# same zero-or-more characters. Replace it with just the capture group
58
59
# (ie the common prefix).
59
60
# D: Delete the first line of the pair, leaving the second line for the
60
61
# next pass.
61
- sed -e ' N;s/^\(.*\).*\n\1.*$/\1\n\1/;D' ) "
62
62
63
63
while [ ! -z " $prefix " ] && [ ! -r " $prefix /pom.xml" ] && [ " ${prefix%/* } " != " $prefix " ]; do
64
64
prefix=" ${prefix%/* } "
@@ -70,19 +70,20 @@ travis_changed_files_parent() {
70
70
)
71
71
}
72
72
73
- common_travis_dir=" $( travis_changed_files_parent) "
73
+ common_dir=" $( changed_files_parent) "
74
+
75
+ echo " Common Dir: ${common_dir} "
74
76
75
- [ -z " $common_travis_dir " ] || pushd " $common_travis_dir "
77
+ [ -z " ${common_dir} " ] || pushd " ${common_dir} "
76
78
77
79
# Give Maven a bit more memory
78
- # export MAVEN_OPTS='-XX:+PrintFlagsFinal -Xmx800m -Xms400m'
79
80
export MAVEN_OPTS=' -Xmx800m -Xms400m'
80
- " ${TRAVIS_BUILD_DIR- $HOME / $CIRCLE_PROJECT_REPONAME } " /mvnw \
81
+ mvn \
81
82
--batch-mode clean verify -e \
82
83
-DskipTests=$SKIP_TESTS | \
83
84
egrep -v " (^\[INFO\] Download|^\[INFO\].*skipping)"
84
85
85
- [ -z " $common_travis_dir " ] || popd
86
+ [ -z " $common_dir " ] || popd
86
87
87
88
# Check that all shell scripts in this repo (including this one) pass the
88
89
# Shell Check linter.
@@ -99,7 +100,7 @@ test_localhost() {
99
100
appengine/datastore/indexes-perfect
100
101
)
101
102
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
103
104
./java-repo-tools/scripts/test-localhost.sh appengine " ${testdir} "
104
105
fi
105
106
done
0 commit comments