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