1+ #! /bin/bash
2+ # Copyright 2018 Google Inc.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+ set -e -o pipefail
17+ shopt -s globstar
18+ # We spin up some subprocesses. Don't kill them on hangup
19+ trap ' ' HUP
20+
21+ # Update gcloud and check version
22+ gcloud components update --quiet
23+ echo -e " \n ********** GCLOUD INFO *********** \n"
24+ gcloud -v
25+ echo -e " \n ********** MAVEN INFO *********** \n"
26+ mvn -v
27+ echo -e " \n ********** GRADLE INFO *********** "
28+ gradle -v
29+
30+ # Setup required enviormental variables
31+ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR} /service-acct.json
32+ export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
33+ # Activate service account
34+ gcloud auth activate-service-account\
35+ --key-file=$GOOGLE_APPLICATION_CREDENTIALS \
36+ --project=$GOOGLE_CLOUD_PROJECT
37+
38+ echo -e " \n******************** CHECKING FOR AFFECTED FOLDERS ********************"
39+ # Diff to find out what has changed from master
40+ cd github/getting-started-java
41+ find ./* / -name pom.xml -print0 | sort -z | while read -d $' \0' file
42+ do
43+ file=$( dirname " $file " )
44+ echo " ------------------------------------------------------------"
45+ echo " - checking $file "
46+ echo " ------------------------------------------------------------"
47+
48+
49+ pushd " $file " > /dev/null
50+ set +e
51+ git diff --quiet master.. .
52+ RTN=$?
53+ set -e
54+
55+ # Check for changes to the current folder
56+ if [ " $CHANGED " -eq 1 ] && [ " $PARENT " -eq 0 ]; then
57+ mvn -q --batch-mode --fail-at-end clean verify \
58+ -Dfile.encoding=" UTF-8" \
59+ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
60+ -Dmaven.test.redirectTestOutputToFile=true \
61+ -Dbigtable.projectID=" ${GOOGLE_CLOUD_PROJECT} " \
62+ -Dbigtable.instanceID=instance
63+ echo -e " Tests complete. \n"
64+ else
65+ echo -e " \n NO change found. \n"
66+ fi
67+
68+ popd > /dev/null
69+
70+ done
0 commit comments