fix(ci): compare coverage against merge-base commit, not latest main#2117
fix(ci): compare coverage against merge-base commit, not latest main#2117jordanstephens wants to merge 1 commit into
Conversation
Dependabot PRs (and any branch that diverges from main) were failing the coverage regression check because the baseline was always the most recent main artifact. If new tested code landed on main after the branch was created, coverage on main would rise while the branch stayed flat. Instead, find the GitHub Actions run whose head_sha matches the git merge-base of the PR branch and main, and download the coverage artifact from that specific run. This ensures the comparison is always branch-point vs. branch, not latest-main vs. branch. Falls back gracefully (continue-on-error) when no matching run exists (first run, expired artifact, API error). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe workflow now uses merge-base commit detection to identify the baseline coverage run instead of always pulling from the ChangesCI Coverage Baseline Detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/go.yml (1)
62-63: 💤 Low valueShallow clone depth may prevent merge-base detection for long-lived branches.
With
actions/checkoutdefaulting tofetch-depth: 1and main fetched with--depth=50, the merge-base may not be reachable if the branch diverged more than ~50 commits ago. This would silently trigger the fallback (skipping coverage comparison) rather than the intended cases (first run, expired artifact, API error).For Dependabot PRs this should be fine since they fork from recent main commits. Consider increasing the depth or using
--deepenif you want more reliable merge-base detection for older feature branches.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/go.yml around lines 62 - 63, The shallow fetch depth (git fetch origin main --depth=50) can make MERGE_BASE=$(git merge-base HEAD origin/main) fail for long-lived branches; update the workflow to fetch more history (e.g., remove --depth, use a larger --depth, or run git fetch --deepen <n> until merge-base is found) so MERGE_BASE detection in the step that uses MERGE_BASE=$(git merge-base HEAD origin/main) is reliable for older branches while keeping the fallback behavior for true first runs or errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/go.yml:
- Around line 62-63: The shallow fetch depth (git fetch origin main --depth=50)
can make MERGE_BASE=$(git merge-base HEAD origin/main) fail for long-lived
branches; update the workflow to fetch more history (e.g., remove --depth, use a
larger --depth, or run git fetch --deepen <n> until merge-base is found) so
MERGE_BASE detection in the step that uses MERGE_BASE=$(git merge-base HEAD
origin/main) is reliable for older branches while keeping the fallback behavior
for true first runs or errors.
Summary
head_shamatches the git merge-base of the PR branch and main, and downloads the coverage artifact from that specific run.continue-on-error) when no matching run exists (first run, expired artifact, API error) — identical behavior to before in those cases.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit