-
Notifications
You must be signed in to change notification settings - Fork 33
feat(commit-config): Implemented Commit Message Linting and Automation for TM-API #85 #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…ized commit messages
WalkthroughThis change introduces a comprehensive commit message linting and standardization system to the project. It adds configuration and tooling for Commitlint, Husky, and Commitizen, alongside a GitHub Actions workflow to automatically enforce commit message conventions on pull requests. The setup includes a commit message hook for local validation, a configuration file specifying detailed commit message rules, and a package manifest defining dependencies and scripts for managing commit hooks and standardized commit creation. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky (Git Hook)
participant Commitlint
participant GitHub Actions
participant Node.js
Developer->>Husky (Git Hook): git commit
Husky (Git Hook)->>Commitlint: Validate commit message
Commitlint-->>Husky (Git Hook): Pass/Fail
Developer->>GitHub Actions: Open/sync/reopen PR
GitHub Actions->>Node.js: Setup environment
GitHub Actions->>Commitlint: Lint all PR commits
Commitlint-->>GitHub Actions: Pass/Fail
Possibly related issues
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
.husky/commit-msg (1)
1-4: 💡 Verification agent🧩 Analysis chain
Ensure Husky hook environment is loaded
The hook script needs to source Husky’s environment loader (husky.sh) so that thecommit-msghook runs correctly. Also verify the file is executable (chmod +x .husky/commit-msg).Apply this diff to load Husky before running Commitlint:
#!/bin/sh +. "$(dirname "$0")/_/husky.sh" npx --no -- commitlint --edit "$1"Do you want assistance to update the script and confirm its executable bit?
🏁 Script executed:
#!/bin/bash echo "=== Checking .husky/commit-msg ===" if [ -f .husky/commit-msg ]; then ls -l .husky/commit-msg echo "---- First 5 lines ----" head -n 5 .husky/commit-msg else echo ".husky/commit-msg not found" fi echo echo "=== Checking .husky/_/husky.sh ===" if [ -f .husky/_/husky.sh ]; then ls -l .husky/_/husky.sh else echo ".husky/_/husky.sh not found" fiLength of output: 516
🏁 Script executed:
#!/bin/bash echo "=== Searching for any husky.sh references ===" grep -R "husky.sh" -n .Length of output: 124
Source Husky hook loader & make script executable
Yourcommit-msghook currently neither loads Husky’s environment nor is executable. Without sourcinghusky.sh, built‑in Husky helpers (e.g.$HUSKY_GIT_PARAMS) won’t work, and the hook won’t run at all without the +x bit.Please:
- Add the loader invocation at the top of
.husky/commit-msg- Commit or generate
.husky/_/husky.sh(runnpx husky installif missing)- Mark the hook executable
Suggested diff:
--- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,2 +1,3 @@ #!/bin/sh +. "$(dirname "$0")/_/husky.sh" npx --no -- commitlint --edit "$1"Then:
git add .husky/_/husky.sh .husky/commit-msg chmod +x .husky/commit-msg
🧹 Nitpick comments (3)
.github/workflows/commitlint.yml (2)
1-31: Add trailing newline for YAML compliance
YAML parsers and linters typically expect a newline at end‑of‑file. Please add a blank line after the last line to satisfy thenew-line-at-end-of-filerule.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 31-31: no new line character at the end of file
(new-line-at-end-of-file)
21-28: Optimize CI by caching NPM modules
Caching your dependencies can dramatically speed up the workflow and reduce network usage. Consider adding anactions/cachestep between setting up Node.js and installing dependencies.Example diff:
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 18 + - name: Cache NPM modules + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - name: Install dependencies run: npm ci --legacy-peer-depspackage.json (1)
11-12: Enhance package metadata
Consider adding"repository","bugs", and"homepage"fields to improve package discoverability and enable proper links in registries.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/commitlint.yml(1 hunks).husky/commit-msg(1 hunks)commitlint.config.js(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commitlint.yml
[error] 31-31: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (1)
commitlint.config.js (1)
1-36: Commitlint configuration follows conventional commit conventions
The configuration correctly extends@commitlint/config-conventionaland enforces header length, subject-case, and allowed types per the Conventional Commits spec.
|
There was a problem hiding this 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)
README.md (1)
67-70: Specify language for fenced code blocks
The code blocks for verifying Node/npm versions (lines 67–70) and for installing dependencies (lines 73–75) should declare a language (e.g.,bash) to improve readability and enable proper syntax highlighting.- ``` + ```bash node --version npm --version - ``` + ```bash - ``` + ```Also applies to: 73-75
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
67-67: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~65-~65: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...
(NODE_JS)
[grammar] ~87-~87: “Bug” is a singular noun. It appears that the verb form is incorrect.
Context: ... - feat: A new feature - fix: A bug fix - docs: Documentation changes - `styl...
(PCT_SINGULAR_NOUN_PLURAL_VERB_AGREEMENT)
[uncategorized] ~90-~90: Loose punctuation mark.
Context: ... changes (formatting, etc.) - refactor: Code changes that neither fix bugs nor ...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
README.md
67-67: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
73-73: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)



📋 Description
Github Issue Fixes: PSMRI/AMRIT/85
JIRA ID:
This PR introduces commit message standardization for the TM-API project by setting up Commitlint, Husky, and Commitizen. The goal is to enforce a consistent commit message format across the repository to improve collaboration, readability, and enable automation (like changelogs and versioning) in the future.
These tools are now fully integrated:
✅ Type of Change
ℹ️ Additional Information
Added Configuration Files
Dependencies Added
Package.json Updates
Testing Completed
Changes Overview
Commitlint functionality working properly:

Commitzen working proper;y with npx cz command:

Summary by CodeRabbit
New Features
Chores