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+ source ${KOKORO_GFILE_DIR} /aws-secrets.sh
34+ source ${KOKORO_GFILE_DIR} /dlp_secrets.txt
35+ # Activate service account
36+ gcloud auth activate-service-account\
37+ --key-file=$GOOGLE_APPLICATION_CREDENTIALS \
38+ --project=$GOOGLE_CLOUD_PROJECT
39+
40+ echo -e " \n******************** CHECKING FOR AFFECTED FOLDERS ********************"
41+ # Diff to find out what has changed from master
42+ cd github/getting-started-java
43+ find ./* / -name pom.xml -print0 | sort -z | while read -d $' \0' file
44+ do
45+ file=$( dirname " $file " )
46+ echo " ------------------------------------------------------------"
47+ echo " - checking $file "
48+ echo " ------------------------------------------------------------"
49+
50+
51+ pushd " $file " > /dev/null
52+ set +e
53+ git diff --quiet master.. .
54+ RTN=$?
55+ set -e
56+
57+ # Check for changes to the current folder
58+ if [ " $CHANGED " -eq 1 ] && [ " $PARENT " -eq 0 ]; then
59+ mvn -q --batch-mode --fail-at-end clean verify \
60+ -Dfile.encoding=" UTF-8" \
61+ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
62+ -Dmaven.test.redirectTestOutputToFile=true \
63+ -Dbigtable.projectID=" ${GOOGLE_CLOUD_PROJECT} " \
64+ -Dbigtable.instanceID=instance
65+ echo -e " Tests complete. \n"
66+ else
67+ echo -e " \n NO change found. \n"
68+ fi
69+
70+ popd > /dev/null
71+
72+ done
0 commit comments