1*af546375SCole Faust#!/bin/bash 2*af546375SCole Faust# Copyright 2019 Google LLC 3*af546375SCole Faust# 4*af546375SCole Faust# Licensed under the Apache License, Version 2.0 (the "License"); 5*af546375SCole Faust# you may not use this file except in compliance with the License. 6*af546375SCole Faust# You may obtain a copy of the License at 7*af546375SCole Faust# 8*af546375SCole Faust# http://www.apache.org/licenses/LICENSE-2.0 9*af546375SCole Faust# 10*af546375SCole Faust# Unless required by applicable law or agreed to in writing, software 11*af546375SCole Faust# distributed under the License is distributed on an "AS IS" BASIS, 12*af546375SCole Faust# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*af546375SCole Faust# See the License for the specific language governing permissions and 14*af546375SCole Faust# limitations under the License. 15*af546375SCole Faust 16*af546375SCole Faustset -eo pipefail 17*af546375SCole Faust 18*af546375SCole Faust## Get the directory of the build script 19*af546375SCole FaustscriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 20*af546375SCole Faust## cd to the parent directory, i.e. the root of the git repo 21*af546375SCole Faustcd ${scriptDir}/.. 22*af546375SCole Faust 23*af546375SCole Faust# include common functions 24*af546375SCole Faustsource ${scriptDir}/common.sh 25*af546375SCole Faust 26*af546375SCole Faust# Print out Maven & Java version 27*af546375SCole Faustmvn -version 28*af546375SCole Faustecho ${JOB_TYPE} 29*af546375SCole Faust 30*af546375SCole Faust# attempt to install 3 times with exponential backoff (starting with 10 seconds) 31*af546375SCole Faustretry_with_backoff 3 10 \ 32*af546375SCole Faust mvn install -B -V -ntp \ 33*af546375SCole Faust -DskipTests=true \ 34*af546375SCole Faust -Dclirr.skip=true \ 35*af546375SCole Faust -Denforcer.skip=true \ 36*af546375SCole Faust -Dmaven.javadoc.skip=true \ 37*af546375SCole Faust -Dgcloud.download.skip=true \ 38*af546375SCole Faust -T 1C 39*af546375SCole Faust 40*af546375SCole Faust# if GOOGLE_APPLICATION_CREDENTIALS is specified as a relative path, prepend Kokoro root directory onto it 41*af546375SCole Faustif [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then 42*af546375SCole Faust export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) 43*af546375SCole Faustfi 44*af546375SCole Faust 45*af546375SCole FaustRETURN_CODE=0 46*af546375SCole Faustset +e 47*af546375SCole Faust 48*af546375SCole Faustcase ${JOB_TYPE} in 49*af546375SCole Fausttest) 50*af546375SCole Faust echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}" 51*af546375SCole Faust mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true ${SUREFIRE_JVM_OPT} 52*af546375SCole Faust RETURN_CODE=$? 53*af546375SCole Faust ;; 54*af546375SCole Faustlint) 55*af546375SCole Faust mvn com.coveo:fmt-maven-plugin:check -B -ntp 56*af546375SCole Faust RETURN_CODE=$? 57*af546375SCole Faust ;; 58*af546375SCole Faustjavadoc) 59*af546375SCole Faust mvn javadoc:javadoc javadoc:test-javadoc -B -ntp 60*af546375SCole Faust RETURN_CODE=$? 61*af546375SCole Faust ;; 62*af546375SCole Faustintegration) 63*af546375SCole Faust mvn -B ${INTEGRATION_TEST_ARGS} \ 64*af546375SCole Faust -ntp \ 65*af546375SCole Faust -Penable-integration-tests \ 66*af546375SCole Faust -DtrimStackTrace=false \ 67*af546375SCole Faust -Dclirr.skip=true \ 68*af546375SCole Faust -Denforcer.skip=true \ 69*af546375SCole Faust -fae \ 70*af546375SCole Faust verify 71*af546375SCole Faust RETURN_CODE=$? 72*af546375SCole Faust ;; 73*af546375SCole FaustgraalvmA) 74*af546375SCole Faust # Run Unit and Integration Tests with Native Image 75*af546375SCole Faust mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Pnative-test test -pl 'oauth2_http' 76*af546375SCole Faust RETURN_CODE=$? 77*af546375SCole Faust ;; 78*af546375SCole FaustgraalvmB) 79*af546375SCole Faust # Run Unit and Integration Tests with Native Image 80*af546375SCole Faust mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Pnative-test test -pl 'oauth2_http' 81*af546375SCole Faust RETURN_CODE=$? 82*af546375SCole Faust ;; 83*af546375SCole Faustsamples) 84*af546375SCole Faust SAMPLES_DIR=samples 85*af546375SCole Faust # only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise. 86*af546375SCole Faust if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]] 87*af546375SCole Faust then 88*af546375SCole Faust SAMPLES_DIR=samples/snapshot 89*af546375SCole Faust fi 90*af546375SCole Faust 91*af546375SCole Faust if [[ -f ${SAMPLES_DIR}/pom.xml ]] 92*af546375SCole Faust then 93*af546375SCole Faust for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do 94*af546375SCole Faust [[ -f "$FILE" ]] || continue 95*af546375SCole Faust source "$FILE" 96*af546375SCole Faust done 97*af546375SCole Faust 98*af546375SCole Faust pushd ${SAMPLES_DIR} 99*af546375SCole Faust mvn -B \ 100*af546375SCole Faust -ntp \ 101*af546375SCole Faust -DtrimStackTrace=false \ 102*af546375SCole Faust -Dclirr.skip=true \ 103*af546375SCole Faust -Denforcer.skip=true \ 104*af546375SCole Faust -fae \ 105*af546375SCole Faust verify 106*af546375SCole Faust RETURN_CODE=$? 107*af546375SCole Faust popd 108*af546375SCole Faust else 109*af546375SCole Faust echo "no sample pom.xml found - skipping sample tests" 110*af546375SCole Faust fi 111*af546375SCole Faust ;; 112*af546375SCole Faustclirr) 113*af546375SCole Faust mvn -B -ntp -Denforcer.skip=true clirr:check 114*af546375SCole Faust RETURN_CODE=$? 115*af546375SCole Faust ;; 116*af546375SCole Faust*) 117*af546375SCole Faust ;; 118*af546375SCole Faustesac 119*af546375SCole Faust 120*af546375SCole Faustif [ "${REPORT_COVERAGE}" == "true" ] 121*af546375SCole Faustthen 122*af546375SCole Faust bash ${KOKORO_GFILE_DIR}/codecov.sh 123*af546375SCole Faustfi 124*af546375SCole Faust 125*af546375SCole Faust# fix output location of logs 126*af546375SCole Faustbash .kokoro/coerce_logs.sh 127*af546375SCole Faust 128*af546375SCole Faustif [[ "${ENABLE_FLAKYBOT}" == "true" ]] 129*af546375SCole Faustthen 130*af546375SCole Faust chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/flakybot 131*af546375SCole Faust ${KOKORO_GFILE_DIR}/linux_amd64/flakybot -repo=googleapis/google-auth-library-java 132*af546375SCole Faustfi 133*af546375SCole Faust 134*af546375SCole Faustecho "exiting with ${RETURN_CODE}" 135*af546375SCole Faustexit ${RETURN_CODE} 136