Skip to content

Commit bb28f49

Browse files
committed
test: skip sample tests if no changes detected
1 parent c25376c commit bb28f49

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.kokoro/test-samples-impl.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ set -eo pipefail
2020
# Enables `**` to include files nested inside sub-folders
2121
shopt -s globstar
2222

23+
DIFF_FROM="origin/main..."
24+
2325
# Exit early if samples don't exist
2426
if ! find samples -name 'requirements.txt' | grep -q .; then
2527
echo "No tests run. './samples/**/requirements.txt' not found"
@@ -71,6 +73,16 @@ for file in samples/**/requirements.txt; do
7173
file=$(dirname "$file")
7274
cd "$file"
7375

76+
# If $DIFF_FROM is set, use it to check for changes in this directory.
77+
if [[ -n "${DIFF_FROM:-}" ]]; then
78+
git diff --quiet "$DIFF_FROM" .
79+
CHANGED=$?
80+
if [[ "$CHANGED" -eq 0 ]]; then
81+
# echo -e "\n Skipping $file: no changes in folder.\n"
82+
continue
83+
fi
84+
fi
85+
7486
echo "------------------------------------------------------------"
7587
echo "- testing $file"
7688
echo "------------------------------------------------------------"

0 commit comments

Comments
 (0)