Skip to content

Commit d2abcd6

Browse files
committed
ci: GraalVM CI uses existing Truststore if configured (#1914)
* chore: Enable SSL debug logs for GraalVM image * chore: Pass SSL debug config to the native image * chore: Unset the tool options * chore: Set the native image truststore directly * chore: Test runtime args for graalvm * chore: Use the execution-id * chore: latest runs * chore: Add comments to explain Original-PR: googleapis/google-auth-library-java#1914
1 parent 30088d2 commit d2abcd6

File tree

1 file changed

+159
-0
lines changed
  • google-auth-library-java/.kokoro

1 file changed

+159
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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+
# 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+
test-logging)
55+
echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}"
56+
mvn clean test -P '!slf4j2x,slf4j2x-test' -B -ntp -Dclirr.skip=true -Denforcer.skip=true ${SUREFIRE_JVM_OPT}
57+
RETURN_CODE=$?
58+
;;
59+
lint)
60+
mvn com.spotify.fmt:fmt-maven-plugin:check -B -ntp
61+
RETURN_CODE=$?
62+
;;
63+
javadoc)
64+
mvn javadoc:javadoc javadoc:test-javadoc -B -ntp
65+
RETURN_CODE=$?
66+
;;
67+
integration)
68+
mvn -B ${INTEGRATION_TEST_ARGS} \
69+
-ntp \
70+
-Penable-integration-tests \
71+
-DtrimStackTrace=false \
72+
-Dclirr.skip=true \
73+
-Denforcer.skip=true \
74+
-Djacoco.skip=true \
75+
-fae \
76+
verify
77+
RETURN_CODE=$?
78+
;;
79+
graalvm)
80+
# Run Unit and Integration Tests with Native Image
81+
bash .kokoro/populate-secrets.sh
82+
export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_GFILE_DIR}/secret_manager/java-it-service-account"
83+
84+
# GraalVM Native Image ignores JAVA_TOOL_OPTIONS at runtime. If the CI environment
85+
# injects a custom truststore (e.g., for a proxy) via JAVA_TOOL_OPTIONS, we need to
86+
# extract it and pass it explicitly to the native executable.
87+
TRUST_STORE=""
88+
if [[ "${JAVA_TOOL_OPTIONS}" =~ -Djavax.net.ssl.trustStore=([^ ]+) ]]; then
89+
TRUST_STORE="${BASH_REMATCH[1]}"
90+
fi
91+
92+
# We use 'package' instead of 'test' to build the native image without automatically
93+
# running it via the Maven plugin. This allows us to run it manually with the
94+
# extracted truststore argument in the next step, avoiding complex Maven XML overrides.
95+
mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Pnative-test -Pslf4j2x package -pl 'oauth2_http'
96+
97+
# Run the native tests manually with the truststore
98+
CMD="./oauth2_http/target/native-tests --xml-output-dir ./oauth2_http/target/native-test-reports"
99+
if [ -n "$TRUST_STORE" ]; then
100+
CMD="$CMD -Djavax.net.ssl.trustStore=$TRUST_STORE"
101+
fi
102+
103+
echo "Executing: $CMD"
104+
$CMD
105+
RETURN_CODE=$?
106+
;;
107+
samples)
108+
SAMPLES_DIR=samples
109+
# only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise.
110+
if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]]
111+
then
112+
SAMPLES_DIR=samples/snapshot
113+
fi
114+
115+
if [[ -f ${SAMPLES_DIR}/pom.xml ]]
116+
then
117+
for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do
118+
[[ -f "$FILE" ]] || continue
119+
source "$FILE"
120+
done
121+
122+
pushd ${SAMPLES_DIR}
123+
mvn -B \
124+
-ntp \
125+
-DtrimStackTrace=false \
126+
-Dclirr.skip=true \
127+
-Denforcer.skip=true \
128+
-fae \
129+
verify
130+
RETURN_CODE=$?
131+
popd
132+
else
133+
echo "no sample pom.xml found - skipping sample tests"
134+
fi
135+
;;
136+
clirr)
137+
mvn -B -ntp -Denforcer.skip=true clirr:check
138+
RETURN_CODE=$?
139+
;;
140+
*)
141+
;;
142+
esac
143+
144+
if [ "${REPORT_COVERAGE}" == "true" ]
145+
then
146+
bash ${KOKORO_GFILE_DIR}/codecov.sh
147+
fi
148+
149+
# fix output location of logs
150+
bash .kokoro/coerce_logs.sh
151+
152+
if [[ "${ENABLE_FLAKYBOT}" == "true" ]]
153+
then
154+
chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/flakybot
155+
${KOKORO_GFILE_DIR}/linux_amd64/flakybot -repo=googleapis/google-auth-library-java
156+
fi
157+
158+
echo "exiting with ${RETURN_CODE}"
159+
exit ${RETURN_CODE}

0 commit comments

Comments
 (0)