aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Matt Kwong <matt-kwong@users.noreply.github.com>2017-09-13 15:44:09 -0700
committerGravatar GitHub <noreply@github.com>2017-09-13 15:44:09 -0700
commit2f8d3aee79be23b755f8c0653bf48a1d3688613a (patch)
tree32d4a12508d49073bac06e47221873ea52895e5c /tools
parentfc57518ac1999743da3f618193e9d2240a5660c1 (diff)
parentbce6bcd1f8404ca09e0f50502195edfef420b22a (diff)
Merge pull request #12268 from matt-kwong/kokoro_fil
Add Kokoro test filtering for MacOS/Windows
Diffstat (limited to 'tools')
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_macos_rc7
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_windows.bat8
-rw-r--r--tools/run_tests/python_utils/filter_pull_request_tests.py2
3 files changed, 16 insertions, 1 deletions
diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
index dd2741e595..ae91a6a6d2 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
@@ -31,6 +31,13 @@ ulimit -a
pip install google-api-python-client --user python
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json
+# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
+if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then
+ brew install jq
+ ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
+ export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
+fi
+
set +ex # rvm script is very verbose and exits with errorcode
source $HOME/.rvm/scripts/rvm
set -e # rvm commands are very verbose
diff --git a/tools/internal_ci/helper_scripts/prepare_build_windows.bat b/tools/internal_ci/helper_scripts/prepare_build_windows.bat
index 69e087e1db..f625755db9 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_windows.bat
+++ b/tools/internal_ci/helper_scripts/prepare_build_windows.bat
@@ -18,6 +18,14 @@ set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH%
bash tools/internal_ci/helper_scripts/gen_report_index.sh
+@rem If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
+if defined KOKORO_GITHUB_PULL_REQUEST_NUMBER if defined RUN_TESTS_FLAGS (
+ chocolatey install -y jq
+ for /f "usebackq delims=" %%x in (`curl -s https://api.github.com/repos/grpc/grpc/pulls/%KOKORO_GITHUB_PULL_REQUEST_NUMBER% ^| jq -r .base.ref`) do (
+ set RUN_TESTS_FLAGS=%RUN_TESTS_FLAGS% --filter_pr_tests --base_branch origin/%%x
+ )
+)
+
@rem Update DNS settings to:
@rem 1. allow resolving metadata.google.internal hostname
@rem 2. make fetching default GCE credential by oauth2client work
diff --git a/tools/run_tests/python_utils/filter_pull_request_tests.py b/tools/run_tests/python_utils/filter_pull_request_tests.py
index 032c0701e2..4ad981237b 100644
--- a/tools/run_tests/python_utils/filter_pull_request_tests.py
+++ b/tools/run_tests/python_utils/filter_pull_request_tests.py
@@ -128,7 +128,7 @@ def _get_changed_files(base_branch):
# Get file changes between branch and merge-base of specified branch
# Not combined to be Windows friendly
base_commit = check_output(["git", "merge-base", base_branch, "HEAD"]).rstrip()
- return check_output(["git", "diff", base_commit, "--name-only"]).splitlines()
+ return check_output(["git", "diff", base_commit, "--name-only", "HEAD"]).splitlines()
def _can_skip_tests(file_names, triggers):