diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 7abd380e..6adf5474 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -1,11 +1,8 @@ workspace(name = "tink_cc_examples") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( +local_repository( name = "tink_cc", - urls = ["https://github.com/tink-crypto/tink-cc/archive/main.zip"], - strip_prefix = "tink-cc-main", + path = "..", ) # Load Tink dependencies. diff --git a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh b/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh index f5a277d3..54416575 100755 --- a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh +++ b/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh @@ -25,33 +25,26 @@ set -euo pipefail # RUN_COMMAND_ARGS=() if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then - readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - cd "${TINK_BASE_DIR}/tink_cc" - source kokoro/testutils/cc_test_container_images.sh + TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" + source "${TINK_BASE_DIR}/tink_cc/kokoro/testutils/cc_test_container_images.sh" CONTAINER_IMAGE="${TINK_CC_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_cc" + if [[ -n "${CONTAINER_IMAGE}" ]]; then RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) fi -# Also build and test the examples using Bazel Modules. +# Build and run tests using bzlmod. ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ ./kokoro/testutils/run_bazel_tests.sh -b "--enable_bzlmod" \ -t "--enable_bzlmod" examples -cp examples/WORKSPACE examples/WORKSPACE.bak - -# Run cleanup on EXIT. -trap cleanup EXIT - -cleanup() { - mv examples/WORKSPACE.bak examples/WORKSPACE -} - -./kokoro/testutils/replace_http_archive_with_local_repository.py \ - -f examples/WORKSPACE -t "../.." +# Build and run tests using the WORKSPACE file. ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ ./kokoro/testutils/run_bazel_tests.sh examples diff --git a/kokoro/macos_external/examples/bazel/run_tests.sh b/kokoro/macos_external/examples/bazel/run_tests.sh index b9ac7964..b5a2ff38 100755 --- a/kokoro/macos_external/examples/bazel/run_tests.sh +++ b/kokoro/macos_external/examples/bazel/run_tests.sh @@ -18,13 +18,10 @@ set -euo pipefail if [[ -n "${KOKORO_ROOT:-}" ]]; then TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - cd "${TINK_BASE_DIR}/tink_cc" fi - : "${TINK_BASE_DIR:=$(cd .. && pwd)}" +readonly TINK_BASE_DIR + +cd "${TINK_BASE_DIR}/tink_cc" -cp "examples/WORKSPACE" "examples/WORKSPACE.bak" -./kokoro/testutils/replace_http_archive_with_local_repository.py \ - -f "examples/WORKSPACE" -t "${TINK_BASE_DIR}" ./kokoro/testutils/run_bazel_tests.sh "examples" -mv "examples/WORKSPACE.bak" "examples/WORKSPACE"