diff options
author | ckl <ckl@google.com> | 2022-02-18 13:09:32 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-02-18 13:10:45 -0800 |
commit | b829022071c14058eac425542656e8843fca5ba6 (patch) | |
tree | 9779d720a54003f8f5ae49ca15e8b2bbb9c57923 | |
parent | d04fd88a70e05ffdc12c5f351fc6dc56ab9ee381 (diff) | |
download | tink-b829022071c14058eac425542656e8843fca5ba6.tar.gz |
Add install_go.sh Kokoro test utility.
In the continuous tests, use the oldest supported minor version of Go as of the latest patch release (currently 1.16.14).
PiperOrigin-RevId: 429632365
-rw-r--r-- | kokoro/gcp_ubuntu_per_language/cross_language/run_tests.sh | 2 | ||||
-rw-r--r-- | kokoro/gcp_ubuntu_per_language/go/bazel/run_tests.sh | 2 | ||||
-rw-r--r-- | kokoro/gcp_ubuntu_per_language/go/gomod/run_tests.sh | 13 | ||||
-rw-r--r-- | kokoro/gcp_ubuntu_per_language/tools/run_tests.sh | 2 | ||||
-rw-r--r-- | kokoro/macos_external/go/bazel/run_tests.sh | 2 | ||||
-rw-r--r-- | kokoro/macos_external/go/gomod/run_tests.sh | 12 | ||||
-rw-r--r-- | kokoro/macos_external/tools/run_tests.sh | 2 | ||||
-rwxr-xr-x | kokoro/run_tests.sh | 2 | ||||
-rwxr-xr-x | kokoro/testutils/install_go.sh | 62 |
9 files changed, 87 insertions, 12 deletions
diff --git a/kokoro/gcp_ubuntu_per_language/cross_language/run_tests.sh b/kokoro/gcp_ubuntu_per_language/cross_language/run_tests.sh index 070d1d4c3..e3af898cc 100644 --- a/kokoro/gcp_ubuntu_per_language/cross_language/run_tests.sh +++ b/kokoro/gcp_ubuntu_per_language/cross_language/run_tests.sh @@ -53,6 +53,8 @@ main() { cd "${KOKORO_ARTIFACTS_DIR}/git/tink" ./kokoro/testutils/copy_credentials.sh ./kokoro/testutils/update_android_sdk.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh fi ( cd testing/cc diff --git a/kokoro/gcp_ubuntu_per_language/go/bazel/run_tests.sh b/kokoro/gcp_ubuntu_per_language/go/bazel/run_tests.sh index 353428c4c..146521b63 100644 --- a/kokoro/gcp_ubuntu_per_language/go/bazel/run_tests.sh +++ b/kokoro/gcp_ubuntu_per_language/go/bazel/run_tests.sh @@ -19,6 +19,8 @@ set -euo pipefail if [[ -n "${KOKORO_ROOT}" ]]; then cd "${KOKORO_ARTIFACTS_DIR}/git/tink" ./kokoro/testutils/copy_credentials.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh fi cd go/ diff --git a/kokoro/gcp_ubuntu_per_language/go/gomod/run_tests.sh b/kokoro/gcp_ubuntu_per_language/go/gomod/run_tests.sh index 08a419597..d6584de93 100644 --- a/kokoro/gcp_ubuntu_per_language/go/gomod/run_tests.sh +++ b/kokoro/gcp_ubuntu_per_language/go/gomod/run_tests.sh @@ -14,11 +14,17 @@ # limitations under the License. ################################################################################ - set -euo pipefail REPO_DIR="${KOKORO_ARTIFACTS_DIR}/git/tink" +( + cd "${REPO_DIR}" + ./kokoro/testutils/copy_credentials.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh +) + TINK_VERSION="$(cat ${REPO_DIR}/tink_version.bzl | grep ^TINK | cut -f 2 -d \")" # Create a temporary directory for performing module tests. @@ -31,11 +37,6 @@ REPO_URL_PREFIX="github.com/google/tink" sudo apt-get update sudo apt-get upgrade -y ca-certificates -( - cd "${REPO_DIR}" - ./kokoro/testutils/copy_credentials.sh -) - ####################################### # Test an individual Go module within the Tink repository. # Globals: diff --git a/kokoro/gcp_ubuntu_per_language/tools/run_tests.sh b/kokoro/gcp_ubuntu_per_language/tools/run_tests.sh index 77e8799fb..a1c2d689a 100644 --- a/kokoro/gcp_ubuntu_per_language/tools/run_tests.sh +++ b/kokoro/gcp_ubuntu_per_language/tools/run_tests.sh @@ -38,6 +38,8 @@ cd ${KOKORO_ARTIFACTS_DIR}/git/tink ./kokoro/testutils/copy_credentials.sh ./kokoro/testutils/update_android_sdk.sh +# Sourcing required to update callers environment. +source ./kokoro/testutils/install_go.sh cd tools use_bazel.sh $(cat .bazelversion) diff --git a/kokoro/macos_external/go/bazel/run_tests.sh b/kokoro/macos_external/go/bazel/run_tests.sh index 353428c4c..146521b63 100644 --- a/kokoro/macos_external/go/bazel/run_tests.sh +++ b/kokoro/macos_external/go/bazel/run_tests.sh @@ -19,6 +19,8 @@ set -euo pipefail if [[ -n "${KOKORO_ROOT}" ]]; then cd "${KOKORO_ARTIFACTS_DIR}/git/tink" ./kokoro/testutils/copy_credentials.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh fi cd go/ diff --git a/kokoro/macos_external/go/gomod/run_tests.sh b/kokoro/macos_external/go/gomod/run_tests.sh index a69cc8f08..2eeed595b 100644 --- a/kokoro/macos_external/go/gomod/run_tests.sh +++ b/kokoro/macos_external/go/gomod/run_tests.sh @@ -14,10 +14,15 @@ # limitations under the License. ################################################################################ - set -euo pipefail REPO_DIR="${KOKORO_ARTIFACTS_DIR}/git/tink" +( + cd "${REPO_DIR}" + ./kokoro/testutils/copy_credentials.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh +) TINK_VERSION="$(cat ${REPO_DIR}/tink_version.bzl | grep ^TINK | cut -f 2 -d \")" @@ -27,11 +32,6 @@ GO_MOD_DIR="${TMP_DIR}/go-mod-test" REPO_URL_PREFIX="github.com/google/tink" -( - cd "${REPO_DIR}" - ./kokoro/testutils/copy_credentials.sh -) - ####################################### # Test an individual Go module within the Tink repository. # Globals: diff --git a/kokoro/macos_external/tools/run_tests.sh b/kokoro/macos_external/tools/run_tests.sh index 32137ea6b..6fc2c3daf 100644 --- a/kokoro/macos_external/tools/run_tests.sh +++ b/kokoro/macos_external/tools/run_tests.sh @@ -26,6 +26,8 @@ export COURSIER_OPTS="-Djava.net.preferIPv6Addresses=true" cd "${KOKORO_ARTIFACTS_DIR}/git/tink" ./kokoro/testutils/copy_credentials.sh ./kokoro/testutils/update_android_sdk.sh +# Sourcing required to update callers environment. +source ./kokoro/testutils/install_go.sh # TODO(b/155225382): Avoid modifying the sytem Python installation. pip3 install --user protobuf diff --git a/kokoro/run_tests.sh b/kokoro/run_tests.sh index 76e39e04f..8e943ea0d 100755 --- a/kokoro/run_tests.sh +++ b/kokoro/run_tests.sh @@ -206,6 +206,8 @@ main() { ./kokoro/testutils/copy_credentials.sh ./kokoro/testutils/update_android_sdk.sh + # Sourcing required to update callers environment. + source ./kokoro/testutils/install_go.sh fi # Verify required environment variables. diff --git a/kokoro/testutils/install_go.sh b/kokoro/testutils/install_go.sh new file mode 100755 index 000000000..dda7ec28e --- /dev/null +++ b/kokoro/testutils/install_go.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright 2022 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. +################################################################################ + +# This script installs a recent version of Go into a temporary directory. The Go +# bin directory is then added to the PATH environment variable. +# +# NOTE: This script MUST be sourced to update the environment of the calling +# script. +# +# Usage instructions: +# +# source ./kokoro/testutils/install_go.sh + +install_temp_go() { + local -r go_version="1.16.14" + + local -r platform="$(uname | tr '[:upper:]' '[:lower:]')" + local go_platform + case "${platform}" in + 'linux') + go_platform='linux-amd64' + ;; + 'darwin') + go_platform='darwin-amd64' + ;; + *) + echo "Unsupported platform, unable to install Go." + exit 1 + ;; + esac + readonly go_platform + + local -r go_archive="go${go_version}.${go_platform}.tar.gz" + local -r go_url="https://go.dev/dl/${go_archive}" + + local -r go_tmpdir=$(mktemp -dt tink-go.XXXXXX) + ( + cd "${go_tmpdir}" + curl -OLsS "${go_url}" + tar -xzf "${go_archive}" + ) + + export PATH="${go_tmpdir}/go/bin:${PATH}" +} + +if [[ -n "${KOKORO_ROOT}" ]] ; then + install_temp_go +fi |