Skip to content

Commit e1e04d7

Browse files
committed
chore(test): improve diff detection for unit tests
1 parent 1b5c48b commit e1e04d7

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
TEST_ALL_PACKAGES: ${{ steps.check-label.outputs.is_full_run }}
5858
run: |
5959
if [ -n "$TARGET_BRANCH" ]; then
60-
git fetch origin "$TARGET_BRANCH" --depth=1 || true
60+
git fetch origin "$TARGET_BRANCH" --deepen=200 || true
6161
fi
6262
python3 ci/get_package_shards.py
6363

.github/workflows/unittest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
PACKAGE_WEIGHTS: ${{ env.PACKAGE_WEIGHTS }}
7373
run: |
7474
if [ -n "$TARGET_BRANCH" ]; then
75-
git fetch origin "$TARGET_BRANCH" --depth=1 || true
75+
git fetch origin "$TARGET_BRANCH" --deepen=200 || true
7676
fi
7777
python3 ci/get_package_shards.py
7878
@@ -168,8 +168,8 @@ jobs:
168168
echo "should_evaluate_coverage=true" >> "$GITHUB_OUTPUT"
169169
else
170170
TARGET_BRANCH="${TARGET_BRANCH:-main}"
171-
git fetch origin "$TARGET_BRANCH" --depth=1 || true
172-
num_files_changed=$(git diff --name-only "origin/${TARGET_BRANCH}" -- ${PACKAGE_DIRS} | wc -l | tr -d ' ')
171+
git fetch origin "$TARGET_BRANCH" --deepen=200 || true
172+
num_files_changed=$(git diff --name-only "origin/${TARGET_BRANCH}..." -- ${PACKAGE_DIRS} | wc -l | tr -d ' ')
173173
if [[ "${num_files_changed}" -gt 0 ]]; then
174174
echo "should_evaluate_coverage=true" >> "$GITHUB_OUTPUT"
175175
else

ci/get_package_shards.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def get_packages_to_test():
108108
return all_packages
109109

110110
if build_type == 'presubmit':
111-
git_diff_arg = f"origin/{target_branch}"
111+
git_diff_arg = f"origin/{target_branch}..."
112112
elif build_type == 'continuous':
113113
git_diff_arg = "HEAD~1.."
114114
else:

ci/report_coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if [[ "${TEST_ALL_PACKAGES}" == "true" ]]; then
4545
modified_packages=$(for dir in ${PACKAGE_DIRS}; do ls -d ${dir}/*/ 2>/dev/null; done | cut -d/ -f1,2 | sort -u)
4646
elif [[ "${BUILD_TYPE}" == "presubmit" ]]; then
4747
# Presubmit build: evaluate coverage only for packages modified relative to the target branch
48-
modified_packages=$(git diff --name-only "origin/${TARGET_BRANCH}" -- ${PACKAGE_DIRS} 2>/dev/null | cut -d/ -f1,2 | sort -u)
48+
modified_packages=$(git diff --name-only "origin/${TARGET_BRANCH}..." -- ${PACKAGE_DIRS} 2>/dev/null | cut -d/ -f1,2 | sort -u)
4949
else
5050
# Continuous build (post-merge on main): evaluate coverage for packages modified in the last commit
5151
modified_packages=$(git diff --name-only HEAD~1 -- ${PACKAGE_DIRS} 2>/dev/null | cut -d/ -f1,2 | sort -u)

ci/run_conditional_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ elif [[ ${BUILD_TYPE} == "presubmit" ]]; then
5454
# For presubmit build, we want to know the difference from the
5555
# common commit in the target branch.
5656
if [ -n "${TARGET_BRANCH}" ]; then
57-
git fetch origin "${TARGET_BRANCH}" --depth=1 || true
57+
git fetch origin "${TARGET_BRANCH}" --deepen=200 || true
5858
fi
59-
GIT_DIFF_ARG="origin/${TARGET_BRANCH}"
59+
GIT_DIFF_ARG="origin/${TARGET_BRANCH}..."
6060

6161
elif [[ ${BUILD_TYPE} == "continuous" ]]; then
6262
# For continuous build, we want to know the difference in the last

0 commit comments

Comments
 (0)