diff --git a/.kokoro/lint/continuous.cfg b/.kokoro/lint/continuous.cfg index 90879b0bec7e..6068e84c5ca5 100644 --- a/.kokoro/lint/continuous.cfg +++ b/.kokoro/lint/continuous.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh" } diff --git a/.kokoro/lint/presubmit.cfg b/.kokoro/lint/presubmit.cfg index e9c6e483b1c7..f876bd804e68 100644 --- a/.kokoro/lint/presubmit.cfg +++ b/.kokoro/lint/presubmit.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests_only_diff.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh" } diff --git a/.kokoro/python2.7/continuous.cfg b/.kokoro/python2.7/continuous.cfg index 90879b0bec7e..6068e84c5ca5 100644 --- a/.kokoro/python2.7/continuous.cfg +++ b/.kokoro/python2.7/continuous.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh" } diff --git a/.kokoro/python2.7/presubmit.cfg b/.kokoro/python2.7/presubmit.cfg index e9c6e483b1c7..f876bd804e68 100644 --- a/.kokoro/python2.7/presubmit.cfg +++ b/.kokoro/python2.7/presubmit.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests_only_diff.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh" } diff --git a/.kokoro/python3.6/continuous.cfg b/.kokoro/python3.6/continuous.cfg index 90879b0bec7e..6068e84c5ca5 100644 --- a/.kokoro/python3.6/continuous.cfg +++ b/.kokoro/python3.6/continuous.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh" } diff --git a/.kokoro/python3.6/presubmit.cfg b/.kokoro/python3.6/presubmit.cfg index e9c6e483b1c7..f876bd804e68 100644 --- a/.kokoro/python3.6/presubmit.cfg +++ b/.kokoro/python3.6/presubmit.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests_only_diff.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh" } diff --git a/.kokoro/python3.7/continuous.cfg b/.kokoro/python3.7/continuous.cfg index 90879b0bec7e..6068e84c5ca5 100644 --- a/.kokoro/python3.7/continuous.cfg +++ b/.kokoro/python3.7/continuous.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh" } diff --git a/.kokoro/python3.7/presubmit.cfg b/.kokoro/python3.7/presubmit.cfg index e9c6e483b1c7..f876bd804e68 100644 --- a/.kokoro/python3.7/presubmit.cfg +++ b/.kokoro/python3.7/presubmit.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests_only_diff.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh" } diff --git a/.kokoro/python3.8/continuous.cfg b/.kokoro/python3.8/continuous.cfg index 90879b0bec7e..6068e84c5ca5 100644 --- a/.kokoro/python3.8/continuous.cfg +++ b/.kokoro/python3.8/continuous.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh" } diff --git a/.kokoro/python3.8/presubmit.cfg b/.kokoro/python3.8/presubmit.cfg index e9c6e483b1c7..f876bd804e68 100644 --- a/.kokoro/python3.8/presubmit.cfg +++ b/.kokoro/python3.8/presubmit.cfg @@ -17,5 +17,5 @@ # Tell the trampoline which build file to use. env_vars: { key: "TRAMPOLINE_BUILD_FILE" - value: "github/python-docs-samples/.kokoro/tests/run_tests_only_diff.sh" + value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh" } diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh index 30bdbce6f26f..b0bd37b04406 100755 --- a/.kokoro/tests/run_tests.sh +++ b/.kokoro/tests/run_tests.sh @@ -20,11 +20,16 @@ set -eo pipefail # Enables `**` to include files nested inside sub-folders shopt -s globstar -# `--only-changed` will only run tests on projects container changes from the master branch. -if [[ $* == *--only-diff* ]]; then - ONLY_DIFF="true" -else - ONLY_DIFF="false" +DIFF_FROM="" + +# `--only-diff-master will only run tests on project changes from the master branch. +if [[ $* == *--only-diff-master* ]]; then + DIFF_FROM="origin/master.." +fi + +# `--only-diff-master will only run tests on project changes from the previous commit. +if [[ $* == *--only-diff-head* ]]; then + DIFF_FROM="HEAD~.." fi cd github/python-docs-samples @@ -66,9 +71,9 @@ for file in **/requirements.txt; do file=$(dirname "$file") cd "$file" - # If $DIFF_ONLY is true, skip projects without changes. - if [[ "$ONLY_DIFF" = "true" ]]; then - git diff --quiet origin/master.. . + # If $DIFF_FROM is set, use it to check for changes in this directory. + if [[ "$DIFF_FROM" != "" ]]; then + git diff --quiet "$DIFF_FROM" . CHANGED=$? if [[ "$CHANGED" -eq 0 ]]; then # echo -e "\n Skipping $file: no changes in folder.\n" @@ -105,9 +110,9 @@ for file in **/requirements.txt; do nox -s "$RUN_TESTS_SESSION" EXIT=$? - # If this is a continuous build, send the test log to the Build Cop Bot. + # If this is a periodic build, send the test log to the Build Cop Bot. # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop. - if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop $KOKORO_GFILE_DIR/linux_amd64/buildcop fi diff --git a/.kokoro/tests/run_tests_only_diff.sh b/.kokoro/tests/run_tests_diff_head.sh similarity index 94% rename from .kokoro/tests/run_tests_only_diff.sh rename to .kokoro/tests/run_tests_diff_head.sh index 60bc46f54169..f1594235df27 100755 --- a/.kokoro/tests/run_tests_only_diff.sh +++ b/.kokoro/tests/run_tests_diff_head.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. mydir="${0%/*}" -"$mydir"/run_tests.sh --only-diff \ No newline at end of file +"$mydir"/run_tests.sh --only-diff-head \ No newline at end of file diff --git a/.kokoro/tests/run_tests_diff_master.sh b/.kokoro/tests/run_tests_diff_master.sh new file mode 100755 index 000000000000..defbb578bae4 --- /dev/null +++ b/.kokoro/tests/run_tests_diff_master.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +mydir="${0%/*}" +"$mydir"/run_tests.sh --only-diff-master \ No newline at end of file