Skip to content

Commit 32f352c

Browse files
committed
fix base branch detection in fuzzer jobs
1 parent 7012970 commit 32f352c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

docker/test/fuzzer/run-fuzzer.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,28 @@ function clone
5050
git checkout "$SHA_TO_TEST"
5151
echo "Checked out nominal SHA $SHA_TO_TEST for PR $PR_TO_TEST"
5252
fi
53-
git diff --name-only master HEAD | tee ci-changed-files.txt
53+
# Use BASE_BRANCH from environment variable if available, otherwise fall back to master
54+
if [ -n "$BASE_BRANCH" ]; then
55+
echo "Using base branch from environment: $BASE_BRANCH"
56+
# Fetch the specific base branch first (without depth limit to allow merge-base)
57+
git fetch origin "$BASE_BRANCH" || {
58+
echo "ERROR: Could not fetch base branch: $BASE_BRANCH"
59+
echo "Available remote branches:"
60+
git branch -r
61+
exit 1
62+
}
63+
MERGE_BASE=$(git merge-base HEAD "origin/$BASE_BRANCH" 2>/dev/null || echo "")
64+
if [ -z "$MERGE_BASE" ]; then
65+
echo "ERROR: No merge base found with base branch: $BASE_BRANCH"
66+
echo "Available remote branches:"
67+
git branch -r
68+
exit 1
69+
fi
70+
git diff --name-only "$MERGE_BASE" HEAD | tee ci-changed-files.txt
71+
else
72+
echo "No BASE_BRANCH environment variable, using master"
73+
git diff --name-only master HEAD | tee ci-changed-files.txt
74+
fi
5475
else
5576
if [ -v SHA_TO_TEST ]; then
5677
git fetch --depth 2 origin "$SHA_TO_TEST"

tests/ci/ci_fuzzer_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def get_run_command(
3434
f"-e SHA_TO_TEST={pr_info.sha}",
3535
f"-e BINARY_URL_TO_DOWNLOAD='{build_url}'",
3636
f"-e FUZZER_TO_RUN='{fuzzer_name}'",
37+
f"-e BASE_BRANCH='{pr_info.base_ref}'",
3738
]
3839

3940
env_str = " ".join(envs)

0 commit comments

Comments
 (0)