tests: ensure system test presubmit runs in release PRs regardless if CHANGELOG is modified#16916
tests: ensure system test presubmit runs in release PRs regardless if CHANGELOG is modified#16916
CHANGELOG is modified#16916Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the .kokoro/system.sh script to use an array for files_to_check, expanding the set of files monitored for changes to include setup.py, pyproject.toml, and versioning files. It is recommended to use the --name-only flag with git diff to improve efficiency, as the script only requires a count of changed files rather than the full diff content.
| 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) |
There was a problem hiding this comment.
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.
| 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
- 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.
CHANGELOG is changedCHANGELOG is modified
Fixes #16905