Skip to content
Merged
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
8 changes: 8 additions & 0 deletions ci/run_conditional_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ set -eo pipefail
export PROJECT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/..)
TARGET_BRANCH="${TARGET_BRANCH:-main}"

# Redirect git clones for core dependencies to the local repository.
# This serves two purposes:
# 1. Performance: Avoids repeated 100MB+ downloads of the monorepo for each dependency.
# 2. Correctness: Ensures that changes in core packages (like google-api-core) are
# tested against downstream packages in the same Pull Request.
git config --global url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python"
git config --global url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python.git"
Comment on lines +44 to +45
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.

high

There are two significant issues with this implementation:

  1. Configuration Overwrite: By default, git config replaces the existing value for a key. Line 45 will overwrite the setting from line 44, meaning only URLs ending in .git will be redirected. To support both URL variants, you must use the --add flag for the second command.
  2. Global State Leakage: Using --global modifies the git configuration for the user profile on the CI runner. In environments where runners are reused (e.g., self-hosted runners), this configuration will persist and may interfere with subsequent jobs that expect to clone from the real GitHub repository.

It is recommended to use a trap to ensure the configuration is unset when the script exits, and to use --add for the second configuration entry.

Suggested change
git config --global url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python"
git config --global url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python.git"
git config --global url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python"
git config --global --add url."${PROJECT_ROOT}".insteadOf "https://github.com/googleapis/google-cloud-python.git"
trap 'git config --global --unset-all url."${PROJECT_ROOT}".insteadOf' EXIT


# A script file for running the test in a sub project.
test_script="${PROJECT_ROOT}/ci/run_single_test.sh"

Expand Down
Loading