Skip to content

test: skip sample tests if no changes detected #1106

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

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions .kokoro/test-samples-impl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 "------------------------------------------------------------"
Expand Down
1 change: 1 addition & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down