Skip to content

Commit 9f681c2

Browse files
authored
Initial Kokoro checkin (#807)
* Initial Kokoro checkin * Fix a typo
1 parent ba3eb53 commit 9f681c2

File tree

4 files changed

+169
-0
lines changed

4 files changed

+169
-0
lines changed

.kokoro/common.cfg

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2017 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Format: //devtools/kokoro/config/proto/build.proto
16+
17+
# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
18+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
19+
20+
# All builds use the trampoline script to run in docker.
21+
build_file: "java-docs-samples/.kokoro/trampoline.sh"
22+
23+
# Configure the docker image for kokoro-trampoline.
24+
env_vars: {
25+
key: "TRAMPOLINE_IMAGE"
26+
value: "gcr.io/cloud-devrel-kokoro-resources/java"
27+
}

.kokoro/system_tests.cfg

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2017 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Format: //devtools/kokoro/config/proto/build.proto
16+
17+
# Download secrets from Cloud Storage.
18+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java-docs-samples"
19+
20+
# Tell the trampoline which build file to use.
21+
env_vars: {
22+
key: "TRAMPOLINE_BUILD_FILE"
23+
value: "github/java-docs-samples/.kokoro/system_tests.sh"
24+
}

.kokoro/system_tests.sh

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
# Copyright 2017 Google Inc.
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+
shopt -s globstar
18+
19+
set -xe
20+
# We spin up some subprocesses. Don't kill them on hangup
21+
trap '' HUP
22+
23+
# Temporary directory to store any output to display on error
24+
export ERROR_OUTPUT_DIR
25+
ERROR_OUTPUT_DIR="$(mktemp -d)"
26+
trap 'rm -r "${ERROR_OUTPUT_DIR}"' EXIT
27+
28+
delete_app_version() {
29+
yes | gcloud --project="${GOOGLE_PROJECT_ID}" \
30+
app versions delete "${1}"
31+
}
32+
33+
handle_error() {
34+
errcode=$? # Remember the error code so we can exit with it after cleanup
35+
36+
# Clean up remote app version
37+
delete_app_version "${1}" &
38+
39+
# Display any errors
40+
if [ -n "$(find "${2}" -mindepth 1 -print -quit)" ]; then
41+
cat "${2:?}"/* 1>&2
42+
fi
43+
44+
wait
45+
46+
exit ${errcode}
47+
}
48+
49+
cleanup() {
50+
delete_app_version "${GOOGLE_VERSION_ID}" &
51+
( [ -d "${ERROR_OUTPUT_DIR}" ] && rm -r "${ERROR_OUTPUT_DIR:?}/"* ) || /bin/true
52+
}
53+
54+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
55+
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
56+
export PATH=/google-cloud-sdk/bin:$PATH
57+
58+
echo "******** Environment *********"
59+
env
60+
echo "******** mvn & Java *********"
61+
mvn -version
62+
63+
echo "Update gcloud ********"
64+
gcloud components update --quiet
65+
66+
echo "******** activate-service-account ********"
67+
ls -lr ${KOKORO_GFILE_DIR}
68+
69+
gcloud auth activate-service-account\
70+
--key-file=$GOOGLE_APPLICATION_CREDENTIALS \
71+
--project=$GOOGLE_CLOUD_PROJECT
72+
73+
echo "********* gcloud config ********"
74+
gcloud config list
75+
76+
echo "******** build everything ********"
77+
cd github/java-docs-samples
78+
mvn clean verify | grep -E -v "(^\[INFO\] Download|^\[INFO\].*skipping)"
79+
80+
81+
# (
82+
# # Stop echoing commands, so we don't leak secret env vars
83+
# # -Pselenium | \ # LV3 20170616 turn off selenium for now.
84+
# set +x
85+
# mvn --batch-mode clean verify \
86+
# -Dbookshelf.clientID="${OAUTH2_CLIENT_ID}" \
87+
# -Dbookshelf.clientSecret="${OAUTH2_CLIENT_SECRET}" \
88+
# -Dbookshelf.bucket="${GCS_BUCKET envvar is unset}" \
89+
# | \
90+
# grep -E -v "(^\[INFO\] Download|^\[INFO\].*skipping)"
91+
# )
92+
#
93+
# Test running samples on localhost.
94+
# git clone https://github.com/GoogleCloudPlatform/java-repo-tools.git
95+
# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-jsp -- -DskipTests=true
96+
# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-servlet -- -DskipTests=true
97+
# ./java-repo-tools/scripts/test-localhost.sh jetty helloworld-compat -- -DskipTests=true
98+
# ./java-repo-tools/scripts/test-localhost.sh spring-boot helloworld-springboot -- -DskipTests=true
99+
100+
# Check that all shell scripts in this repo (including this one) pass the
101+
Shell Check linter.
102+
shellcheck ./**/*.sh

.kokoro/trampoline.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# Copyright 2017 Google Inc.
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+
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"

0 commit comments

Comments
 (0)