diff --git a/.kokoro/test-samples-impl.sh b/.kokoro/test-samples-impl.sh index 5a0f5fab6a..776365a831 100755 --- a/.kokoro/test-samples-impl.sh +++ b/.kokoro/test-samples-impl.sh @@ -20,6 +20,8 @@ set -eo pipefail # Enables `**` to include files nested inside sub-folders shopt -s globstar +DIFF_FROM="origin/main..." + # Exit early if samples don't exist if ! find samples -name 'requirements.txt' | grep -q .; then echo "No tests run. './samples/**/requirements.txt' not found" @@ -71,6 +73,16 @@ for file in samples/**/requirements.txt; do file=$(dirname "$file") cd "$file" + # If $DIFF_FROM is set, use it to check for changes in this directory. + if [[ -n "${DIFF_FROM:-}" ]]; then + git diff --quiet "$DIFF_FROM" . + CHANGED=$? + if [[ "$CHANGED" -eq 0 ]]; then + # echo -e "\n Skipping $file: no changes in folder.\n" + continue + fi + fi + echo "------------------------------------------------------------" echo "- testing $file" echo "------------------------------------------------------------" diff --git a/owlbot.py b/owlbot.py index 7c249527b2..f2251da864 100644 --- a/owlbot.py +++ b/owlbot.py @@ -137,6 +137,7 @@ def get_staging_dirs( ".github/workflows", # exclude gh actions as credentials are needed for tests "README.rst", ".github/release-please.yml", + ".kokoro/test-samples-impl.sh", ], )