Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: diff against the common commit on the master #3916

Merged
merged 3 commits into from
May 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ shopt -s globstar

DIFF_FROM=""

# `--only-diff-master will only run tests on project changes from the master branch.
# `--only-diff-master` will only run tests on project changes on the
# last common commit from the master branch.
if [[ $* == *--only-diff-master* ]]; then
DIFF_FROM="origin/master.."
set +e
git diff --quiet "origin/master..." .kokoro/tests .kokoro/docker \
.kokoro/trampoline_v2.sh
CHANGED=$?
tmatsuo marked this conversation as resolved.
Show resolved Hide resolved
set -e
if [[ "${CHANGED}" -eq 0 ]]; then
DIFF_FROM="origin/master..."
else
echo "Changes to test driver files detected. Running full tests."
fi
fi

# `--only-diff-master will only run tests on project changes from the previous commit.
# `--only-diff-head` will only run tests on project changes from the
# previous commit.
if [[ $* == *--only-diff-head* ]]; then
DIFF_FROM="HEAD~.."
fi
Expand Down Expand Up @@ -83,16 +94,6 @@ set +e
RTN=0
ROOT=$(pwd)

# If some files in .kokoro directory have any changes, we will test everything.
test_all="true"
if [[ -n "${DIFF_FROM:-}" ]]; then
git diff --quiet "$DIFF_FROM" .kokoro/docker .kokoro/tests
CHANGED=$?
if [[ "$CHANGED" -eq 0 ]]; then
test_all="false"
fi
fi

# Find all requirements.txt in the repository (may break on whitespace).
for file in **/requirements.txt; do
cd "$ROOT"
Expand Down Expand Up @@ -131,7 +132,7 @@ for file in **/requirements.txt; do
fi
fi
# If $DIFF_FROM is set, use it to check for changes in this directory.
if [[ -n "${DIFF_FROM:-}" ]] && [[ "${test_all}" == "false" ]]; then
if [[ -n "${DIFF_FROM:-}" ]]; then
git diff --quiet "$DIFF_FROM" .
CHANGED=$?
if [[ "$CHANGED" -eq 0 ]]; then
Expand Down