-
Notifications
You must be signed in to change notification settings - Fork 5
52 lines (45 loc) · 1.86 KB
/
Copy pathcommitlint.yml
File metadata and controls
52 lines (45 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Commitlint
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
commitlint:
name: Lint Commit Messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
# Node 24 LTS, matching the rest of CI (pnpm 11 floor is Node 22.13).
# See docs/release-hardening-decisions.md (Decision 3).
node-version: 24
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Lint only the commits this branch adds, using the merge-base with the
# live origin/main as the lower bound (not the PR's recorded base SHA,
# which goes stale as main moves forward). The merge-base is robust even
# when the branch is behind main: it always resolves to the point where
# this branch diverged, so the range is exactly the new commits.
#
# main MUST be fetched with full history (no --depth). A shallow fetch
# hides the merge-base, so `git log <main>..HEAD` can no longer exclude
# shared history and the range balloons to include unrelated historical
# commits. See docs/release-hardening-plan.md (AC6).
- name: Resolve lint range
id: range
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
git fetch --no-tags origin main:refs/remotes/origin/main
base=$(git merge-base origin/main "$HEAD_SHA")
echo "base=${base}" >> "$GITHUB_OUTPUT"
echo "Linting ${base}..${HEAD_SHA}"
- name: Lint commits
run: pnpm exec commitlint --from ${{ steps.range.outputs.base }} --to ${{ github.event.pull_request.head.sha }} --verbose