Debian Codegraph @

kokoro/gcp_ubuntu/gomod/run_tests.sh

raw symbols SCIP
1 #!/bin/bash
2 # Copyright 2022 Google LLC
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 ################################################################################
16
17 # Builds and tests tink-go-awskms using Go tooling.
18 #
19 # The behavior of this script can be modified using the following optional env
20 # variables:
21 #
22 # - CONTAINER_IMAGE (unset by default): By default when run locally this script
23 # executes tests directly on the host. The CONTAINER_IMAGE variable can be set
24 # to execute tests in a custom container image for local testing. E.g.:
25 #
26 # CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-go-base:latest" \
27 # sh ./kokoro/gcp_ubuntu/gomod/run_tests.sh
28
29 # Generated with openssl rand -hex 10
30 echo "==========================================================================="
31 echo "Tink Script ID: 1a16e889c6093132dd37 (to quickly find the script from logs)"
32 echo "==========================================================================="
33
34 set -eEuo pipefail
35
36 RUN_COMMAND_ARGS=()
37 if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then
38 readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)"
39 cd "${TINK_BASE_DIR}/tink_go_awskms"
40 source "./kokoro/testutils/go_test_container_images.sh"
41 CONTAINER_IMAGE="${TINK_GO_BASE_IMAGE}"
42 RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" )
43 fi
44 readonly CONTAINER_IMAGE
45
46 if [[ -n "${CONTAINER_IMAGE:-}" ]]; then
47 RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" )
48 fi
49
50 ./kokoro/testutils/docker_execute.sh "${RUN_COMMAND_ARGS[@]}" \
51 ./kokoro/testutils/check_go_generated_files_up_to_date.sh .
52 ./kokoro/testutils/copy_credentials.sh "testdata" "aws"
53
54 cat <<EOF > env_variables.txt
55 GOARCH
56 EOF
57
58 RUN_COMMAND_ARGS+=( -e env_variables.txt )
59
60 readonly RUN_COMMAND_ARGS
61
62 cat <<EOF > _run_test.sh
63 #!/bin/bash
64 set -euo pipefail
65
66 set -x
67 go build -v ./...
68 go test -v ./...
69
70 cd v3
71
72 go build -v ./...
73 go test -v ./...
74 EOF
75
76 chmod +x _run_test.sh
77
78 # Run cleanup on EXIT.
79 trap cleanup EXIT
80
81 cleanup() {
82 rm -rf _run_test.sh
83 rm -rf env_variables.txt
84 }
85
86 ./kokoro/testutils/docker_execute.sh "${RUN_COMMAND_ARGS[@]}" \
87 ./_run_test.sh