Skip to content

Commit

Permalink
Use the latest tink-java release (v1.11.0) by default
Browse files Browse the repository at this point in the history
We no longer need to keep compatibility with tink-java@HEAD. Also remove unused testutils script.

PiperOrigin-RevId: 567556836
Change-Id: Icaa7b2042d25d41a6c5a62ea85815cc984925d68
  • Loading branch information
morambro authored and copybara-github committed Sep 22, 2023
1 parent 64552a8 commit cd3ec14
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 273 deletions.
15 changes: 6 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
workspace(name = "tink_java_gcpkms")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@tink_java_gcpkms//:tink_java_gcpkms_deps.bzl", "TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS", "tink_java_gcpkms_deps")

http_archive(
name = "tink_java",
urls = ["https://github.com/tink-crypto/tink-java/archive/main.zip"],
strip_prefix = "tink-java-main",
)
tink_java_gcpkms_deps()

load("@tink_java//:tink_java_deps.bzl", "TINK_MAVEN_ARTIFACTS", "tink_java_deps")

load("@tink_java//:tink_java_deps.bzl", "tink_java_deps", "TINK_MAVEN_ARTIFACTS")
tink_java_deps()

load("@tink_java//:tink_java_deps_init.bzl", "tink_java_deps_init")
load("@tink_java_gcpkms//:tink_java_gcpkms_deps.bzl", "TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS")
load("@rules_jvm_external//:defs.bzl", "maven_install")

tink_java_deps_init()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
artifacts = TINK_MAVEN_ARTIFACTS + TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS,
repositories = [
Expand Down
19 changes: 6 additions & 13 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
workspace(name = "tink_java_awskms_examples")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "tink_java",
urls = ["https://github.com/tink-crypto/tink-java/archive/main.zip"],
strip_prefix = "tink-java-main",
)

http_archive(
local_repository(
name = "tink_java_gcpkms",
urls = ["https://github.com/tink-crypto/tink-java-gcpkms/archive/main.zip"],
strip_prefix = "tink-java-gcpkms-main",
path = "..",
)

load("@tink_java_gcpkms//:tink_java_gcpkms_deps.bzl", "TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS", "tink_java_gcpkms_deps")

tink_java_gcpkms_deps()

load("@tink_java//:tink_java_deps.bzl", "tink_java_deps", "TINK_MAVEN_ARTIFACTS")

tink_java_deps()
Expand All @@ -24,8 +19,6 @@ tink_java_deps_init()

load("@rules_jvm_external//:defs.bzl", "maven_install")

load("@tink_java_gcpkms//:tink_java_gcpkms_deps.bzl", "TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS")

maven_install(
artifacts = TINK_MAVEN_ARTIFACTS +
TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS + [
Expand Down
5 changes: 0 additions & 5 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink</artifactId>
<version>HEAD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink-gcpkms</artifactId>
Expand Down
31 changes: 9 additions & 22 deletions kokoro/gcp_ubuntu/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@
# 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.:
# Builds and tests tink-java-gcpkms using Bazel.
#
# 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 behavior of this script can be modified using the following optional env
# variables:
#
# 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
# - CONTAINER_IMAGE (unset by default): By default when run locally this script
# executes tests directly on the host. The CONTAINER_IMAGE variable can be set
# to execute tests in a custom container image for local testing. E.g.:
#
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-java-base:latest" \
# sh ./kokoro/gcp_ubuntu/bazel/run_tests.sh
set -eEuo pipefail

readonly GITHUB_ORG="https://github.com/tink-crypto"

RUN_COMMAND_ARGS=()
if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]] ; then
readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
Expand All @@ -43,18 +41,9 @@ if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

# 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 "testdata" "gcp"
./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp"

cp WORKSPACE WORKSPACE.bak
./kokoro/testutils/replace_http_archive_with_local_repository.py \
-f WORKSPACE -t ..

cat <<'EOF' > _do_run_test.sh
set -euo pipefail
Expand All @@ -65,7 +54,6 @@ if ! cmp -s BUILD.bazel BUILD.bazel.temp; then
echo "patch BUILD.bazel<<PATCH"
echo "$(diff BUILD.bazel BUILD.bazel.temp)"
echo "PATCH"
EOP
exit 1
fi
MANUAL_TARGETS=()
Expand Down Expand Up @@ -97,7 +85,6 @@ trap cleanup EXIT
cleanup() {
rm -rf _do_run_test.sh
rm -rf BUILD.bazel.temp
mv WORKSPACE.bak WORKSPACE
}

# Share the required Kokoro env variables.
Expand Down
53 changes: 14 additions & 39 deletions kokoro/gcp_ubuntu/maven/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
# 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.:
# Builds and tests tink-java-gcpkms and its examples using Maven.
#
# 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 behavior of this script can be modified using the following optional env
# variables:
#
# 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
# - CONTAINER_IMAGE (unset by default): By default when run locally this script
# executes tests directly on the host. The CONTAINER_IMAGE variable can be set
# to execute tests in a custom container image for local testing. E.g.:
#
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-java-base:latest" \
# sh ./kokoro/gcp_ubuntu/maven/run_tests.sh
set -eEuo pipefail

readonly GITHUB_ORG="https://github.com/tink-crypto"
Expand All @@ -37,19 +37,14 @@ readonly IS_KOKORO

RUN_COMMAND_ARGS=()
if [[ "${IS_KOKORO}" == "true" ]] ; 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

cd "${TINK_BASE_DIR}/tink_java_gcpkms"

if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi
Expand All @@ -58,21 +53,11 @@ cat <<'EOF' > _do_run_test.sh
set -euo pipefail
readonly MAVEN_POM_FILE="maven/tink-java-gcpkms.pom.xml"
# Ignore com.google.crypto.tink:tink; this is a Bazel dependency, not a Maven one.
# Ignore com.google.crypto.tink:tink; this is a Bazel dependency, not a Maven
# one.
./kokoro/testutils/check_maven_bazel_deps_consistency.sh \
-e "com.google.crypto.tink:tink" "//:tink-gcpkms" "${MAVEN_POM_FILE}"
# Install the latest snapshots locally.
(
cd ../tink_java
./maven/maven_deploy_library.sh install tink \
maven/tink-java.pom.xml HEAD
)
# Build tink-java-gcpkms against tink-java at HEAD-SNAPSHOT.
mvn versions:set-property -Dproperty=tink.version -DnewVersion=HEAD-SNAPSHOT \
--file "${MAVEN_POM_FILE}"
./maven/maven_deploy_library.sh install tink-gcpkms "${MAVEN_POM_FILE}" HEAD
readonly CREDENTIALS_FILE_PATH="testdata/gcp/credential.json"
Expand All @@ -86,23 +71,13 @@ EOF

chmod +x _do_run_test.sh

# 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"

cp WORKSPACE WORKSPACE.bak

./kokoro/testutils/replace_http_archive_with_local_repository.py \
-f WORKSPACE -t ..
./kokoro/testutils/copy_credentials.sh "testdata" "gcp"

# Run cleanup on EXIT.
trap cleanup EXIT

cleanup() {
rm -rf _do_run_test.sh
mv WORKSPACE.bak WORKSPACE
}

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" ./_do_run_test.sh
Expand Down
8 changes: 0 additions & 8 deletions kokoro/macos_external/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,9 @@ if [[ -n "${KOKORO_ROOT:-}" ]] ; then
export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0_292")
fi

# 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 "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}"

# Run manual tests which rely on key material injected into the Kokoro
# environement.
Expand Down
8 changes: 0 additions & 8 deletions kokoro/release_maven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,5 @@ if [[ "${IS_KOKORO}" == "true" ]]; then
"${KOKORO_KEYSTORE_DIR}/70968_tink_dev_maven_pgp_passphrase")"
fi

# Check for dependencies in TINK_BASE_DIR. Any that aren't present will be
# downloaded. This is for manual runs only, on Kokoro this is a noop.
./kokoro/testutils/fetch_git_repo_if_not_present.sh "${TINK_BASE_DIR}" \
"https://github.com/tink-crypto/tink-java"
# Use tink-java that is made available by Kokoro or the one fetched above if
# running locally.
./kokoro/testutils/replace_http_archive_with_local_repository.py \
-f "WORKSPACE" -t "${TINK_BASE_DIR}"
./maven/maven_deploy_library.sh "${MAVEN_DEPLOY_LIBRARY_OPTIONS[@]}" release \
tink-gcpkms maven/tink-java-gcpkms.pom.xml "${RELEASE_VERSION}"
33 changes: 0 additions & 33 deletions kokoro/testutils/fetch_git_repo_if_not_present.sh

This file was deleted.

Loading

0 comments on commit cd3ec14

Please sign in to comment.