1#!/bin/bash 2# Copyright 2019 Google LLC 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 16set -eo pipefail 17 18## Get the directory of the build script 19scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 20## cd to the parent directory, i.e. the root of the git repo 21cd ${scriptDir}/.. 22 23# include common functions 24source ${scriptDir}/common.sh 25 26# Use GCP Maven Mirror 27mkdir -p ${HOME}/.m2 28cp settings.xml ${HOME}/.m2 29 30setup_application_credentials 31 32if [ -f "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secrets" ]; then 33 source "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secrets" 34fi 35 36RETURN_CODE=0 37 38case ${JOB_TYPE} in 39 test) 40 retry_with_backoff 3 10 \ 41 mvn -B -ntp \ 42 -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS \ 43 -Dclirr.skip=true \ 44 -Denforcer.skip=true \ 45 -Dcheckstyle.skip=true \ 46 -Dflatten.skip=true \ 47 -Danimal.sniffer.skip=true \ 48 -Dmaven.wagon.http.retryHandler.count=5 \ 49 -T 1C \ 50 test 51 RETURN_CODE=$? 52 echo "Finished running unit tests" 53 ;; 54 integration) 55 generate_modified_modules_list 56 if [[ ${#modified_module_list[@]} -gt 0 ]]; then 57 module_list=$( 58 IFS=, 59 echo "${modified_module_list[*]}" 60 ) 61 setup_cloud "$module_list" 62 install_modules 63 run_integration_tests "$module_list" 64 else 65 echo "No Integration Tests to run" 66 fi 67 ;; 68 graalvm-presubmit) 69 if [ -z "${MAVEN_MODULES}" ]; then 70 echo "MAVEN_MODULES not defined in environment." 71 exit 1 72 fi 73 printf "Running GraalVM checks for:\n%s\n" "${MAVEN_MODULES}" 74 setup_cloud "$MAVEN_MODULES" 75 install_modules 76 run_graalvm_tests "$MAVEN_MODULES" 77 ;; 78 graalvm) 79 generate_graalvm_modules_list 80 if [ ! -z "${module_list}" ]; then 81 printf "Running GraalVM checks for:\n%s\n" "${module_list}" 82 setup_cloud "$module_list" 83 install_modules 84 run_graalvm_tests "$module_list" 85 else 86 echo "Not running GraalVM checks -- No changes in relevant modules" 87 fi 88 ;; 89 graalvm17) 90 generate_graalvm_modules_list 91 if [ ! -z "${module_list}" ]; then 92 printf "Running GraalVM 17 checks for:\n%s\n" "${module_list}" 93 setup_cloud "$module_list" 94 install_modules 95 run_graalvm_tests "$module_list" 96 else 97 echo "Not running GraalVM 17 checks -- No changes in relevant modules" 98 fi 99 ;; 100 *) ;; 101 102esac 103 104if [ "${REPORT_COVERAGE}" == "true" ]; then 105 bash ${KOKORO_GFILE_DIR}/codecov.sh 106fi 107 108# fix output location of logs 109bash .kokoro/coerce_logs.sh 110 111if [[ "${ENABLE_FLAKYBOT}" == "true" ]]; then 112 chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/flakybot 113 ${KOKORO_GFILE_DIR}/linux_amd64/flakybot -repo=googleapis/google-cloud-java 114fi 115 116echo "exiting with ${RETURN_CODE}" 117exit ${RETURN_CODE} 118