From d83ca560253b46ac014a77920503f735564c88c2 Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Thu, 13 Aug 2026 17:53:16 +0000 Subject: [PATCH 1/3] fix(ci): preserve target branch history for import profiler baseline generation Avoid shallow-fetching origin/${TARGET_BRANCH} when TEST_TYPE is import_profile so git merge-base can successfully find baseline commits for baseline profiling comparison. --- ci/run_conditional_tests.sh | 6 +++++- ci/run_single_test.sh | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/run_conditional_tests.sh b/ci/run_conditional_tests.sh index 1f8affbc710e..fc17e4977069 100755 --- a/ci/run_conditional_tests.sh +++ b/ci/run_conditional_tests.sh @@ -54,7 +54,11 @@ elif [[ ${BUILD_TYPE} == "presubmit" ]]; then # For presubmit build, we want to know the difference from the # common commit in the target branch. if [ -n "${TARGET_BRANCH}" ]; then - git fetch origin "${TARGET_BRANCH}" --depth=200 || true + if [[ "${TEST_TYPE}" == "import_profile" ]]; then + git fetch origin "${TARGET_BRANCH}" || true + else + git fetch origin "${TARGET_BRANCH}" --depth=200 || true + fi fi GIT_DIFF_ARG="origin/${TARGET_BRANCH}..." diff --git a/ci/run_single_test.sh b/ci/run_single_test.sh index 16826476f26b..ab2a44a0f250 100755 --- a/ci/run_single_test.sh +++ b/ci/run_single_test.sh @@ -138,6 +138,10 @@ case ${TEST_TYPE} in BASELINE_CSV="${PROFILER_TEMP_DIR}/baseline_${PACKAGE_NAME}.csv" if [ -n "${TARGET_BRANCH}" ]; then + # Fetch history for origin/${TARGET_BRANCH} without --depth=1 in case it was shallowly fetched + if [ -f "$(git rev-parse --git-dir)/shallow" ]; then + git fetch origin "${TARGET_BRANCH}" --unshallow 2>/dev/null || git fetch origin "${TARGET_BRANCH}" 2>/dev/null || true + fi # Try upstream first (for forks), then origin BASELINE_COMMIT=$(git merge-base HEAD "upstream/${TARGET_BRANCH}" 2>/dev/null || \ git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \ From b7a5656c1d0d39e88712130872b1c85e93e02b5b Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Thu, 13 Aug 2026 17:58:14 +0000 Subject: [PATCH 2/3] fix(ci): support upstream remote in unshallow fetch for import profiler baseline Attempt fetching from upstream before falling back to origin to properly support fork repositories. --- ci/run_conditional_tests.sh | 4 ++-- ci/run_single_test.sh | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/run_conditional_tests.sh b/ci/run_conditional_tests.sh index fc17e4977069..238a4e483245 100755 --- a/ci/run_conditional_tests.sh +++ b/ci/run_conditional_tests.sh @@ -55,9 +55,9 @@ elif [[ ${BUILD_TYPE} == "presubmit" ]]; then # common commit in the target branch. if [ -n "${TARGET_BRANCH}" ]; then if [[ "${TEST_TYPE}" == "import_profile" ]]; then - git fetch origin "${TARGET_BRANCH}" || true + git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || git fetch origin "${TARGET_BRANCH}" || true else - git fetch origin "${TARGET_BRANCH}" --depth=200 || true + git fetch upstream "${TARGET_BRANCH}" --depth=200 2>/dev/null || git fetch origin "${TARGET_BRANCH}" --depth=200 || true fi fi GIT_DIFF_ARG="origin/${TARGET_BRANCH}..." diff --git a/ci/run_single_test.sh b/ci/run_single_test.sh index ab2a44a0f250..318f651ce709 100755 --- a/ci/run_single_test.sh +++ b/ci/run_single_test.sh @@ -138,9 +138,12 @@ case ${TEST_TYPE} in BASELINE_CSV="${PROFILER_TEMP_DIR}/baseline_${PACKAGE_NAME}.csv" if [ -n "${TARGET_BRANCH}" ]; then - # Fetch history for origin/${TARGET_BRANCH} without --depth=1 in case it was shallowly fetched + # Fetch history for the target branch without --depth=1 in case it was shallowly fetched if [ -f "$(git rev-parse --git-dir)/shallow" ]; then - git fetch origin "${TARGET_BRANCH}" --unshallow 2>/dev/null || git fetch origin "${TARGET_BRANCH}" 2>/dev/null || true + git fetch upstream "${TARGET_BRANCH}" --unshallow 2>/dev/null || \ + git fetch origin "${TARGET_BRANCH}" --unshallow 2>/dev/null || \ + git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || \ + git fetch origin "${TARGET_BRANCH}" 2>/dev/null || true fi # Try upstream first (for forks), then origin BASELINE_COMMIT=$(git merge-base HEAD "upstream/${TARGET_BRANCH}" 2>/dev/null || \ From 3bbbf4f5cda434ff38c5f2887c530db4ddcb924c Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Thu, 13 Aug 2026 18:34:33 +0000 Subject: [PATCH 3/3] refactor(ci): target origin directly with explicit refspec for baseline fetching Address PR review feedback: - Explicitly pass ${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH} to git fetch to update remote tracking branch refs. - Target origin directly and fall back to HEAD if merge-base fails. --- ci/run_conditional_tests.sh | 4 ++-- ci/run_single_test.sh | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ci/run_conditional_tests.sh b/ci/run_conditional_tests.sh index 238a4e483245..36f2af877db7 100755 --- a/ci/run_conditional_tests.sh +++ b/ci/run_conditional_tests.sh @@ -55,9 +55,9 @@ elif [[ ${BUILD_TYPE} == "presubmit" ]]; then # common commit in the target branch. if [ -n "${TARGET_BRANCH}" ]; then if [[ "${TEST_TYPE}" == "import_profile" ]]; then - git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || git fetch origin "${TARGET_BRANCH}" || true + git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" || true else - git fetch upstream "${TARGET_BRANCH}" --depth=200 2>/dev/null || git fetch origin "${TARGET_BRANCH}" --depth=200 || true + git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --depth=200 || true fi fi GIT_DIFF_ARG="origin/${TARGET_BRANCH}..." diff --git a/ci/run_single_test.sh b/ci/run_single_test.sh index 318f651ce709..514cc5c2b16e 100755 --- a/ci/run_single_test.sh +++ b/ci/run_single_test.sh @@ -140,15 +140,12 @@ case ${TEST_TYPE} in if [ -n "${TARGET_BRANCH}" ]; then # Fetch history for the target branch without --depth=1 in case it was shallowly fetched if [ -f "$(git rev-parse --git-dir)/shallow" ]; then - git fetch upstream "${TARGET_BRANCH}" --unshallow 2>/dev/null || \ - git fetch origin "${TARGET_BRANCH}" --unshallow 2>/dev/null || \ - git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || \ - git fetch origin "${TARGET_BRANCH}" 2>/dev/null || true + git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --unshallow 2>/dev/null || \ + git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" 2>/dev/null || true fi - # Try upstream first (for forks), then origin - BASELINE_COMMIT=$(git merge-base HEAD "upstream/${TARGET_BRANCH}" 2>/dev/null || \ - git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \ - git merge-base HEAD "${TARGET_BRANCH}" 2>/dev/null || true) + # Try origin first, then fallback to HEAD if everything else fails + BASELINE_COMMIT=$(git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \ + git rev-parse HEAD) if [ -n "${BASELINE_COMMIT}" ]; then echo "Checking out baseline commit ${BASELINE_COMMIT} in a temporary worktree..." REPO_PREFIX=$(git rev-parse --show-prefix)