Skip to content

Commit

Permalink
Merge branch 'diff-tests' into dpebot-repositorygardener
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisvg committed Feb 14, 2018
2 parents 7cc4633 + b75f200 commit a444fed
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions .kokoro/tests/diff_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ shopt -s globstar
trap '' HUP

# Update gcloud and check version
gcloud components update --quiet
gcloud components update --quiet --verbosity="error"
echo -e "\n ********** GCLOUD INFO *********** \n"
gcloud -v
echo -e "\n ********** MAVEN INFO *********** \n"
mvn -v
echo -e "\n ********** GRADLE INFO *********** "
gradle -v

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

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


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

# Check for changes to the current folder
if [ "$RTN" -eq 1 ]; then
echo -e "\n Change detected. Running tests. \n "
if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then
file=$(dirname "$file")
echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

mvn -q --batch-mode --fail-at-end clean verify \
-Dfile.encoding="UTF-8" \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dmaven.test.redirectTestOutputToFile=true \
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
-Dbigtable.instanceID=instance
echo -e " Tests complete. \n"
else
echo -e "\n NO change found. \n"
fi

popd > /dev/null
Expand Down

0 comments on commit a444fed

Please sign in to comment.