-
Notifications
You must be signed in to change notification settings - Fork 17
feat(git-hooks): setup Commitlint, Husky, and Commitizen for standardized commit messages #62 #94
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
Conversation
…ized commit messages PSMRI#62 Performing this for HWC-UI
WalkthroughThis pull request implements commit message validation across the repository. A GitHub Actions workflow is added to run commit message linting on pull request events. In addition, a Husky commit hook is configured to enforce commitlint rules locally, supported by a new commitlint configuration file. The package.json is updated with Commitizen integration and relevant dependencies, ensuring standardized commit messages during both local commits and pull request validations. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Git
participant HuskyHook as Husky Hook
participant Commitlint
Developer->>Git: Create commit
Git->>HuskyHook: Trigger commit-msg hook
HuskyHook->>Commitlint: Execute commitlint with commit message file
Commitlint-->>HuskyHook: Return validation result
HuskyHook-->>Git: Allow or reject commit
sequenceDiagram
participant Developer
participant GHActions as GitHub Actions
participant NodeEnv as Node Environment
participant Commitlint
Developer->>GHActions: Open Pull Request
GHActions->>NodeEnv: Checkout repo, setup Node.js, install dependencies
NodeEnv->>Commitlint: Run commitlint on commit range
Commitlint-->>NodeEnv: Return validation result
NodeEnv-->>GHActions: Log output and status
GHActions-->>Developer: Report PR validation result
Assessment against linked issues
Possibly related issues
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
🪧 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: 1
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
16-19: Add newline at end of fileThe file is missing a newline at the end, which is considered a best practice for text files.
echo "Validating commit messages against conventional commits standard..." npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
📜 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/commit-lint.yml(1 hunks).husky/commit-msg(1 hunks)commitlint.config.js(1 hunks)package.json(2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (7)
.husky/commit-msg (1)
1-4: Good implementation of the commit message hook!The script correctly sets up the Git hook to validate commit messages using commitlint. It uses the proper shebang line, sources the Husky setup script, and passes the commit message file to commitlint for validation.
commitlint.config.js (1)
1-36: Well-defined commitlint configuration!The configuration extends the conventional commits standard and sets appropriate rules for message formatting. The type enumeration covers all common commit types, and the severity levels are reasonably set.
.github/workflows/commit-lint.yml (1)
1-19: Great workflow implementation for CI validationThe GitHub Actions workflow is properly configured to validate commit messages for pull requests. It correctly sets up the environment, installs dependencies, and runs commitlint against the PR commits.
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
package.json (4)
13-13: Good addition of Commitizen scriptAdding the
commitscript provides an easy way for developers to create standardized commit messages through the Commitizen interactive CLI.
19-23: Proper Commitizen configurationThe configuration correctly sets up Commitizen to use the conventional changelog format.
75-76: Appropriate dependencies addedThe added dependencies for commitlint and Commitizen are necessary for the commit standardization features and use appropriate versions.
Also applies to: 81-82
67-97:Details
✅ Verification successful
Verify Node.js compatibility
The GitHub Actions workflow uses Node.js 16, but your Angular version (16.x) is compatible with newer Node.js versions. Consider ensuring consistent Node.js version usage across your CI workflow and local development environment.
🏁 Script executed:
#!/bin/bash # Check the Angular version and suggested Node.js compatibility echo "Checking Angular dependencies versions and Node.js compatibility..." grep -A 5 "@angular/core" package.json echo "Angular 16.x is compatible with Node.js 16.x, 18.x (recommended)"Length of output: 571
Ensure Consistent Node.js Version Usage
The verification confirms that your Angular dependencies are set to 16.x (e.g.,
@angular/coreis at^16.2.0), and as noted, Angular 16.x is compatible with both Node.js 16.x and 18.x. Since the GitHub Actions workflow is currently using Node.js 16, please ensure that your local development environment uses a consistent Node.js version. This alignment will help prevent any subtle differences between CI and local runs.
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: 0
♻️ Duplicate comments (1)
.github/workflows/commit-lint.yml (1)
11-14: 🛠️ Refactor suggestionUpdate Node.js Version for Enhanced Security and Support
The workflow is currently configured to use Node.js version '16', which has reached end-of-life. Upgrading to a supported LTS version (e.g., '18' or '20') would improve both security and compatibility.
- node-version: '16' + node-version: '18'
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
16-19: Commitlint Step & Trailing Newline IssueThe commit linting step is implemented well, with an informative echo statement and proper usage of the commitlint command. However, static analysis indicates that the file is missing a newline at the end. Please ensure that a trailing newline is added to comply with YAML lint rules.
+ (add a newline at the end of the file)🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/commit-lint.yml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (1)
.github/workflows/commit-lint.yml (1)
1-3: Workflow Trigger and Name DefinitionThe workflow is aptly named and correctly triggered on pull request events. No changes are needed in this section.
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: 0
♻️ Duplicate comments (1)
.github/workflows/commit-lint.yml (1)
11-14: Updated Node.js Setup
The workflow now usesactions/setup-node@v4withnode-version: '18'and enables npm caching. This update follows best practices by upgrading from Node.js 16 to a supported LTS release, as previously recommended.
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
19-19: Newline at End of File Needed
A newline character should be added at the end of the file to comply with YAML linting rules (new-line-at-end-of-file).🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/commit-lint.yml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (5)
.github/workflows/commit-lint.yml (5)
1-3: Workflow Header and Trigger Configuration
The workflow is configured with a clear header and is correctly set to trigger on pull request events. This aligns well with the commit message validation requirements.
4-7: Job Configuration is Clear and Maintainable
Thejobssection and the definition of thecommitlintjob using the Ubuntu environment are straightforward and well-structured. This setup will help in maintaining clarity as the workflow evolves.
8-10: Proper Checkout Action Setup
Usingactions/checkout@v4withfetch-depth: 0ensures that the full commit history is available. This is essential for the commitlint step to accurately validate commit messages across the PR's commit range.
15-15: Reliable Dependency Installation
Runningnpm ci --legacy-peer-depsis a good choice here. It ensures reproducible installations in the CI environment while addressing potential legacy peer dependency issues.
16-19: Effective Commit Message Linting Step
The step clearly logs the linting process and runsnpx commitlintwith the correct parameters to compare the commits between the base and head SHAs of the pull request. This implementation should enforce conventional commit messages as intended.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 19-19: no new line character at the end of file
(new-line-at-end-of-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: 0
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
30-30: Missing Newline at End-of-File.
YAML files should end with a newline character to conform to best practices and avoid linting issues. Please add a newline character at the end of the file.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/commit-lint.yml(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)
🔇 Additional comments (7)
.github/workflows/commit-lint.yml (7)
1-2: Descriptive Workflow Name.
The workflow name "Lint Commit Messages" clearly indicates the purpose of this job.
3-6: Pull Request Trigger Configuration.
Theonsection is correctly set up to trigger on pull request events (opened, synchronize, reopened), ensuring commit messages are evaluated at appropriate times.
7-10: Job and Runner Configuration.
The jobcommitlintis configured to run onubuntu-latest, which is a suitable environment for this workflow.
11-19: Checkout Step Configuration.
The checkout step usesactions/checkout@v4with proper submodule handling and a full fetch (fetch-depth: 0), which is essential for retrieving complete commit history when linting commit messages.
20-24: Node.js Setup Step.
The Node.js setup step usesactions/setup-node@v4with Node.js version 18, addressing previous concerns about outdated Node.js versions and ensuring better security and compatibility.
25-27: Dependency Installation Step.
Usingnpm ci --legacy-peer-depsis appropriate here to install dependencies cleanly, which helps manage potential peer dependency conflicts effectively.
28-30: Commitlint Execution Step.
The final step correctly runsnpx commitlintusing commit range values between the base and head SHA with the--verboseflag. This ensures that commit messages in pull requests are properly validated. Ensure that the commitlint configuration incommitlint.config.jsaligns with project standards.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-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: 0
🧹 Nitpick comments (1)
.github/workflows/commit-lint.yml (1)
1-31: Great job implementing a robust commit message linting workflow!The workflow is well-structured, uses best practices (full fetch, Node.js 18, proper commitlint range), and will effectively enforce commit message standards in PRs.
Just two minor YAML formatting issues to address:
- Remove trailing spaces on line 31.
- Add a newline at the end of the file.
- +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 31-31: no new line character at the end of file
(new-line-at-end-of-file)
[error] 31-31: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/commit-lint.yml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml
[error] 31-31: no new line character at the end of file
(new-line-at-end-of-file)
[error] 31-31: trailing spaces
(trailing-spaces)
|



📋 Description
JIRA ID:
GitHub Issue: Fixes PSMRI/AMRIT#62
This PR introduces commit message standardization for the
HWC-UIproject by setting up Commitlint, Husky, and Commitizen. This PR 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
Changes Overview
commitlint.config.jswith conventional commit rules..husky/commit-msg.Commitizenwith configuration inpackage.jsonfor interactive commit prompts..github/workflows/commit-lint.ymlto check commit messages on PRs.package.jsonandpackage-lock.jsonwith required dev dependencies:@commitlint/cli@commitlint/config-conventionalcommitizencz-conventional-changelogTesting & Validation
npm run commitornpx cz.Screenshots
Commitlint

Commitizen
a.

b.

Summary by CodeRabbit
New Features
Chores