Skip to content

Commit f59dbf4

Browse files
feat: add kokoro jobs for samples module (#61)
* update based on comments * feat: add kokoro builds for samples module * simplify build script for samples * add samples builds to nightly and presubmit runs
1 parent 866659a commit f59dbf4

File tree

8 files changed

+232
-0
lines changed

8 files changed

+232
-0
lines changed

‎.kokoro/common.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Format: //devtools/kokoro/config/proto/build.proto
22

3+
# Download secrets from Cloud Storage.
4+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java-docs-samples"
5+
36
# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
47
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
58

‎.kokoro/continuous/java11-samples.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
21+
}
22+
23+
# Tell the trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-docs-samples/.kokoro/run_samples_tests.sh"
27+
}

‎.kokoro/continuous/java8-samples.cfg

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
21+
}
22+
23+
# Tell trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-bigquery/.kokoro/run_samples_tests.sh"
27+
}
28+
29+
30+

‎.kokoro/nightly/java11-samples.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
21+
}
22+
23+
# Tell the trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-docs-samples/.kokoro/run_samples_tests.sh"
27+
}

‎.kokoro/nightly/java8-samples.cfg

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
21+
}
22+
23+
# Tell trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-bigquery/.kokoro/run_samples_tests.sh"
27+
}
28+
29+
30+

‎.kokoro/presubmit/java11-samples.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
21+
}
22+
23+
# Tell the trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-docs-samples/.kokoro/run_samples_tests.sh"
27+
}

‎.kokoro/presubmit/java8-samples.cfg

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019 Google LLC
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+
# Configure the docker image for kokoro-trampoline.
18+
env_vars: {
19+
key: "TRAMPOLINE_IMAGE"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
21+
}
22+
23+
# Tell trampoline which tests to run.
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/java-bigquery/.kokoro/run_samples_tests.sh"
27+
}
28+
29+
30+

‎.kokoro/run_samples_tests.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
# Copyright 2019 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+
# `-e` enables the script to automatically fail when a command fails
17+
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
18+
set -eo pipefail
19+
# Enables `**` to include files nested inside sub-folders
20+
shopt -s globstar
21+
22+
# Update `gcloud` and log versioning for debugging.
23+
gcloud components install beta --quiet
24+
gcloud components update --quiet
25+
echo "********** GCLOUD INFO ***********"
26+
gcloud -v
27+
echo "********** MAVEN INFO ***********"
28+
mvn -v
29+
30+
# Setup required env variables
31+
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
32+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
33+
export GCS_BUCKET=java-docs-samples-testing
34+
35+
# Activate service account
36+
gcloud auth activate-service-account \
37+
--key-file="$GOOGLE_APPLICATION_CREDENTIALS" \
38+
--project="$GOOGLE_CLOUD_PROJECT"
39+
40+
# Get the directory of the build script
41+
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
42+
# Move into the samples directory
43+
cd ${scriptDir}/../samples/
44+
45+
echo -e "\n******************** RUNNING SAMPLE TESTS ********************"
46+
RTN=0
47+
48+
mvn --fail-at-end clean verify
49+
50+
EXIT=$?
51+
if [[ $EXIT -ne 0 ]]; then
52+
RTN=1
53+
echo -e "\n Testing failed: Maven returned a non-zero exit code. \n"
54+
else
55+
echo -e "\n Testing completed.\n"
56+
fi
57+
58+
exit "$RTN"

0 commit comments

Comments
 (0)