Skip to content

Conversation

@G4URAV001
Copy link

@G4URAV001 G4URAV001 commented Apr 25, 2025

📋 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

  • 🐞 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)

ℹ️ 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/cli ⁠
    ⁠ - @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.

Screenshot 2025-04-25 192605
Screenshot 2025-04-25 192644

Summary by CodeRabbit

  • New Features

    • Introduced automated commit message linting to enforce standardized commit conventions.
    • Added Git commit hooks to validate commit messages during the commit process.
    • Provided npm scripts and Commitizen integration for easier creation of compliant commit messages.
  • Documentation

    • Updated README with setup instructions for commit hooks and commit message guidelines.
  • Chores

    • Added Node.js-related entries to the ignore list for improved project hygiene.

@coderabbitai
Copy link

coderabbitai bot commented Apr 25, 2025

Walkthrough

This 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 .gitignore is extended to cover Node.js-related artifacts, and a new GitHub Actions workflow is established to enforce commit message standards on pull requests. The README is updated with detailed instructions for setting up and using the new commit hooks and conventions.

Changes

File(s) Change Summary
.github/workflows/commit-lint.yml Added a GitHub Actions workflow to lint commit messages on pull request events using Commitlint.
.gitignore Appended Node.js-specific ignore rules for node_modules/ and npm-debug.log.
.husky/commit-msg Introduced a Husky commit-msg hook to run Commitlint on commit messages.
README.md Added documentation on setting up commit hooks, prerequisites, and commit message conventions.
commitlint.config.js Added Commitlint configuration enforcing Conventional Commits rules and allowed types.
package.json Introduced project metadata, scripts, Commitizen configuration, and devDependencies for commit linting tools.

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
Loading

Possibly related issues

Poem

In the warren where code is neat,
Commit hooks now hop to greet!
Husky guards each message sent,
Commitlint sniffs for good intent.
With Commitizen, we write with flair,
GitHub Actions checks with care—
Our code garden’s tidy, everywhere!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@G4URAV001
Copy link
Author

G4URAV001 commented Apr 25, 2025

Created this as the Assigned person PR was not merged and had issue, also it been some time since then
cc: @drtechie @Sneha6003 @VedantKhairnar

@sonarqubecloud
Copy link

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: 2

🧹 Nitpick comments (7)
.gitignore (2)

41-41: Remove trailing space in ignore pattern
There's an unintended trailing space on app.log which may prevent the pattern from matching correctly.

- app.log 
+ app.log

45-45: Remove trailing space in ignore pattern
Similarly, npm-debug.log has 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 Constraints

You’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 Enforcement

The 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 Whitespace

Line 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

📥 Commits

Reviewing files that changed from the base of the PR and between c3323d0 and 1d8d3f3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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 Configuration

The module.exports and extending of @commitlint/config-conventional correctly establish the Conventional Commits baseline.


4-7: Approve: Body & Footer Formatting Rules

Requiring 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 Limit

Enforcing a maximum of 100 characters for the header aligns with best practices for commit message summaries.

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.

[C4GT Community]: Implement Commit Message Linting and Automation for Inventory-API

1 participant