diff --git a/kokoro/gcp_ubuntu/bazel/run_tests.sh b/kokoro/gcp_ubuntu/bazel/run_tests.sh index c0c5e09..2ae38a7 100644 --- a/kokoro/gcp_ubuntu/bazel/run_tests.sh +++ b/kokoro/gcp_ubuntu/bazel/run_tests.sh @@ -31,22 +31,17 @@ readonly GITHUB_ORG="https://github.com/tink-crypto" RUN_COMMAND_ARGS=() if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]] ; then - TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - source \ - "${TINK_BASE_DIR}/tink_java_gcpkms/kokoro/testutils/java_test_container_images.sh" + readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" + cd "${TINK_BASE_DIR}/tink_java_gcpkms" + source ./kokoro/testutils/java_test_container_images.sh CONTAINER_IMAGE="${TINK_JAVA_BASE_IMAGE}" RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" ) fi -: "${TINK_BASE_DIR:=$(cd .. && pwd)}" -readonly TINK_BASE_DIR readonly CONTAINER_IMAGE if [[ -n "${CONTAINER_IMAGE:-}" ]]; then RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) fi -readonly RUN_COMMAND_ARGS - -cd "${TINK_BASE_DIR}/tink_java_gcpkms" # Check for dependencies in TINK_BASE_DIR. Any that aren't present will be # downloaded. @@ -54,6 +49,7 @@ cd "${TINK_BASE_DIR}/tink_java_gcpkms" "${GITHUB_ORG}/tink-java" ./kokoro/testutils/copy_credentials.sh "testdata" "gcp" +./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" cp WORKSPACE WORKSPACE.bak ./kokoro/testutils/replace_http_archive_with_local_repository.py \ @@ -64,14 +60,34 @@ set -euo pipefail ./tools/create_maven_build_file.sh -o BUILD.bazel.temp if ! cmp -s BUILD.bazel BUILD.bazel.temp; then - echo "ERROR: Update your BUILD.bazel file using ./tools/create_maven_build_file.sh or applying:" >&2 + echo -n "ERROR: Update your BUILD.bazel file using" >&2 + echo " ./tools/create_maven_build_file.sh or applying:" echo "patch BUILD.bazel< env_variables.txt +KOKORO_ROOT +EOF +RUN_COMMAND_ARGS+=( -e env_variables.txt ) +readonly RUN_COMMAND_ARGS + ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" ./_do_run_test.sh diff --git a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh b/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh deleted file mode 100644 index 7839251..0000000 --- a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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. -################################################################################ - -# By default when run locally this script runs the command below directly on the -# host. The CONTAINER_IMAGE variable can be set to run on a custom container -# image for local testing. E.g.: -# -# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-cmake:latest" \ -# sh ./kokoro/gcp_ubuntu/bazel_fips/run_tests.sh -# -# The user may specify TINK_BASE_DIR as the folder where to look for -# tink-java-gcpkms and its depndencies. That is: -# ${TINK_BASE_DIR}/tink_java -# ${TINK_BASE_DIR}/tink_java_gcpkms -set -eEuo pipefail - -readonly GITHUB_ORG="https://github.com/tink-crypto" - -RUN_COMMAND_ARGS=() -if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]] ; then - TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - source \ - "${TINK_BASE_DIR}/tink_java_gcpkms/kokoro/testutils/java_test_container_images.sh" - CONTAINER_IMAGE="${TINK_JAVA_BASE_IMAGE}" - RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" ) -fi -: "${TINK_BASE_DIR:=$(cd .. && pwd)}" -readonly TINK_BASE_DIR -readonly CONTAINER_IMAGE - -if [[ -n "${CONTAINER_IMAGE:-}" ]]; then - RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) -fi -readonly RUN_COMMAND_ARGS - -cd "${TINK_BASE_DIR}/tink_java_gcpkms" - -# Check for dependencies in TINK_BASE_DIR. Any that aren't present will be -# downloaded. -./kokoro/testutils/fetch_git_repo_if_not_present.sh "${TINK_BASE_DIR}" \ - "${GITHUB_ORG}/tink-java" - -./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" - -cp "examples/WORKSPACE" "examples/WORKSPACE.bak" - -./kokoro/testutils/replace_http_archive_with_local_repository.py \ - -f "examples/WORKSPACE" -t ../.. - -# Targets tagged as "manual" that require setting GCP credentials. -MANUAL_TARGETS=() -if [[ -n "${KOKORO_ROOT:-}" ]]; then - MANUAL_TARGETS=( - "//gcs:gcs_envelope_aead_example_test" - "//encryptedkeyset:encrypted_keyset_example_test" - "//envelopeaead:envelope_aead_example_test" - ) -fi -readonly MANUAL_TARGETS - -# Run cleanup on EXIT. -trap cleanup EXIT - -cleanup() { - rm -rf _do_run_test.sh - mv examples/WORKSPACE.bak examples/WORKSPACE -} - -./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ - ./kokoro/testutils/run_bazel_tests.sh "examples" "${MANUAL_TARGETS[@]}" diff --git a/kokoro/macos_external/bazel/run_tests.sh b/kokoro/macos_external/bazel/run_tests.sh index 4a72f64..5b06350 100644 --- a/kokoro/macos_external/bazel/run_tests.sh +++ b/kokoro/macos_external/bazel/run_tests.sh @@ -22,13 +22,11 @@ export ANDROID_HOME="/usr/local/share/android-sdk" export COURSIER_OPTS="-Djava.net.preferIPv6Addresses=true" if [[ -n "${KOKORO_ROOT:-}" ]] ; then - TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" + readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_java_gcpkms" export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0_292") fi -: "${TINK_BASE_DIR:=$(cd .. && pwd)}" - # Check for dependencies in TINK_BASE_DIR. Any that aren't present will be # downloaded. readonly GITHUB_ORG="https://github.com/tink-crypto" @@ -36,6 +34,7 @@ readonly GITHUB_ORG="https://github.com/tink-crypto" "${GITHUB_ORG}/tink-java" ./kokoro/testutils/copy_credentials.sh "testdata" "gcp" +./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" ./kokoro/testutils/update_android_sdk.sh ./kokoro/testutils/replace_http_archive_with_local_repository.py \ -f "WORKSPACE" -t "${TINK_BASE_DIR}" @@ -51,3 +50,16 @@ fi readonly MANUAL_TARGETS ./kokoro/testutils/run_bazel_tests.sh . "${MANUAL_TARGETS[@]}" + +# Targets tagged as "manual" that require setting GCP credentials. +MANUAL_EXAMPLE_TARGETS=() +if [[ -n "${KOKORO_ROOT:-}" ]]; then + MANUAL_EXAMPLE_TARGETS=( + "//gcs:gcs_envelope_aead_example_test" + "//encryptedkeyset:encrypted_keyset_example_test" + "//envelopeaead:envelope_aead_example_test" + ) +fi +readonly MANUAL_EXAMPLE_TARGETS + +./kokoro/testutils/run_bazel_tests.sh "examples" "${MANUAL_EXAMPLE_TARGETS[@]}" diff --git a/kokoro/macos_external/examples/bazel/run_tests.sh b/kokoro/macos_external/examples/bazel/run_tests.sh deleted file mode 100644 index 958f59d..0000000 --- a/kokoro/macos_external/examples/bazel/run_tests.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/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. -################################################################################ - -set -euo pipefail - -export XCODE_VERSION="14.1" -export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer" -export ANDROID_HOME="/usr/local/share/android-sdk" -export COURSIER_OPTS="-Djava.net.preferIPv6Addresses=true" - -if [[ -n "${KOKORO_ROOT:-}" ]]; then - TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - cd "${TINK_BASE_DIR}/tink_java_gcpkms" - export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0_292") -fi - -: "${TINK_BASE_DIR:=$(cd .. && pwd)}" - -# Check for dependencies in TINK_BASE_DIR. Any that aren't present will be -# downloaded. -readonly GITHUB_ORG="https://github.com/tink-crypto" -./kokoro/testutils/fetch_git_repo_if_not_present.sh "${TINK_BASE_DIR}" \ - "${GITHUB_ORG}/tink-java" - -./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" -./kokoro/testutils/update_android_sdk.sh - -cp "examples/WORKSPACE" "examples/WORKSPACE.bak" - -./kokoro/testutils/replace_http_archive_with_local_repository.py \ - -f "examples/WORKSPACE" -t "${TINK_BASE_DIR}" - -# Targets tagged as "manual" that require setting GCP credentials. -MANUAL_EXAMPLE_JAVA_TARGETS=() -if [[ -n "${KOKORO_ROOT:-}" ]]; then - MANUAL_EXAMPLE_JAVA_TARGETS=( - "//gcs:gcs_envelope_aead_example_test" - "//encryptedkeyset:encrypted_keyset_example_test" - "//envelopeaead:envelope_aead_example_test" - ) -fi -readonly MANUAL_EXAMPLE_JAVA_TARGETS - -./kokoro/testutils/run_bazel_tests.sh "examples" \ - "${MANUAL_EXAMPLE_JAVA_TARGETS[@]}" - -mv "examples/WORKSPACE.bak" "examples/WORKSPACE"