-
Notifications
You must be signed in to change notification settings - Fork 40
Fix: Implemented Commit Message Linting and Automation for Identity-API Issue#85 #92
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
Some Changes
Implemented Commit Message Linting and Automation for TM-API
Implement Commit Message Linting and Automation for TM-API PSMRI#85
WalkthroughThis update introduces automated commit message linting to the repository. It adds a GitHub Actions workflow to enforce commit message standards on pull requests, sets up Husky to run commit linting as a commit-msg hook, and configures Commitlint using the conventional commit rules. The changes also include a new Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky
participant Commitlint
participant GitHub
participant GitHub Actions
Developer->>Husky: git commit
Husky->>Commitlint: Run commitlint on commit message
Commitlint-->>Husky: Validate message (pass/fail)
Husky-->>Developer: Allow or block commit
Developer->>GitHub: Push PR
GitHub->>GitHub Actions: Trigger commitlint workflow
GitHub Actions->>Commitlint: Lint all PR commit messages
Commitlint-->>GitHub Actions: Report results (pass/fail)
GitHub Actions-->>GitHub: Set PR status
Possibly related issues
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
🪧 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
🧹 Nitpick comments (2)
package.json (1)
6-10: Add a dedicated npm script for commitlint
Providing alint:commitscript makes it easy for contributors to run commit message checks manually:"scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "echo \"Error: no test specified\" && exit 1", + "lint:commit": "commitlint --edit \"$1\"", "prepare": "husky install", "commit": "cz" },commitlint.config.cjs (1)
1-5: Refactor to simplify config export
You can export the conventional config directly for brevity:-const config = require('@commitlint/config-conventional'); - -module.exports = { - ...config, -}; +module.exports = require('@commitlint/config-conventional');
📜 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 (5)
.github/workflows/commitlint.yml(1 hunks).gitignore(1 hunks).husky/commit-msg(1 hunks)commitlint.config.cjs(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/commitlint.yml
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
18-18: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (2)
.gitignore (1)
13-13: Appropriate.gitignoreupdate
Ignoringnode_modules/ensures Node.js dependencies are not committed, which aligns with the newpackage.jsonand prevents repository bloat..github/workflows/commitlint.yml (1)
1-29: Workflow correctly enforces commit message linting
The GitHub Action is well-configured to run commitlint on pull requests, uses official actions (actions/checkout@v3,actions/setup-node@v3), and fails on any warnings. It aligns perfectly with the new commitlint configuration.🧰 Tools
🪛 actionlint (1.7.4)
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
18-18: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
.husky/commit-msg
Outdated
| @@ -0,0 +1 @@ | |||
| npx --no -- commitlint --edit "$1" | |||
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.
Ensure Husky hook script includes the proper header
The hook currently only runs the lint command but is missing the shebang and Husky loader. Without these, it may not execute correctly. Please apply:
+#!/usr/bin/env sh
+. "$(dirname "$0")/_/husky.sh"
npx --no -- commitlint --edit "$1"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| npx --no -- commitlint --edit "$1" | |
| #!/usr/bin/env sh | |
| . "$(dirname "$0")/_/husky.sh" | |
| npx --no -- commitlint --edit "$1" |
|
|
@mohan-bee |
|
@drtechie Sorry mistyped. Renamed ! |



📋 Description
To make commit messages consistent and easy to read across the AMRIT API repositories, I will introduce Commitlint based on the Conventional Commits specification. This will create a standardized guideline for commit messages. I will integrate Husky to ensure that these rules are enforced automatically on every commit, preventing non-conforming messages. To improve the process for contributors, I will add Commitizen, which will prompt users with a simple interface to write valid commit messages. Additionally, I will set up a GitHub Action that will run during every pull request to catch any non-compliant commits before they are merged into the main branch. The implementation will be thoroughly tested in forked branches to ensure smooth integration with the existing CI/CD workflow, ensuring there are no disruptions.
✅ Type of Change
ℹ️ Additional Information
I have tested this approach in forked branches, ensuring compatibility with existing CI/CD workflows. The integration with Husky, Commitizen, and Commitlint was verified and worked smoothly without interrupting current processes. I also ran tests locally to verify that the automated checks were correctly applied to the commit messages.
Proofs
Summary by CodeRabbit