Skip to content

Commit

Permalink
Test examples in the main repo's test script
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 568846166
Change-Id: I2f8246876f9a851242a7f12f5b8d91773da4786a
  • Loading branch information
morambro authored and copybara-github committed Sep 27, 2023
1 parent f5a4938 commit 44c61d7
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 213 deletions.
27 changes: 18 additions & 9 deletions kokoro/gcp_ubuntu/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
# limitations under the License.
################################################################################

set -euo pipefail

# 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-cc and its examples using Bazel.
#
# The behavior of this script can be modified using the following optional env
# variables:
#
# - 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-cc-base:latest" \
# sh ./kokoro/gcp_ubuntu/bazel/run_tests.sh
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-base:latest" \
# sh ./kokoro/gcp_ubuntu/bazel/run_tests.sh
#
set -euo pipefail

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

if [[ -n "${CONTAINER_IMAGE}" ]]; then
if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_bazel_tests.sh -b --enable_bzlmod -t --enable_bzlmod .
./kokoro/testutils/run_bazel_tests.sh .

# Build and run tests using the WORKSPACE file.
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_bazel_tests.sh examples
40 changes: 21 additions & 19 deletions ...ro/gcp_ubuntu/examples/bazel/run_tests.sh → kokoro/gcp_ubuntu/bzlmod/run_tests.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,37 +14,39 @@
# limitations under the License.
################################################################################

set -euo pipefail

# 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-cc and its examples using Bazel's bzlmod.
#
# The behavior of this script can be modified using the following optional env
# variables:
#
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-base:latest" \
# sh ./kokoro/gcp_ubuntu/examples/bazel/run_tests.sh
# - 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-cc-base:latest" \
# sh ./kokoro/gcp_ubuntu/bzlmod/run_tests.sh
#
set -euo pipefail

RUN_COMMAND_ARGS=()
if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then
TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
source "${TINK_BASE_DIR}/tink_cc/kokoro/testutils/cc_test_container_images.sh"
readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
cd "${TINK_BASE_DIR}/tink_cc"
source 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
if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

# 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
-t "--enable_bzlmod" .

# Build and run tests using the WORKSPACE file.
# Build and run tests using bzlmod.
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_bazel_tests.sh examples
./kokoro/testutils/run_bazel_tests.sh -b "--enable_bzlmod" \
-t "--enable_bzlmod" examples
21 changes: 13 additions & 8 deletions kokoro/gcp_ubuntu/cmake/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
# limitations under the License.
################################################################################

set -euo pipefail

# 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-cc and its examples using CMake.
#
# The behavior of this script can be modified using the following optional env
# variables:
#
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-cmake:latest" \
# sh ./kokoro/gcp_ubuntu/cmake/run_tests.sh
# - 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-cc-cmake:latest" \
# sh ./kokoro/gcp_ubuntu/cmake/run_tests.sh
#
set -euo pipefail

RUN_COMMAND_ARGS=()
if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then
readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
Expand All @@ -33,7 +38,7 @@ if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then
fi
readonly CONTAINER_IMAGE

if [[ -n "${CONTAINER_IMAGE}" ]]; then
if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

Expand Down
25 changes: 17 additions & 8 deletions kokoro/gcp_ubuntu/cmake_openssl/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
# limitations under the License.
################################################################################

set -euo pipefail

# 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-cc with OpenSSL 1.1.1 and its examples CMake.
#
# The behavior of this script can be modified using the following optional env
# variables:
#
# - 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-cc-cmake-and-openssl-1_1_1:latest" \
# sh ./kokoro/gcp_ubuntu/cmake_openssl/run_tests.sh
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-cmake-and-openssl-1_1_1:latest" \
# sh ./kokoro/gcp_ubuntu/cmake_openssl/run_tests.sh
#
set -euo pipefail

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

if [[ -n "${CONTAINER_IMAGE}" ]]; then
if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_cmake_tests.sh . -DTINK_USE_SYSTEM_OPENSSL=ON

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_cmake_tests.sh "examples" -DTINK_BUILD_TESTS=OFF \
-DTINK_USE_SYSTEM_OPENSSL=ON
25 changes: 17 additions & 8 deletions kokoro/gcp_ubuntu/cmake_openssl3/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
# limitations under the License.
################################################################################

set -euo pipefail

# 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-cc with OpenSSL 3 and its examples CMake.
#
# The behavior of this script can be modified using the following optional env
# variables:
#
# - 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-cc-cmake-and-openssl-3:latest" \
# sh ./kokoro/gcp_ubuntu/cmake_openssl/run_tests.sh
# CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-cc-cmake-and-openssl-3:latest" \
# sh ./kokoro/gcp_ubuntu/cmake_openssl3/run_tests.sh
#
set -euo pipefail

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

if [[ -n "${CONTAINER_IMAGE}" ]]; then
if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
fi

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_cmake_tests.sh . -DTINK_USE_SYSTEM_OPENSSL=ON

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_cmake_tests.sh "examples" -DTINK_BUILD_TESTS=OFF \
-DTINK_USE_SYSTEM_OPENSSL=ON
41 changes: 0 additions & 41 deletions kokoro/gcp_ubuntu/examples/cmake/run_tests.sh

This file was deleted.

41 changes: 0 additions & 41 deletions kokoro/gcp_ubuntu/examples/cmake_openssl/run_tests.sh

This file was deleted.

3 changes: 2 additions & 1 deletion kokoro/macos_external/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ set -euo pipefail

# If we are running on Kokoro cd into the repository.
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_cc"
fi

./kokoro/testutils/run_bazel_tests.sh .
./kokoro/testutils/run_bazel_tests.sh "examples"
1 change: 1 addition & 0 deletions kokoro/macos_external/cmake/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ if [[ -n "${KOKORO_ROOT:-}" ]]; then
fi

./kokoro/testutils/run_cmake_tests.sh .
./kokoro/testutils/run_cmake_tests.sh "examples" -DTINK_BUILD_TESTS=OFF
2 changes: 2 additions & 0 deletions kokoro/macos_external/cmake_openssl/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ fi
# Sourcing is needed to update the caller environment.
source ./kokoro/testutils/install_openssl.sh
./kokoro/testutils/run_cmake_tests.sh . -DTINK_USE_SYSTEM_OPENSSL=ON
./kokoro/testutils/run_cmake_tests.sh "examples" -DTINK_BUILD_TESTS=OFF \
-DTINK_USE_SYSTEM_OPENSSL=ON
27 changes: 0 additions & 27 deletions kokoro/macos_external/examples/bazel/run_tests.sh

This file was deleted.

24 changes: 0 additions & 24 deletions kokoro/macos_external/examples/cmake/run_tests.sh

This file was deleted.

Loading

0 comments on commit 44c61d7

Please sign in to comment.