Imported Upstream version 1.41.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 # change to grpc repo root
19 cd $(dirname $0)/../../..
20
21 source tools/internal_ci/helper_scripts/prepare_build_linux_rc
22
23 # make sure bazel is available
24 tools/bazel version
25
26 # to get "bazel" link for kokoro build, we need to generate
27 # invocation UUID, set a flag for bazel to use it
28 # and upload "bazel_invocation_ids" file as artifact.
29 BAZEL_INVOCATION_ID="$(uuidgen)"
30 echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids"
31
32 tools/bazel \
33   --bazelrc=tools/remote_build/kokoro.bazelrc \
34   test \
35   --invocation_id="${BAZEL_INVOCATION_ID}" \
36   --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh \
37   $@ \
38   -- //test/... || FAILED="true"
39
40 if [ "$UPLOAD_TEST_RESULTS" != "" ]
41 then
42   # Sleep to let ResultStore finish writing results before querying
43   sleep 60
44   python ./tools/run_tests/python_utils/upload_rbe_results.py
45 fi
46
47 if [ "$FAILED" != "" ]
48 then
49   exit 1
50 fi