Skip to content

Commit 480acbf

Browse files
alexeyrclaude
andcommitted
Use GitHub API to get merge-base for workflow_dispatch benchmarks
Instead of fetching history to calculate merge-base locally, use the GitHub compare API which returns it directly. This is faster and works regardless of how far the branch diverged from master. See: https://stackoverflow.com/a/74710919 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 1204082 commit 480acbf

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,17 @@ jobs:
548548
START_POINT_HASH="${{ github.event.pull_request.base.sha }}"
549549
EXTRA_ARGS="--start-point-reset"
550550
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
551-
# Find where branch diverged from master
552-
git fetch origin master --depth=100
551+
# Get merge-base from GitHub API (avoids needing deep fetch)
552+
# See: https://stackoverflow.com/a/74710919
553553
BRANCH="${{ github.ref_name }}"
554554
START_POINT="master"
555-
START_POINT_HASH=$(git merge-base HEAD origin/master)
555+
START_POINT_HASH=$(gh api "repos/${{ github.repository }}/compare/master...$BRANCH" --jq '.merge_base_commit.sha' || true)
556+
557+
if [ -n "$START_POINT_HASH" ]; then
558+
echo "Found merge-base via API: $START_POINT_HASH"
559+
else
560+
echo "⚠️ Could not find merge-base with master via GitHub API, continuing without it"
561+
fi
556562
EXTRA_ARGS=""
557563
else
558564
echo "❌ ERROR: Unexpected event type: ${{ github.event_name }}"

0 commit comments

Comments
 (0)