|
| 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 | + |
| 16 | +set -eo pipefail |
| 17 | + |
| 18 | +## Get the directory of the build script |
| 19 | +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) |
| 20 | +## cd to the parent directory, i.e. the root of the git repo |
| 21 | +cd ${scriptDir}/.. |
| 22 | + |
| 23 | +# Print out Java version |
| 24 | +java -version |
| 25 | +echo ${JOB_TYPE} |
| 26 | + |
| 27 | +mvn install -B -V \ |
| 28 | + -DskipTests=true \ |
| 29 | + -Dclirr.skip=true \ |
| 30 | + -Denforcer.skip=true \ |
| 31 | + -Dmaven.javadoc.skip=true \ |
| 32 | + -Dgcloud.download.skip=true \ |
| 33 | + -T 1C |
| 34 | + |
| 35 | +# if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it |
| 36 | +if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then |
| 37 | + export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_ROOT}/src/${GOOGLE_APPLICATION_CREDENTIALS}) |
| 38 | +fi |
| 39 | + |
| 40 | +RETURN_CODE=0 |
| 41 | +set +e |
| 42 | + |
| 43 | +case ${JOB_TYPE} in |
| 44 | +test) |
| 45 | + mvn test -B -Dclirr.skip=true -Denforcer.skip=true |
| 46 | + RETURN_CODE=$? |
| 47 | + ;; |
| 48 | +lint) |
| 49 | + mvn \ |
| 50 | + -Penable-samples \ |
| 51 | + com.coveo:fmt-maven-plugin:check |
| 52 | + RETURN_CODE=$? |
| 53 | + ;; |
| 54 | +javadoc) |
| 55 | + mvn javadoc:javadoc javadoc:test-javadoc |
| 56 | + RETURN_CODE=$? |
| 57 | + ;; |
| 58 | +integration) |
| 59 | + mvn -B ${INTEGRATION_TEST_ARGS} \ |
| 60 | + -Penable-integration-tests \ |
| 61 | + -DtrimStackTrace=false \ |
| 62 | + -Dclirr.skip=true \ |
| 63 | + -Denforcer.skip=true \ |
| 64 | + -fae \ |
| 65 | + verify |
| 66 | + RETURN_CODE=$? |
| 67 | + ;; |
| 68 | +samples) |
| 69 | + if [[ -f samples/pom.xml ]] |
| 70 | + then |
| 71 | + pushd samples |
| 72 | + mvn -B \ |
| 73 | + -Penable-samples \ |
| 74 | + -DtrimStackTrace=false \ |
| 75 | + -Dclirr.skip=true \ |
| 76 | + -Denforcer.skip=true \ |
| 77 | + -fae \ |
| 78 | + verify |
| 79 | + RETURN_CODE=$? |
| 80 | + popd |
| 81 | + else |
| 82 | + echo "no sample pom.xml found - skipping sample tests" |
| 83 | + fi |
| 84 | + ;; |
| 85 | +clirr) |
| 86 | + mvn -B -Denforcer.skip=true clirr:check |
| 87 | + RETURN_CODE=$? |
| 88 | + ;; |
| 89 | +*) |
| 90 | + ;; |
| 91 | +esac |
| 92 | + |
| 93 | +if [ "${REPORT_COVERAGE}" == "true" ] |
| 94 | +then |
| 95 | + bash ${KOKORO_GFILE_DIR}/codecov.sh |
| 96 | +fi |
| 97 | + |
| 98 | +# fix output location of logs |
| 99 | +bash .kokoro/coerce_logs.sh |
| 100 | + |
| 101 | +if [[ "${ENABLE_BUILD_COP}" == "true" ]] |
| 102 | +then |
| 103 | + chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/buildcop |
| 104 | + ${KOKORO_GFILE_DIR}/linux_amd64/buildcop -repo=googleapis/java-memcache |
| 105 | +fi |
| 106 | + |
| 107 | +echo "exiting with ${RETURN_CODE}" |
| 108 | +exit ${RETURN_CODE} |
0 commit comments