Skip to content

Commit

Permalink
Use Bazel Remote Caching in Kokoro jobs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 652770644
Change-Id: Ie218cf89d55614203ed1fc7a0faca34a0df08ee5
  • Loading branch information
morambro authored and copybara-github committed Jul 16, 2024
1 parent 6b7c419 commit b029efe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
38 changes: 15 additions & 23 deletions kokoro/gcp_ubuntu/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,27 @@ fi

./kokoro/testutils/copy_credentials.sh "testdata" "aws"

cat <<'EOF' > _do_run_test.sh
#!/bin/bash
set -euo pipefail
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/check_go_generated_files_up_to_date.sh .

./kokoro/testutils/check_go_generated_files_up_to_date.sh "$(pwd)"
RUN_BAZEL_TESTS_OPTS=(
-t
--test_arg=--test.v
)
if [[ -n "${TINK_REMOTE_BAZEL_CACHE_GCS_BUCKET:-}" ]]; then
cp "${TINK_REMOTE_BAZEL_CACHE_SERVICE_KEY}" ./cache_key
readonly REMOTE_CACHE="${TINK_REMOTE_BAZEL_CACHE_GCS_BUCKET}/bazel/tink_go_awskms_${TINK_GO_BASE_IMAGE_HASH}"
RUN_BAZEL_TESTS_OPTS+=( -c "${REMOTE_CACHE}" )
fi
readonly RUN_BAZEL_TESTS_OPTS

MANUAL_TARGETS=()
# Run manual tests that rely on test data only available via Bazel.
if [[ -n "${KOKORO_ROOT:-}" ]]; then
MANUAL_TARGETS+=( "//integration/awskms:awskms_test" )
fi
readonly MANUAL_TARGETS
./kokoro/testutils/run_bazel_tests.sh -t --test_arg=--test.v . \
"${MANUAL_TARGETS[@]}"
EOF
chmod +x _do_run_test.sh

cat <<EOF > _env_variables.txt
KOKORO_ROOT
EOF
RUN_COMMAND_ARGS+=( -e _env_variables.txt )

# Run cleanup on EXIT.
trap cleanup EXIT

cleanup() {
rm -rf _do_run_test.sh
rm -rf _env_variables.txt
}

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" ./_do_run_test.sh
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_bazel_tests.sh "${RUN_BAZEL_TESTS_OPTS[@]}" . \
"${MANUAL_TARGETS[@]}"
14 changes: 13 additions & 1 deletion kokoro/macos_external/bazel/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@ echo "Using go binary from $(which go): $(go version)"

./kokoro/testutils/copy_credentials.sh "testdata" "aws"

RUN_BAZEL_TESTS_OPTS=(
-t
--test_arg=--test.v
)
if [[ -n "${TINK_REMOTE_BAZEL_CACHE_GCS_BUCKET:-}" ]]; then
cp "${TINK_REMOTE_BAZEL_CACHE_SERVICE_KEY}" ./cache_key
RUN_BAZEL_TESTS_OPTS+=(
-c "${TINK_REMOTE_BAZEL_CACHE_GCS_BUCKET}/bazel/macos_tink_go_awskms"
)
fi
readonly RUN_BAZEL_TESTS_OPTS

MANUAL_TARGETS=()
# Run manual tests that rely on test data only available via Bazel.
if [[ -n "${KOKORO_ROOT:-}" ]]; then
MANUAL_TARGETS+=( "//integration/awskms:awskms_test" )
fi
readonly MANUAL_TARGETS

./kokoro/testutils/run_bazel_tests.sh -t --test_arg=--test.v . \
./kokoro/testutils/run_bazel_tests.sh "${RUN_BAZEL_TESTS_OPTS[@]}" . \
"${MANUAL_TARGETS[@]}"

0 comments on commit b029efe

Please sign in to comment.