Skip to content

fix(ci): preserve target branch history for import profiler baseline generation - #18105

Merged
hebaalazzeh merged 3 commits into
mainfrom
fix/import-profiler-baseline-merge-base
Aug 13, 2026
Merged

fix(ci): preserve target branch history for import profiler baseline generation#18105
hebaalazzeh merged 3 commits into
mainfrom
fix/import-profiler-baseline-merge-base

Conversation

@hebaalazzeh

Copy link
Copy Markdown
Contributor

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.

…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.
@hebaalazzeh hebaalazzeh self-assigned this Aug 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the CI scripts to handle shallow clones and fetch target branches more reliably. The review feedback correctly points out that the unshallow fetch logic in 'ci/run_single_test.sh' should also support forks by attempting to fetch from the 'upstream' remote before falling back to 'origin'.

Comment thread ci/run_single_test.sh Outdated
…er baseline

Attempt fetching from upstream before falling back to origin to properly support fork repositories.
Comment on lines +57 to +61
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || git fetch origin "${TARGET_BRANCH}" || true
else
git fetch upstream "${TARGET_BRANCH}" --depth=200 2>/dev/null || git fetch origin "${TARGET_BRANCH}" --depth=200 || true
fi

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.

Suggested change
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch upstream "${TARGET_BRANCH}" 2>/dev/null || git fetch origin "${TARGET_BRANCH}" || true
else
git fetch upstream "${TARGET_BRANCH}" --depth=200 2>/dev/null || git fetch origin "${TARGET_BRANCH}" --depth=200 || true
fi
if [[ "${TEST_TYPE}" == "import_profile" ]]; then
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" || true
else
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" --depth=200 || true
fi

Since we do not need to support external forks upstream, we can target origin directly. Gemini also suggested this edit

Comment thread ci/run_single_test.sh
Comment on lines +141 to +147
# 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
fi

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.

Similar feedback as my other comment

Suggested change
# 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
fi
# 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}:refs/remotes/origin/${TARGET_BRANCH}" --unshallow 2>/dev/null || \
git fetch origin "${TARGET_BRANCH}:refs/remotes/origin/${TARGET_BRANCH}" 2>/dev/null || true
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Simplified the unshallow fetch to target origin directly with the explicit refspec.

Comment thread ci/run_single_test.sh Outdated

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.

Since we don't need to support upstream, we can use

                # 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! Updated to check origin/${TARGET_BRANCH} directly and fallback to git rev-parse HEAD.

…ne 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.
@parthea
parthea marked this pull request as ready for review August 13, 2026 18:37
@parthea
parthea requested a review from a team as a code owner August 13, 2026 18:37
@hebaalazzeh
hebaalazzeh enabled auto-merge (squash) August 13, 2026 18:39
@hebaalazzeh
hebaalazzeh merged commit 5325595 into main Aug 13, 2026
39 checks passed
@hebaalazzeh
hebaalazzeh deleted the fix/import-profiler-baseline-merge-base branch August 13, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants