-
Notifications
You must be signed in to change notification settings - Fork 25
feat(scheduler-api): implement commit message linting and automation #50
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 enforcement system for the project. It adds configuration files and dependencies for Commitlint, Husky, and Commitizen, establishes a GitHub Actions workflow for commit message compliance on pull requests, and documents the setup and usage in the README. The Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky (commit-msg hook)
participant Commitlint
participant GitHub Actions (CI)
participant Node.js/NPM
Developer->>Husky (commit-msg hook): git commit
Husky (commit-msg hook)->>Commitlint: Lint commit message
Commitlint-->>Husky (commit-msg hook): Pass/Fail result
Husky (commit-msg hook)-->>Developer: Allow or block commit
Developer->>GitHub Actions (CI): Open/sync PR
GitHub Actions (CI)->>Node.js/NPM: Setup environment, install dependencies
GitHub Actions (CI)->>Commitlint: Lint PR commit messages
Commitlint-->>GitHub Actions (CI): Pass/Fail result
GitHub Actions (CI)-->>Developer: Report status on PR
Possibly related issues
✨ 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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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 (4)
.github/workflows/commit-lint.yml (2)
30-30: Remove trailing spaces and ensure newline at end-of-fileStatic analysis flagged trailing spaces on line 30 and no EOL at the end. Cleaning this up will satisfy YAML linters:
- 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)
1-29: Optional: Enforce commit message linting on direct pushesCurrently the workflow only triggers on pull requests. To catch non-PR commits (e.g., direct pushes to main), you might also add:
on: push: branches: - mainThis helps maintain commit consistency across all branches.
README.md (2)
34-43: Use consistent list markersThe new “Setting Up Commit Hooks” section mixes
-for lists, whereas the rest of the README uses*. Switching to*maintains consistency:- - Node.js (v14 or later) - - npm (comes with Node.js) + * Node.js (v14 or later) + * npm (comes with Node.js)🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
39-39: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
40-40: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
47-50: Specify a language for fenced code blocksAdding
bashorshellto your code fences improves readability and linting:- ``` + ```bash node --version npm --version - ``` + ```bashRepeat for the other code blocks (lines 55–56 and 87–88).
Also applies to: 55-56, 87-88
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
47-47: 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 (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)
[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 (5)
.gitignore (1)
39-43: Ignore local configuration and Node.js artifacts correctlyThe added ignore patterns for
src/main/environment/common_local.propertiesensure that developers’ local config copies aren’t accidentally committed, and the Node.js entries (node_modules/,npm-debug.log) align with the newly introduced tooling.commitlint.config.js (4)
1-36: Well-structured commitlint configuration that properly enforces conventional commits standards.The configuration extends the standard
@commitlint/config-conventionalpreset and defines a comprehensive set of rules that will ensure consistent commit messages across the project. The rules appropriately distinguish between critical requirements (error level 2) and stylistic preferences (warning level 1).
4-8: Good balance between strictness and flexibility in message formatting rules.Setting body and footer blank line requirements as warnings (level 1) while making length limits errors (level 2) is a sensible approach that enforces important structural constraints without being overly strict about formatting.
9-15: Appropriate subject line constraints for readable commit messages.The subject case restrictions and prohibition of trailing periods will help maintain consistent, readable commit messages. Setting these as errors (level 2) is appropriate since the subject line is the most visible part of commit messages.
16-34: Comprehensive and standard type enumeration for conventional commits.The type enumeration includes all standard conventional commit types and enforces lowercase formatting. This will ensure that commits are properly categorized, making the repository history more navigable and enabling automated changelog generation.
| @@ -0,0 +1 @@ | |||
| npx --no -- commitlint --edit $1 No newline 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.
Add a shebang to ensure hook runs with the expected shell
The Husky hook script needs a shebang (e.g., #!/usr/bin/env sh) at the top so Git will execute it correctly. Without it, some environments may not recognize how to run the script.
Apply this diff:
+#!/usr/bin/env 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 | |
| npx --no -- commitlint --edit $1 |
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "prepare": "husky", | ||
| "commit": "cz" | ||
| }, |
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.
Fix the prepare script to correctly install Husky hooks
The prepare script should invoke husky install (not just husky) so that hooks are set up after npm ci:
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
- "prepare": "husky",
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "prepare": "husky install",
"commit": "cz"
}📝 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.
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "prepare": "husky", | |
| "commit": "cz" | |
| }, | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "prepare": "husky install", | |
| "commit": "cz" | |
| }, |



📋 Description
Closes PSMRI/AMRIT#84
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
.gitignoreto exclude Node.js-related files and directories.