-
Notifications
You must be signed in to change notification settings - Fork 24
feat(ci) : implement commit message standards and automation #30
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
This change implements a robust commit message standardization system for the BeneficiaryID-Generation-API repository. We've integrated Commitlint, Husky, and Commitizen to enforce consistent commit message formatting across all contributions. The setup includes pre-commit hooks for test validation and commit message linting, ensuring that all commits follow the Conventional Commits specification. The GitHub Actions workflow has been configured to validate commit messages in pull requests, checking the entire commit history for compliance. We've also added clear documentation in the README about commit message standards and the tools used. The implementation maintains compatibility with existing CI/CD pipelines while providing contributors with an interactive commit message creation process through Commitizen.
This change implements a robust commit message standardization system for the BeneficiaryID-Generation-API repository. We've
WalkthroughThis change introduces commit message linting and automation tools into the repository. It adds configuration files for Commitlint, Husky, and Commitizen to enforce the Conventional Commits specification. Git hooks are set up to validate commit messages and run tests before commits. A GitHub Actions workflow is included to check commit messages on pull requests. The Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky
participant Commitlint
participant CI (GitHub Actions)
Developer->>Husky: git commit
Husky->>Commitlint: Validate commit message
Commitlint-->>Husky: Pass/Fail
alt If commit message is valid
Husky->>Husky: Run pre-commit tests (npm run test:ci)
Husky-->>Developer: Allow commit if tests pass
else If commit message is invalid or tests fail
Husky-->>Developer: Block commit
end
Developer->>GitHub: Push PR
CI->>Commitlint: Lint commit messages in PR
Commitlint-->>CI: Pass/Fail
CI-->>Developer: Report result in PR checks
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: 2
🧹 Nitpick comments (2)
.github/commitlint.config.js (1)
1-1: Remove the BOM character from the file.There appears to be a Byte Order Mark (BOM) character at the beginning of this file (indicated by the UTF-8 BOM character "" in line 1). This can cause issues with some JavaScript parsers.
-module.exports = { +module.exports = {README.md (1)
9-15: Specify a language for the fenced code block.
Adding a language identifier improves readability and syntax highlighting. For example:- ``` + ```text🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
9-9: 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 ignored due to path filters (3)
hs_err_pid9248.logis excluded by!**/*.logpackage-lock.jsonis excluded by!**/package-lock.jsonreplay_pid9248.logis excluded by!**/*.log
📒 Files selected for processing (9)
.commitlintrc.json(1 hunks).github/commitlint.config.js(1 hunks).github/workflows/commitlint.yml(1 hunks).gitignore(1 hunks).husky/commit-msg(1 hunks).husky/pre-commit(1 hunks).vscode/settings.json(1 hunks)README.md(2 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/commitlint.yml
11-11: 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)
14-14: 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)
🪛 LanguageTool
README.md
[grammar] ~19-~19: “Bug” is a singular noun. It appears that the verb form is incorrect.
Context: ... - feat: A new feature - fix: A bug fix - docs: Documentation only changes - ...
(PCT_SINGULAR_NOUN_PLURAL_VERB_AGREEMENT)
🪛 markdownlint-cli2 (0.17.2)
README.md
9-9: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🔇 Additional comments (12)
.vscode/settings.json (1)
1-3: Good addition for consistent Java development environment.This VS Code setting enables automatic nullability checks during Java compilation, which helps catch potential null pointer exceptions early in the development process. This aligns well with the overall goal of improving code quality and standardization.
.gitignore (2)
5-8: Great addition for Java-specific ignore patterns.These ignore patterns for Java crash logs are appropriate and follow standard practices.
9-19: Appropriate Node.js ignore patterns for the new tooling.These additions properly ignore Node.js artifacts and environment files, which is essential now that you're introducing Node.js-based tooling (Commitlint, Husky, Commitizen). The environment file patterns ensure sensitive information doesn't get committed.
.husky/pre-commit (1)
1-6:Details
✅ Verification successful
Verify the test:ci script exists in package.json.
The pre-commit hook is set up correctly to run tests before allowing commits, but I need to verify if the
test:ciscript is defined in your package.json file.
🏁 Script executed:
#!/bin/bash # Check if the test:ci script is defined in package.json if [ -f package.json ]; then if grep -q "\"test:ci\":" package.json; then echo "✅ test:ci script is defined in package.json" else echo "❌ test:ci script is not defined in package.json" echo "The pre-commit hook may fail if the script doesn't exist." fi else echo "⚠️ package.json file not found" fiLength of output: 158
✅
test:ciscript verified in package.jsonNo changes required—your pre-commit hook will run successfully.
• package.json:
"test:ci"script is defined.
• .husky/pre-commit: invokesnpm run test:ci, which now exists..github/commitlint.config.js (1)
1-3: Properly configured Commitlint with conventional commits standard.The configuration correctly extends the
@commitlint/config-conventionalpreset to enforce conventional commit message standards. This is consistent with the PR objective of standardizing commit messages..commitlintrc.json (1)
1-3: Commitlint configuration is correct and minimal.
This file properly extends the Conventional Commits rules via@commitlint/config-conventional, ensuring commit messages follow the spec..husky/commit-msg (1)
1-3: Commit-msg hook correctly validates commit messages.
The hook sources Husky’s environment and invokescommitlint --edit "$1", enforcing your configured rules on every commit.README.md (2)
6-30: New "Commit Message Standards" section is clear and comprehensive.
The documentation accurately outlines the Conventional Commits format, enumerates allowed types, and lists the enforcement tools (Commitlint, Husky, Commitizen).🧰 Tools
🪛 LanguageTool
[grammar] ~19-~19: “Bug” is a singular noun. It appears that the verb form is incorrect.
Context: ... -feat: A new feature -fix: A bug fix -docs: Documentation only changes - ...(PCT_SINGULAR_NOUN_PLURAL_VERB_AGREEMENT)
🪛 markdownlint-cli2 (0.17.2)
9-9: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
65-65: Typographical refinement applied correctly.
The contraction “We'd” uses a standard apostrophe and reads well in context..github/workflows/commitlint.yml (1)
1-21: GitHub Actions workflow for commitlint is well-defined.
The workflow triggers on pull requests tomain, checks out full history, sets up Node.js, runsnpm ci, and lints commit messages between the base and head commits using.commitlintrc.json. This aligns perfectly with the PR objective to enforce commit standards in CI.🧰 Tools
🪛 actionlint (1.7.4)
11-11: 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)
14-14: 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)
package.json (2)
13-21: Lint-staged configuration looks solid.
Your patterns for JavaScript/TypeScript and JSON/Markdown will format and lint staged files automatically, improving code quality before commits.
32-36: Commitizen configuration is correctly set up.
Thecz-conventional-changelogadapter inconfig.commitizenwill drive interactive commit prompts vianpm run commit.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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)
.husky/commit-msg (1)
1-2: LGTM! Correctly sets up the commit-msg hook for Commitlint.The script properly invokes the npm
commitmsgscript, passing the commit message file path as an argument. This is the standard pattern for Husky Git hooks.For added robustness, consider adding error handling:
#!/bin/sh -npm run commitmsg -- "$1" +# Validate commit message using Commitlint +npm run commitmsg -- "$1" || { + echo "Error: Commit message validation failed" + exit 1 +}Also, ensure this file has executable permissions (
chmod +x .husky/commit-msg).
📜 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 (2)
.husky/commit-msg(1 hunks)package.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
|
@rohan-019 |
hs_err_pid9248.log
Outdated
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.
don't check in log files.
replay_pid9248.log
Outdated
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.
don't check in log files.
| . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| # Run tests if they exist | ||
| npm run test:ci |
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.
What is this file about? I don't see this command in package.json scripts.
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.
hi, @drtechie ,
The pre-commit hook has been updated to use lint-staged instead of the placeholder test command. This change is more meaningful because it actually performs code quality checks on staged files before commits, running ESLint and Prettier on JavaScript/TypeScript files, and Prettier on JSON/Markdown files. This ensures consistent code formatting and quality across the repository.
Also, I've excluded log files from being checked in .
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.
@rohan-019 the test:ci script in package.json does nothing.
|
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)
.commitlintrc.json (1)
4-8: Review blank-line and line-length limits
While enforcing leading blank lines and 100‑character max lengths is valid, many teams prefer stricter limits (e.g., header ≤50 chars, body ≤72 chars for readability in terminals). Consider adjusting these values to align with your team's workflow.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.commitlintrc.json(1 hunks)
🔇 Additional comments (4)
.commitlintrc.json (4)
2-2: Baseline commitlint preset extended
Extending@commitlint/config-conventionalprovides a solid foundation of conventional commit rules.
14-15: Enforce non-empty subjects and no trailing periods
Good: commits cannot have empty subjects or end with a period, aligning with conventional commits best practices.
16-17: Require lowercase, non-empty commit types
Requiring lowercase and non-emptytypefields ensures standardized commit prefixes.
18-34: Validate allowed commit types
Thetype-enumcovers the most common categories:build,chore,ci,docs,feat,fix,perf,refactor,revert,style, andtest. Confirm these meet your project’s needs; if you require additional categories (e.g.,security), add them here.
|
hi, @drtechie |
|
Hi @drtechie, Thank you in advance. |





Fixes : PSMRI/AMRIT#88
Description
This PR implements a robust commit message standardization system for the BeneficiaryID-Generation-API repository. The changes ensure consistent commit message formatting across all contributions.
Changes
Testing
Related Issues
Checklist
Summary by CodeRabbit