Skip to content

ci(commitlint): check PR commits against PR base ref#8234

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/commitlint-workflow-pr-base-ref
Jun 3, 2026
Merged

ci(commitlint): check PR commits against PR base ref#8234
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/commitlint-workflow-pr-base-ref

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 3, 2026

Summary

.github/workflows/commitlint.yml uses actions/checkout@v6 with no ref: argument. For pull_request_target events, that defaults to the target repo's default branch (main), not the PR base.

The workflow then computes merge-base HEAD pr_head where HEAD=main and walks rev-list forward to pick the "first PR commit". Because main and 4.3 diverged long ago, that walk picks the oldest 4.3 commit since divergence — currently fix(graphiql): migrate to v5 via esm.sh CDN (#8209). Scope graphiql is not in .commitlintrc → the check fails on every PR against 4.3.

Fix

Set ref: ${{ github.event.pull_request.base.ref }} on the checkout step so HEAD becomes the PR's actual base (e.g. 4.3). The existing shell logic for merge-base + rev-list is then correct.

Reproduction

Any PR against 4.3 since the workflow landed has hit this — see commitlint runs on #8226, #8229#8233.

Test plan

  • CI confirms commitlint passes on this PR (the first commit of which is itself a valid ci(commitlint): ... message).

…lt branch

The workflow uses `actions/checkout@v6` on `pull_request_target` without a
`ref:` argument. That defaults to the target repo's default branch (`main`),
not the PR's base ref. The shell step then computes `merge-base HEAD pr_head`
where HEAD is `main` and walks `rev-list` forward to pick the "first PR
commit". Because `main` and `4.3` diverged long ago, the walk picks the
oldest `4.3` commit since divergence rather than the actual first PR commit,
making commitlint fail on every PR against `4.3` (currently flagging
`fix(graphiql): ...` whose scope is not in `.commitlintrc`).

Set `ref: ${{ github.event.pull_request.base.ref }}` on the checkout step so
HEAD is the PR's actual base. The existing merge-base + rev-list logic is
then correct.

Fixes the commitlint check failing on every PR against 4.3 by flagging unrelated 4.3 commits.
@soyuka soyuka merged commit 2e3ee78 into api-platform:4.3 Jun 3, 2026
105 of 106 checks passed
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