Skip to content
Draft
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
18 changes: 14 additions & 4 deletions .kokoro/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,24 @@ for path in `find 'packages' \
package_path="packages/${package_name}"

# Determine if we should skip based on git diff
files_to_check="${package_path}/CHANGELOG.md"
# We always check for changes in these specific versioning/config files
files_to_check=(
"${package_path}/CHANGELOG.md"
"${package_path}/setup.py"
"${package_path}/pyproject.toml"
"${package_path}/**/gapic_version.py"
"${package_path}/**/version.py"
)

# If the package is in our "always run full system tests" list, check the whole directory
if [[ $package_name == @($packages_with_system_tests_pattern) ]]; then
files_to_check="${package_path}"
files_to_check=("${package_path}")
fi

echo "checking changes with 'git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- ${files_to_check}'"
echo "checking changes with 'git diff ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} -- ${files_to_check[*]}'"
set +e
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- ${files_to_check} | wc -l)
# Passing the array expanded as arguments to git diff
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- "${files_to_check[@]}" | wc -l)
Comment on lines +150 to +153
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using git diff without output-limiting flags generates the full patch content, which is inefficient when you only need to determine if any changes occurred. Adding the --name-only flag improves performance by only retrieving the list of changed filenames, which is sufficient for the wc -l check. Additionally, ensure that the PR commit and target branch are properly fetched, as pull requests can originate from forked repositories.

Suggested change
echo "checking changes with 'git diff ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} -- ${files_to_check[*]}'"
set +e
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- ${files_to_check} | wc -l)
# Passing the array expanded as arguments to git diff
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- "${files_to_check[@]}" | wc -l)
echo "checking changes with 'git diff --name-only ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} -- ${files_to_check[*]}'"
set +e
# Passing the array expanded as arguments to git diff
package_modified=$(git diff --name-only "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- "${files_to_check[@]}" | wc -l)
References
  1. When fetching a specific commit in a Git repository, consider that pull requests can originate from forked repositories, which might affect how the commit is fetched.

set -e

if [[ "${package_modified}" -gt 0 || "$KOKORO_BUILD_ARTIFACTS_SUBDIR" == *"continuous"* ]]; then
Expand Down
1 change: 1 addition & 0 deletions packages/google-auth/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[mypy]
python_version = 3.9
namespace_packages = True

1 change: 1 addition & 0 deletions packages/google-cloud-dlp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

version = None


with open(os.path.join(package_root, "google/cloud/dlp/gapic_version.py")) as fp:
version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read())
assert len(version_candidates) == 1
Expand Down
Loading