Skip to content

fix(ci): never auto-merge an untested head in dependabot-auto-merge#29

Merged
leMaur merged 1 commit into
mainfrom
fix/dependabot-auto-merge-rebase-race
Jun 1, 2026
Merged

fix(ci): never auto-merge an untested head in dependabot-auto-merge#29
leMaur merged 1 commit into
mainfrom
fix/dependabot-auto-merge-rebase-race

Conversation

@leMaur

@leMaur leMaur commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Problem

The dependabot auto-merge workflow validates that the test run for the PR's head.sha succeeded, then merges. But between that check and gh pr merge, Dependabot can rebase the PR onto a new head. The merge would then land a head we never tested.

The rationale comment was also stale — it claimed the workflow avoids branch protection because other workflows push directly to main. That's no longer true: the style check is read-only and the changelog update is PR-based, and main is protected.

Fix

  • Pass --match-head-commit "$HEAD_SHA" to gh pr merge. If the head moved after validation, the merge is refused rather than landing an untested commit.
  • Add timeout-minutes: 30 to the job so the test-polling loop can't hang indefinitely.
  • Rewrite the rationale comment to match reality: main is protected (signed commits, linear history, PR required) but has no required status checks, so the test gate is enforced here in the workflow. A GitHub squash-merge keeps history linear and is signed.

No behavioural change for the normal case (tests pass, head unchanged → merge proceeds); it only closes the rebase race.

Pass --match-head-commit to `gh pr merge` so the merge is refused if
Dependabot rebases the PR after the test run we validated. Without it,
a rebase between the test-result check and the merge could land an
untested head on main.

Add a 30-minute job timeout so the test-polling loop can't hang, and
correct the rationale comment: main is protected (signed commits,
linear history, PR required) but has no required status checks, which
is why the test gate is enforced in this workflow rather than by branch
protection.
@leMaur leMaur merged commit 84d6dab into main Jun 1, 2026
26 checks passed
@leMaur leMaur deleted the fix/dependabot-auto-merge-rebase-race branch June 1, 2026 19:08
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.

1 participant