-
Notifications
You must be signed in to change notification settings - Fork 29
feat(inventory-api): implement commit message linting and automation #75
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
WalkthroughThis update introduces a comprehensive commit message linting and automation setup for the project. It adds configuration files and scripts for Commitlint, Husky, and Commitizen, ensuring that all commit messages adhere to the Conventional Commits specification. The Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky
participant Commitlint
participant GitHub Actions
Developer->>Husky: git commit
Husky->>Commitlint: Validate commit message
Commitlint-->>Husky: Pass/Fail
Husky-->>Developer: Allow/Block commit
Developer->>GitHub Actions: Open/Synchronize PR
GitHub Actions->>Commitlint: Lint all PR commit messages
Commitlint-->>GitHub Actions: Pass/Fail
GitHub Actions-->>Developer: PR check result
Possibly related issues
Poem
✨ Finishing Touches
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 (
|
|
Created this as the Assigned person PR was not merged and had issue, also it been some time since then |
|
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 (7)
.gitignore (2)
41-41: Remove trailing space in ignore pattern
There's an unintended trailing space onapp.logwhich may prevent the pattern from matching correctly.- app.log + app.log
45-45: Remove trailing space in ignore pattern
Similarly,npm-debug.loghas a trailing space. Cleaning it up ensures it’s properly ignored.- npm-debug.log + npm-debug.log.github/workflows/commit-lint.yml (1)
30-30: Remove trailing space and add end-of-file newline
YAMLLint reports a trailing space on this line and missing final newline. Removing the extra space and adding a blank line at EOF will satisfy the linter.- npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-file)
[error] 30-30: trailing spaces
(trailing-spaces)
README.md (1)
47-50: Specify fenced code block language
Adding a language identifier (e.g.,bash) after the opening backticks improves readability and enables syntax highlighting.- ``` - node --version - npm --version - ``` + ```bash + node --version + npm --version + ``` ... - ``` - npm ci - ``` + ```bash + npm ci + ```Also applies to: 54-56
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
47-47: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
commitlint.config.js (3)
9-15: Approve & Suggest Optional: Subject ConstraintsYou’ve correctly prohibited certain casing styles and trailing periods, and prevented empty subjects. To tighten further, consider adding a minimum subject length, for example:
'subject-min-length': [1, 'always', 1]
16-34: Approve & Suggest Optional: Type EnforcementThe lowercase, non-empty type rule with a strict enum is well configured. If you use scopes in your commits, you might also enforce consistent scope casing, e.g.:
'scope-case': [2, 'always', 'lower-case']
35-36: Nitpick: Trailing WhitespaceLine 36 ends with an extra space after
};. Removing that whitespace can prevent potential lint warnings in JS linters.
📜 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 (6)
.github/workflows/commit-lint.yml(1 hunks).gitignore(1 hunks).husky/commit-msg(1 hunks)README.md(2 hunks)commitlint.config.js(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-file)
[error] 30-30: trailing spaces
(trailing-spaces)
🪛 LanguageTool
README.md
[uncategorized] ~45-~45: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...
(NODE_JS)
[uncategorized] ~57-~57: Possible missing comma found.
Context: ...``` - This will install all required dependencies including Husky and commitlint 3. **Ve...
(AI_HYDRA_LEO_MISSING_COMMA)
[grammar] ~71-~71: “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] ~74-~74: 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
39-39: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
40-40: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
45-45: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
46-46: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
47-47: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
53-53: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
54-54: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
57-57: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
60-60: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
61-61: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
66-66: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
67-67: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
70-70: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
71-71: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
72-72: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
73-73: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
74-74: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
75-75: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
76-76: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
77-77: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
78-78: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
79-79: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
86-86: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🔇 Additional comments (3)
commitlint.config.js (3)
1-3: Approve: Export and Base ConfigurationThe
module.exportsand extending of@commitlint/config-conventionalcorrectly establish the Conventional Commits baseline.
4-7: Approve: Body & Footer Formatting RulesRequiring a leading blank line before the body/footer and capping their lengths at 100 characters will help maintain clear and concise commit message sections.
8-8: Approve: Header Length LimitEnforcing a maximum of 100 characters for the header aligns with best practices for commit message summaries.



📋 Description
Closes PSMRI/AMRIT#82
JIRA ID: issue link
This PR implements commit message linting and automation for all contributors in the API repositories using Commitlint, Husky, and Commitizen. The aim of this initiative is to enforce a consistent and readable commit history, improving collaboration and enabling future automated changelogs and CI/CD processes. This setup aligns with the practices followed across all C4GT Community repositories.
Every commit in API repositories will follow the defined structure (e.g., Conventional Commits).
Husky will block non-compliant commit messages locally.
Contributors will use Commitizen (cz) to follow a guided commit format.
GitHub Actions will fail PR checks if commit messages do not follow the required format.
All changes will be compatible with the existing CI/CD pipelines, ensuring smooth integration.
✅ Type of Change
ℹ️ Additional Information
• Added commitlint.config.js with conventional commit rules.
• Configured Husky to run Commitlint on every commit via .husky/commit-msg .
• Set up Commitizen with configuration in package.json for interactive commit prompts.
• Added GitHub Actions workflow .github/workflows/commit-lint.yml to check commit messages on PRs.
• Updated package.json and package-lock.json with required dev dependencies:
- @commitlint/config-conventional
- commitizen
- cz-conventional-changelog
Testing & Validation
• Invalid commit messages are blocked locally with clear lint errors.
• Interactive commit flow works via npm run commit or npx cz .
• GitHub Actions workflow correctly fails PRs with non-compliant commit messages.
• No disruption to existing build or CI pipelines.
Summary by CodeRabbit
New Features
Documentation
Chores