grpc_run_bazel_c_cpp_tests.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. # Copyright 2019 The 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. set -ex
  16. # avoid slow finalization after the script has exited.
  17. source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
  18. # change to grpc repo root
  19. cd $(dirname $0)/../../..
  20. # TODO(jtattermusch): most of the prepare steps should not be needed for bazel
  21. source tools/internal_ci/helper_scripts/prepare_build_macos_rc
  22. # make sure bazel is available
  23. tools/bazel version
  24. ./tools/run_tests/start_port_server.py
  25. # to get "bazel" link for kokoro build, we need to generate
  26. # invocation UUID, set a flag for bazel to use it
  27. # and upload "bazel_invocation_ids" file as artifact.
  28. # NOTE: UUID needs to be in lowercase for the result link to work
  29. # (on mac "uuidgen" outputs uppercase UUID)
  30. BAZEL_INVOCATION_ID="$(uuidgen | tr '[:upper:]' '[:lower:]')"
  31. echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids"
  32. # run all C/C++ tests
  33. tools/bazel \
  34. --bazelrc=tools/remote_build/mac.bazelrc \
  35. test \
  36. --invocation_id="${BAZEL_INVOCATION_ID}" \
  37. --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh \
  38. --google_credentials="${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json" \
  39. $BAZEL_FLAGS \
  40. -- //test/... || FAILED="true"
  41. if [ "$UPLOAD_TEST_RESULTS" != "" ]
  42. then
  43. # Sleep to let ResultStore finish writing results before querying
  44. sleep 60
  45. PYTHONHTTPSVERIFY=0 python3 ./tools/run_tests/python_utils/upload_rbe_results.py
  46. fi
  47. if [ "$FAILED" != "" ]
  48. then
  49. exit 1
  50. fi