run_if_c_cpp_modified.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. # This script is invoked by a pull request job and executes all
  17. # args passed to this script if the pull request affect C/C++ code
  18. set -ex
  19. # Enter the gRPC repo root
  20. cd $(dirname $0)/../../..
  21. AFFECTS_C_CPP=`python3 -c 'import os; \
  22. import sys; \
  23. sys.path.insert(0, "tools/run_tests/python_utils"); \
  24. import filter_pull_request_tests as filter; \
  25. github_target_branch = os.environ.get("KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH"); \
  26. print(filter.affects_c_cpp("origin/%s" % github_target_branch))'`
  27. if [ $AFFECTS_C_CPP == "False" ] ; then
  28. echo "This pull request does not affect C/C++. Tests do not need to be run."
  29. else
  30. $@
  31. fi