|
1 | 1 | #!/bin/bash
|
2 |
| -# Copyright 2019 Google LLC |
| 2 | + |
| 3 | +# Copyright 2018 Google LLC |
3 | 4 | #
|
4 | 5 | # Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 6 | # you may not use this file except in compliance with the License.
|
6 | 7 | # You may obtain a copy of the License at
|
7 | 8 | #
|
8 |
| -# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
9 | 10 | #
|
10 | 11 | # Unless required by applicable law or agreed to in writing, software
|
11 | 12 | # distributed under the License is distributed on an "AS IS" BASIS,
|
|
15 | 16 |
|
16 | 17 | set -eo pipefail
|
17 | 18 |
|
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 |
| -# include common functions |
24 |
| -source ${scriptDir}/common.sh |
25 |
| - |
26 |
| -# Print out Maven & Java version |
27 |
| -mvn -version |
28 |
| -echo ${JOB_TYPE} |
29 |
| - |
30 |
| -# attempt to install 3 times with exponential backoff (starting with 10 seconds) |
31 |
| -retry_with_backoff 3 10 \ |
32 |
| - mvn install -B -V -ntp \ |
33 |
| - -DskipTests=true \ |
34 |
| - -Dclirr.skip=true \ |
35 |
| - -Denforcer.skip=true \ |
36 |
| - -Dmaven.javadoc.skip=true \ |
37 |
| - -Dgcloud.download.skip=true \ |
38 |
| - -T 1C |
39 |
| - |
40 |
| -# if GOOGLE_APPLICATION_CREDENTIALS is specified as a relative path, prepend Kokoro root directory onto it |
41 |
| -if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then |
42 |
| - export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) |
43 |
| -fi |
44 |
| - |
45 |
| -RETURN_CODE=0 |
46 |
| -set +e |
47 |
| - |
48 |
| -case ${JOB_TYPE} in |
49 |
| -test) |
50 |
| - echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}" |
51 |
| - mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true ${SUREFIRE_JVM_OPT} |
52 |
| - RETURN_CODE=$? |
53 |
| - ;; |
54 |
| -lint) |
55 |
| - mvn com.coveo:fmt-maven-plugin:check -B -ntp |
56 |
| - RETURN_CODE=$? |
57 |
| - ;; |
58 |
| -javadoc) |
59 |
| - mvn javadoc:javadoc javadoc:test-javadoc -B -ntp |
60 |
| - RETURN_CODE=$? |
61 |
| - ;; |
62 |
| -integration) |
63 |
| - mvn -B ${INTEGRATION_TEST_ARGS} \ |
64 |
| - -ntp \ |
65 |
| - -Penable-integration-tests \ |
66 |
| - -DtrimStackTrace=false \ |
67 |
| - -Dclirr.skip=true \ |
68 |
| - -Denforcer.skip=true \ |
69 |
| - -fae \ |
70 |
| - verify |
71 |
| - RETURN_CODE=$? |
72 |
| - ;; |
73 |
| -graalvm) |
74 |
| - # Run Unit and Integration Tests with Native Image |
75 |
| - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test |
76 |
| - RETURN_CODE=$? |
77 |
| - ;; |
78 |
| -graalvm17) |
79 |
| - # Run Unit and Integration Tests with Native Image |
80 |
| - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test |
81 |
| - RETURN_CODE=$? |
82 |
| - ;; |
83 |
| -samples) |
84 |
| - SAMPLES_DIR=samples |
85 |
| - # only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise. |
86 |
| - if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]] |
87 |
| - then |
88 |
| - SAMPLES_DIR=samples/snapshot |
89 |
| - fi |
90 |
| - |
91 |
| - if [[ -f ${SAMPLES_DIR}/pom.xml ]] |
92 |
| - then |
93 |
| - for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do |
94 |
| - [[ -f "$FILE" ]] || continue |
95 |
| - source "$FILE" |
96 |
| - done |
97 |
| - |
98 |
| - pushd ${SAMPLES_DIR} |
99 |
| - mvn -B \ |
100 |
| - -ntp \ |
101 |
| - -DtrimStackTrace=false \ |
102 |
| - -Dclirr.skip=true \ |
103 |
| - -Denforcer.skip=true \ |
104 |
| - -fae \ |
105 |
| - verify |
106 |
| - RETURN_CODE=$? |
107 |
| - popd |
108 |
| - else |
109 |
| - echo "no sample pom.xml found - skipping sample tests" |
110 |
| - fi |
111 |
| - ;; |
112 |
| -clirr) |
113 |
| - mvn -B -ntp -Denforcer.skip=true clirr:check |
114 |
| - RETURN_CODE=$? |
115 |
| - ;; |
116 |
| -*) |
117 |
| - ;; |
118 |
| -esac |
119 |
| - |
120 |
| -if [ "${REPORT_COVERAGE}" == "true" ] |
121 |
| -then |
122 |
| - bash ${KOKORO_GFILE_DIR}/codecov.sh |
123 |
| -fi |
| 19 | +cd github/synthtool |
124 | 20 |
|
125 |
| -# fix output location of logs |
126 |
| -bash .kokoro/coerce_logs.sh |
| 21 | +# Disable buffering, so that the logs stream through. |
| 22 | +export PYTHONUNBUFFERED=1 |
127 | 23 |
|
128 |
| -if [[ "${ENABLE_FLAKYBOT}" == "true" ]] |
129 |
| -then |
130 |
| - chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/flakybot |
131 |
| - ${KOKORO_GFILE_DIR}/linux_amd64/flakybot -repo={{metadata['repo']['repo']}} |
132 |
| -fi |
| 24 | +# Run tests |
| 25 | +nox -s lint test |
133 | 26 |
|
134 |
| -echo "exiting with ${RETURN_CODE}" |
135 |
| -exit ${RETURN_CODE} |
| 27 | +# remove all files, preventing kokoro from trying to sync them. |
| 28 | +rm -rf * |
0 commit comments