Imported Upstream version 1.21.0
[platform/upstream/grpc.git] / tools / internal_ci / linux / grpc_bazel_on_foundry_base.sh
1 #!/usr/bin/env bash
2 # Copyright 2017 gRPC authors.
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 set -ex
17
18 # Download bazel
19 temp_dir="$(mktemp -d)"
20 wget -q https://github.com/bazelbuild/bazel/releases/download/0.23.2/bazel-0.23.2-linux-x86_64 -O "${temp_dir}/bazel"
21 chmod 755 "${temp_dir}/bazel"
22 export PATH="${temp_dir}:${PATH}"
23 # This should show ${temp_dir}/bazel
24 which bazel
25
26 # change to grpc repo root
27 cd $(dirname $0)/../../..
28
29 source tools/internal_ci/helper_scripts/prepare_build_linux_rc
30
31 # to get "bazel" link for kokoro build, we need to generate
32 # invocation UUID, set a flag for bazel to use it
33 # and upload "bazel_invocation_ids" file as artifact.
34 BAZEL_INVOCATION_ID="$(uuidgen)"
35 echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids"
36
37 bazel \
38   --bazelrc=tools/remote_build/kokoro.bazelrc \
39   test \
40   --invocation_id="${BAZEL_INVOCATION_ID}" \
41   --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh \
42   --google_credentials="${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json" \
43   $@ \
44   -- //test/... || FAILED="true"
45
46 if [ "$UPLOAD_TEST_RESULTS" != "" ]
47 then
48   # Sleep to let ResultStore finish writing results before querying
49   sleep 60
50   python ./tools/run_tests/python_utils/upload_rbe_results.py
51 fi
52
53 if [ "$FAILED" != "" ]
54 then
55   exit 1
56 fi