Skip to content

ci(ci): pin commitlint once and run the same hook in CI - #181

Merged
MarTrepodi merged 1 commit into
developfrom
ci/pin-commitlint
Oct 13, 2026
Merged

MarTrepodi merged 1 commit into
developfrom
ci/pin-commitlint

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

Description

Local and CI commitlint had drifted into three different versions:

Where @commitlint/cli config-conventional Why
pre-commit hook (before) 19.8.1 20.5.0 third-party rev v9.21.0 ships a ^19.7.1 range (its lockfile isn't honoured); additional_dependencies unpinned
CI (before) 21.2.3 21.2.3 unpinned npm install -g
both (after) 21.2.3 21.2.3 pinned once in .pre-commit-config.yaml, Node 24.21.0

Rules really do differ across those majors. In 19.x subject-exclamation-mark rejects !: anywhere in the header. In 21.x it only looks right after the type/scope (relevant to #174, which enables that rule).

 .pre-commit-config.yaml
-  repo: alessandrojcm/commitlint-pre-commit-hook @ v9.21.0   (cli ^19, preset unpinned)
+  repo: local · id: commitlint · language: node
+    language_version: 24.21.0                     # commitlint 21 needs Node >= 22.12
+    additional_dependencies: @commitlint/cli@21.2.3, @commitlint/config-conventional@21.2.3
 .github/workflows/commitlint.yml
-  npm install -g @commitlint/{cli,config-conventional}
-  git log -1 --format=%B $sha | npx commitlint --verbose
+  setup-uv · actions/cache ~/.cache/pre-commit (key: hash of .pre-commit-config.yaml)
+  git log -1 --format=%B $sha > $RUNNER_TEMP/COMMIT_EDITMSG
+  uvx pre-commit run commitlint --hook-stage commit-msg --commit-msg-filename …

The PR-unique commit selection, which skips merges and anything already on main, is unchanged. Only the linter invocation moved.

Related Issues

Follow-up to #174, where the local and CI commitlint gave different verdicts on the same subject.

Type of Change

  • CI / build / dependencies

Checklist

  • This PR targets the develop branch
  • My commits follow the Conventional Commits / Angular convention
  • I have not edited CHANGELOG.md by hand
  • I have updated the docs (CONTRIBUTING.md: project tree comment, where versions are pinned)
  • I have not bundled unrelated changes in this PR
  • N/A: no src/ changes, so no unit tests / pytest / ty run

Testing

Run locally through pre-commit with the new hook:

  • Resolved environment: node v24.21.0, @commitlint/cli 21.2.3, @commitlint/config-conventional 21.2.3
  • feat(core): add thing → exit 0 · nope → exit 1 (subject-empty, type-empty) · feat(nosuchscope): add → exit 0 with the scope-enum warning
  • Ran the workflow's exact per-commit loop over this branch's commits → rc=0
  • This PR's own commit was linted by the new hook at commit-msg time

Merge danger: two-way door, revert restores the old hook and npm step. The blast radius is contributor setup: on the first commit after pulling, pre-commit builds the new hook environment and downloads Node 24.21.0 once (~30 MB). No system Node is required any more. Versions are no longer updated automatically, so bump cli and config-conventional together by hand.

🤖 Generated with Claude Code

The local hook (third-party rev v9.21.0) resolved @commitlint/cli 19.8.1
with an unpinned config-conventional 20.5.0, while CI installed whatever
npm served (21.2.3 of both). Rules such as subject-exclamation-mark
behave differently across those majors.

Replace the third-party hook with a local node hook that pins cli,
config-conventional and Node exactly, and have the Commit Lint workflow
run that hook through pre-commit instead of its own npm install. The
hook environment is cached on the config's hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation ci Changes related to continuous integration processes labels Oct 13, 2026
@MarTrepodi
MarTrepodi merged commit 1e7f831 into develop Oct 13, 2026
16 checks passed
@MarTrepodi
MarTrepodi deleted the ci/pin-commitlint branch October 13, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Changes related to continuous integration processes documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant