Skip to content

chore(commitlint): add commit-msg hook and workflow validation#210

Open
DurgaPrasad-54 wants to merge 2 commits intoPSMRI:mainfrom
DurgaPrasad-54:feat/commitlint-setup
Open

chore(commitlint): add commit-msg hook and workflow validation#210
DurgaPrasad-54 wants to merge 2 commits intoPSMRI:mainfrom
DurgaPrasad-54:feat/commitlint-setup

Conversation

@DurgaPrasad-54
Copy link
Contributor

@DurgaPrasad-54 DurgaPrasad-54 commented Mar 6, 2026

📋 Description

JIRA ID:

Add the commit message validation setup by defining the commit rules directly in commitlint.config.js instead of extending @commitlint/config-conventional.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

Summary by CodeRabbit

  • Chores

    • Added automated commit message validation on pull requests to enforce consistent commit standards.
    • Enabled local git hook support so developers can validate commit messages before committing.
  • Documentation

    • Updated README with instructions for enabling local commit hooks and required tooling.

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39ecaa55-e303-41e3-aaf1-27062c50aa9e

📥 Commits

Reviewing files that changed from the base of the PR and between 7371373 and 0aa829e.

📒 Files selected for processing (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

📝 Walkthrough

Walkthrough

Adds commit message linting: a local git commit hook, a commitlint configuration, a GitHub Actions workflow to validate PR commit messages, and README instructions to enable the hooks.

Changes

Cohort / File(s) Summary
Git hooks
\.git-hooks/commit-msg
New shell hook that runs npx @commitlint/cli@20.4.3 --edit "$1" to enforce commit message rules locally.
CI workflow
.github/workflows/commit-lint.yml
New GitHub Actions workflow "Commit Message Check" triggered on PR events; checks out code, sets up Node.js v20, enumerates non-merge commits in the PR, and runs commitlint for each commit message via temporary files.
Commitlint config
commitlint.config.js
New exported module.exports object defining commitlint rules (header/body/footer lengths, subject rules, type-case/enum with allowed types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test).
Docs
README.md
Small formatting fix and added "Setting Up Commit Hooks" instructions with git config core.hooksPath .git-hooks command.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer (local)
  participant Repo as Repository / PR
  participant GH as GitHub Actions Runner
  participant CL as commitlint (via npx)

  Dev->>Repo: Open / update Pull Request
  Note right of Repo: PR event triggers workflow
  Repo->>GH: Start "Commit Message Check" workflow
  GH->>GH: checkout + setup Node.js v20
  GH->>Repo: list commits in PR (exclude merge commits)
  loop for each commit
    GH->>GH: write commit message to temp file
    GH->>CL: run `npx `@commitlint/cli`@20.4.3 --edit temp-file`
    CL-->>GH: exit status (pass/fail)
  end
  GH-->>Repo: report workflow result (success/failure)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through branches, tidy and bright,
Linting each message by moon and by light.
Hooks hum a tune, CI keeps the beat,
Clean commits now march with nimble feet. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(commitlint): add commit-msg hook and workflow validation' clearly summarizes the main changes—adding commit message linting via a git hook and GitHub Actions workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.git-hooks/commit-msg (1)

4-4: Avoid a registry fetch in the commit path.

This one-off npx install makes local commits depend on npm registry availability and duplicates the pinned CLI version in CI. Prefer declaring @commitlint/cli once in repo tooling and invoking the local binary from both the hook and workflow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.git-hooks/commit-msg at line 4, Replace the one-off npx invocation in the
commit hook ("npx --yes `@commitlint/cli`@20.4.3 --edit \"$1\"") with a call to
the repo-local commitlint install: declare `@commitlint/cli` as a devDependency
and expose a script or rely on the local binary, then update the commit hook to
invoke that local binary (or run the package script) with the same --edit "$1"
argument so commits no longer perform an npm registry fetch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 62-64: The README's prerequisites block is missing Node.js/npm
which causes the commit-msg hook (which uses npx to run commitlint) to fail with
"npx: not found"; update the prerequisites section to list Node.js (and npm) as
required tools and add a short note that the git hook setup (see "Setting Up
Commit Hooks" and the command `git config core.hooksPath .git-hooks`) relies on
npx/Node.js so contributors should install Node.js/npm before enabling hooks.

---

Nitpick comments:
In @.git-hooks/commit-msg:
- Line 4: Replace the one-off npx invocation in the commit hook ("npx --yes
`@commitlint/cli`@20.4.3 --edit \"$1\"") with a call to the repo-local commitlint
install: declare `@commitlint/cli` as a devDependency and expose a script or rely
on the local binary, then update the commit hook to invoke that local binary (or
run the package script) with the same --edit "$1" argument so commits no longer
perform an npm registry fetch.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0abccc0-2f0b-4de8-889a-0e97a331e68a

📥 Commits

Reviewing files that changed from the base of the PR and between 690dbee and 7371373.

📒 Files selected for processing (4)
  • .git-hooks/commit-msg
  • .github/workflows/commit-lint.yml
  • README.md
  • commitlint.config.js

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