Skip to content

Commit a444fed

Browse files
committed
Merge branch 'diff-tests' into dpebot-repositorygardener
2 parents 7cc4633 + b75f200 commit a444fed

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

.kokoro/tests/diff_tests.sh

+15-14
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ shopt -s globstar
1919
trap '' HUP
2020

2121
# Update gcloud and check version
22-
gcloud components update --quiet
22+
gcloud components update --quiet --verbosity="error"
2323
echo -e "\n ********** GCLOUD INFO *********** \n"
2424
gcloud -v
2525
echo -e "\n ********** MAVEN INFO *********** \n"
2626
mvn -v
2727
echo -e "\n ********** GRADLE INFO *********** "
2828
gradle -v
2929

30-
# Setup required enviormental variables
30+
# Setup required environmental variables
3131
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
3232
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
3333
source ${KOKORO_GFILE_DIR}/aws-secrets.sh
@@ -37,35 +37,36 @@ gcloud auth activate-service-account\
3737
--key-file=$GOOGLE_APPLICATION_CREDENTIALS \
3838
--project=$GOOGLE_CLOUD_PROJECT
3939

40-
echo -e "\n******************** CHECKING FOR AFFECTED FOLDERS ********************"
40+
echo -e "\n******************** TESTING AFFECTED PROJECTS ********************"
4141
# Diff to find out what has changed from master
4242
cd github/java-docs-samples
43-
find ./*/ -name pom.xml -print0 | sort -z | while read -d $'\0' file
43+
find * -name pom.xml -print0 | sort -z | while read -d $'\0' file
4444
do
45-
file=$(dirname "$file")
46-
echo "------------------------------------------------------------"
47-
echo "- checking $file"
48-
echo "------------------------------------------------------------"
49-
5045

46+
# Navigate to project
5147
pushd "$file" > /dev/null
5248
set +e
49+
# Has the project changed?
5350
git diff --quiet master.. .
54-
RTN=$?
51+
CHANGED=$?
52+
# Skip parents so the projects aren't tested twice
53+
PARENT=$(grep "<modules>" pom.xml -c)
5554
set -e
5655

5756
# Check for changes to the current folder
58-
if [ "$RTN" -eq 1 ]; then
59-
echo -e "\n Change detected. Running tests. \n "
57+
if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then
58+
file=$(dirname "$file")
59+
echo "------------------------------------------------------------"
60+
echo "- testing $file"
61+
echo "------------------------------------------------------------"
62+
6063
mvn -q --batch-mode --fail-at-end clean verify \
6164
-Dfile.encoding="UTF-8" \
6265
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
6366
-Dmaven.test.redirectTestOutputToFile=true \
6467
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
6568
-Dbigtable.instanceID=instance
6669
echo -e " Tests complete. \n"
67-
else
68-
echo -e "\n NO change found. \n"
6970
fi
7071

7172
popd > /dev/null

0 commit comments

Comments
 (0)