From d3e9d463c2540aa63e13577f3c8ca01aa4e60541 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mon, 22 Jun 2026 11:19:48 -0400 Subject: [PATCH] fix(ci): lint individual commits on PRs to catch invalid prefixes early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merge queue uses merge (not squash), so individual commit messages matter. Previously, commit-lint only checked the PR title on pull_request events and deferred per-commit linting to merge_group. This meant invalid prefixes (like `style`) only surfaced when the merge queue rejected the PR — too late for contributors to fix easily. Now commit-lint checks individual commits on pull_request events too, giving early feedback before the merge queue. Assisted-by: Claude Opus 4.6 Signed-off-by: Ralph Bean --- .github/workflows/lint.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bbba68a62..8ab6bec99 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -52,8 +52,10 @@ jobs: files: coverage.out commit-lint: - # On pull_request: lint the PR title (which becomes the merge commit - # subject on squash-merge). On push/merge_group: lint each commit. + # Lint the PR title and individual commits on pull_request. + # Lint each commit on push/merge_group. + # The merge queue uses merge (not squash), so individual commit + # messages matter — catch bad prefixes before the merge queue rejects them. runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -72,19 +74,21 @@ jobs: uvx --from gitlint-core gitlint --config .gitlint --ignore B6 --msg-filename /tmp/pr-title.txt - name: Lint commits - if: github.event_name != 'pull_request' env: EVENT_NAME: ${{ github.event_name }} PUSH_BEFORE: ${{ github.event.before }} PUSH_AFTER: ${{ github.sha }} MQ_BASE: ${{ github.event.merge_group.base_sha }} MQ_HEAD: ${{ github.event.merge_group.head_sha }} + PR_BASE: ${{ github.event.pull_request.base.sha }} + PR_HEAD: ${{ github.event.pull_request.head.sha }} run: | - if [ "${EVENT_NAME}" = "push" ]; then - RANGE="${PUSH_BEFORE}..${PUSH_AFTER}" - else - RANGE="${MQ_BASE}..${MQ_HEAD}" - fi + case "${EVENT_NAME}" in + push) RANGE="${PUSH_BEFORE}..${PUSH_AFTER}" ;; + merge_group) RANGE="${MQ_BASE}..${MQ_HEAD}" ;; + pull_request) RANGE="${PR_BASE}..${PR_HEAD}" ;; + *) echo "Unknown event: ${EVENT_NAME}"; exit 1 ;; + esac FAILED=false for sha in $(git rev-list --no-merges "${RANGE}"); do