From f59dbf439788137ae4fe5215687c47b287b64ab9 Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 30 Dec 2019 18:37:23 -0500 Subject: [PATCH] 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 --- .kokoro/common.cfg | 3 ++ .kokoro/continuous/java11-samples.cfg | 27 +++++++++++++ .kokoro/continuous/java8-samples.cfg | 30 ++++++++++++++ .kokoro/nightly/java11-samples.cfg | 27 +++++++++++++ .kokoro/nightly/java8-samples.cfg | 30 ++++++++++++++ .kokoro/presubmit/java11-samples.cfg | 27 +++++++++++++ .kokoro/presubmit/java8-samples.cfg | 30 ++++++++++++++ .kokoro/run_samples_tests.sh | 58 +++++++++++++++++++++++++++ 8 files changed, 232 insertions(+) create mode 100644 .kokoro/continuous/java11-samples.cfg create mode 100644 .kokoro/continuous/java8-samples.cfg create mode 100644 .kokoro/nightly/java11-samples.cfg create mode 100644 .kokoro/nightly/java8-samples.cfg create mode 100644 .kokoro/presubmit/java11-samples.cfg create mode 100644 .kokoro/presubmit/java8-samples.cfg create mode 100644 .kokoro/run_samples_tests.sh diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 24a5c6b19..274ab26d0 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -1,5 +1,8 @@ # Format: //devtools/kokoro/config/proto/build.proto +# Download secrets from Cloud Storage. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java-docs-samples" + # Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" diff --git a/.kokoro/continuous/java11-samples.cfg b/.kokoro/continuous/java11-samples.cfg new file mode 100644 index 000000000..673ef81d8 --- /dev/null +++ b/.kokoro/continuous/java11-samples.cfg @@ -0,0 +1,27 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} + +# Tell the trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/run_samples_tests.sh" +} \ No newline at end of file diff --git a/.kokoro/continuous/java8-samples.cfg b/.kokoro/continuous/java8-samples.cfg new file mode 100644 index 000000000..b75d587fb --- /dev/null +++ b/.kokoro/continuous/java8-samples.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +# Tell trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-bigquery/.kokoro/run_samples_tests.sh" +} + + + diff --git a/.kokoro/nightly/java11-samples.cfg b/.kokoro/nightly/java11-samples.cfg new file mode 100644 index 000000000..673ef81d8 --- /dev/null +++ b/.kokoro/nightly/java11-samples.cfg @@ -0,0 +1,27 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} + +# Tell the trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/run_samples_tests.sh" +} \ No newline at end of file diff --git a/.kokoro/nightly/java8-samples.cfg b/.kokoro/nightly/java8-samples.cfg new file mode 100644 index 000000000..b75d587fb --- /dev/null +++ b/.kokoro/nightly/java8-samples.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +# Tell trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-bigquery/.kokoro/run_samples_tests.sh" +} + + + diff --git a/.kokoro/presubmit/java11-samples.cfg b/.kokoro/presubmit/java11-samples.cfg new file mode 100644 index 000000000..673ef81d8 --- /dev/null +++ b/.kokoro/presubmit/java11-samples.cfg @@ -0,0 +1,27 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} + +# Tell the trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/run_samples_tests.sh" +} \ No newline at end of file diff --git a/.kokoro/presubmit/java8-samples.cfg b/.kokoro/presubmit/java8-samples.cfg new file mode 100644 index 000000000..b75d587fb --- /dev/null +++ b/.kokoro/presubmit/java8-samples.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +# Tell trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-bigquery/.kokoro/run_samples_tests.sh" +} + + + diff --git a/.kokoro/run_samples_tests.sh b/.kokoro/run_samples_tests.sh new file mode 100644 index 000000000..dc6929f00 --- /dev/null +++ b/.kokoro/run_samples_tests.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright 2019 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# `-e` enables the script to automatically fail when a command fails +# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero +set -eo pipefail +# Enables `**` to include files nested inside sub-folders +shopt -s globstar + +# Update `gcloud` and log versioning for debugging. +gcloud components install beta --quiet +gcloud components update --quiet +echo "********** GCLOUD INFO ***********" +gcloud -v +echo "********** MAVEN INFO ***********" +mvn -v + +# Setup required env variables +export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json +export GCS_BUCKET=java-docs-samples-testing + +# Activate service account +gcloud auth activate-service-account \ + --key-file="$GOOGLE_APPLICATION_CREDENTIALS" \ + --project="$GOOGLE_CLOUD_PROJECT" + +# Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +# Move into the samples directory +cd ${scriptDir}/../samples/ + +echo -e "\n******************** RUNNING SAMPLE TESTS ********************" +RTN=0 + +mvn --fail-at-end clean verify + +EXIT=$? +if [[ $EXIT -ne 0 ]]; then + RTN=1 + echo -e "\n Testing failed: Maven returned a non-zero exit code. \n" +else + echo -e "\n Testing completed.\n" +fi + +exit "$RTN" \ No newline at end of file