Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip integration tests if no changes #4392

Merged
merged 3 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,44 @@ set -eo pipefail

cd github/google-cloud-java/

function client_has_changes() {
CLIENT_NAME=$1
if [[ ! -z $(git diff master google-cloud-clients/google-cloud-core*) ]]; then
echo "true"
return
fi

if [[ ! -z $(git diff master google-cloud-clients/${CLIENT_NAME}) ]]; then
echo "true"
return
fi

if [[ ! -z $(git diff master google-api-grpc/*${CLIENT_NAME}*) ]]; then
echo "true"
return
fi

echo "false"
}

# Print out Java version
java -version
echo $JOB_TYPE

if [[ "${SKIP_INTEGRATION_TESTS_IF_NO_CHANGES}" == "true" ]] &&
[[ "${JOB_TYPE}" == "integration" ]]; then
CLIENT=$(echo ${INTEGRATION_TEST_ARGS} | cut -d' ' -f1 | cut -d'/' -f2)
CLIENT_HAS_CHANGES=$(client_has_changes ${CLIENT})
if [[ "${CLIENT_HAS_CHANGES}" == "false" ]]; then
echo "No difference from master, skipping tests."
exit 0
fi
fi

mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V

# prepend Kokoro root directory onto GOOGLE_APPLICATION_CREDENTIALS path
if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then
if [[ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]]; then
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_ROOT}/src/${GOOGLE_APPLICATION_CREDENTIALS})
fi

Expand Down
6 changes: 6 additions & 0 deletions .kokoro/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-java/.kokoro/build.sh"
}

# By default, always run integration tests
env_vars: {
key: "SKIP_INTEGRATION_TESTS_IF_NO_CHANGES"
value: "false"
}
14 changes: 10 additions & 4 deletions .kokoro/presubmit/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
build_file: "google-cloud-java/.kokoro/trampoline.sh"

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-cloud-java/.kokoro/build.sh"
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-cloud-java/.kokoro/build.sh"
}

env_vars: {
key: "JOB_TYPE"
value: "test"
key: "JOB_TYPE"
value: "test"
}

# For presubmits, only run integrations if the code has changed
env_vars: {
key: "SKIP_INTEGRATION_TESTS_IF_NO_CHANGES"
value: "true"
}

before_action {
Expand Down