Skip to content

Commit

Permalink
Modify examples to use the local tink-cc
Browse files Browse the repository at this point in the history
This makes examples relative to the same repo version and simplifies test scripts

PiperOrigin-RevId: 559352518
Change-Id: I57c601cfc439db831b2df54923c28b5e3ead56d1
  • Loading branch information
morambro authored and copybara-github committed Aug 23, 2023
1 parent b1fc136 commit 858c628
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
7 changes: 2 additions & 5 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
23 changes: 8 additions & 15 deletions kokoro/gcp_ubuntu/examples/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 deletions kokoro/macos_external/examples/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@5552964359

5552964359 Sep 18, 2023

asorg,23

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"

1 comment on commit 858c628

@5552964359
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.