-
Notifications
You must be signed in to change notification settings - Fork 43
feat(commit): setup Husky, Commitlint,Commitzen #187
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 automated commit message linting and developer tooling to the project. It adds configuration and scripts for Commitlint, Husky, Commitizen, and lint-staged to enforce conventional commit message standards and code quality checks. A GitHub Actions workflow is set up to validate commit messages on pull requests. The README is rewritten to reflect the new focus on healthcare interoperability and includes detailed setup instructions for the new developer tools. No changes are made to application code or exported entities; all modifications are related to configuration, automation, and documentation. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky (Local)
participant Commitlint (Local)
participant Commitizen (Local)
participant GitHub
participant GitHub Actions
Developer->>Commitizen (Local): Run "npm run commit"
Commitizen (Local)->>Developer: Prompt for commit details
Developer->>Husky (Local): git commit
Husky (Local)->>Commitlint (Local): Validate commit message
Commitlint (Local)-->>Husky (Local): Pass/Fail
Husky (Local)-->>Developer: Allow/Block commit
Developer->>GitHub: Push branch / create PR
GitHub->>GitHub Actions: Trigger commit-lint workflow
GitHub Actions->>Commitlint (CI): Lint commit messages in PR
Commitlint (CI)-->>GitHub Actions: Pass/Fail
GitHub Actions-->>GitHub: Report PR status
Assessment against linked issues
Possibly related issues
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 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 (
|
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: 4
🧹 Nitpick comments (6)
README.md (6)
1-4
: Refine introductory section for clarity and grammarConsider adding a comma after “systems” (line 3) for readability and inserting “the” before “rest of the 18 resources” (line 4). For example:
- COMMON-PAI provides a means for representing and sharing information among clinicians and organizations in a standard way regardless of how it is stored in those systems. + COMMON-PAI provides a means for representing and sharing information among clinicians and organizations in a standard way, regardless of how it is stored in those systems. - Contributors are working on developing rest of the 18 resources which will make AMRIT to be compliant with ABDM guidelines. + Contributors are working on developing the rest of the 18 resources, which will make AMRIT compliant with ABDM guidelines.🧰 Tools
🪛 LanguageTool
[uncategorized] ~3-~3: Possible missing comma found.
Context: ...nicians and organizations in a standard way regardless of the ways local EHRs repre...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~3-~3: You might be missing the article “the” here.
Context: ...on, while being flexible enough to meet needs of a wide variety of use cases within t...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ... Contributors are working on developing rest of the 18 resources which will make AMR...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
26-27
: Unify list marker styleThe prerequisites list uses dashes (
-
) for bullets. Consider using a consistent style (e.g., asterisks*
) throughout the README to align with markdownlint expectations.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
26-26: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
27-27: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
31-37
: Specify shell language in code fencesThe version checks are wrapped in a code fence without a language specifier. Add
bash
(orsh
) for syntax highlighting:- ``` + ```bash node --version npm --version ```🧰 Tools
🪛 LanguageTool
[uncategorized] ~32-~32: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...(NODE_JS)
🪛 markdownlint-cli2 (0.17.2)
32-32: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
33-33: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
34-34: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
38-43
: Specify shell language in dependency installation snippetSimilarly, the
npm ci
snippet should be language-tagged:- ``` + ```bash npm ci ```🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
39-39: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
40-40: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
43-43: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
45-46
: Unify list marker style in verification stepsThe verification steps also use dashes for bullets. For consistency (and to satisfy markdownlint), switch to asterisk-style bullets.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
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-53
: Verify commit types against configuration and add Commitizen usageEnsure that the types listed here exactly match those in
commitlint.config.js
. Also consider adding a note on using Commitizen’s interactive CLI, for example:+ 4. **Create conventional commits** + - Use Commitizen to scaffold commits: + ```bash + npm run commit + ```🧰 Tools
🪛 LanguageTool
[grammar] ~53-~53: “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)
🪛 markdownlint-cli2 (0.17.2)
49-49: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
50-50: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
52-52: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
53-53: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ 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).husky/commit-msg
(1 hunks).husky/pre-commit
(1 hunks)README.md
(1 hunks)commitlint.config.js
(1 hunks)package.json
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~3-~3: Possible missing comma found.
Context: ...nicians and organizations in a standard way regardless of the ways local EHRs repre...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~3-~3: You might be missing the article “the” here.
Context: ...on, while being flexible enough to meet needs of a wide variety of use cases within t...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ... Contributors are working on developing rest of the 18 resources which will make AMR...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~32-~32: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...
(NODE_JS)
[grammar] ~53-~53: “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] ~56-~56: 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
5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
26-26: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
27-27: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
32-32: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
33-33: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
34-34: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
39-39: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
40-40: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
43-43: 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)
49-49: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
50-50: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
52-52: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
53-53: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
54-54: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
55-55: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
56-56: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
57-57: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
58-58: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
59-59: 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)
73-73: Code block style
Expected: fenced; Actual: indented
(MD046, code-block-style)
🔇 Additional comments (3)
.github/workflows/commit-lint.yml (1)
1-31
: Workflow correctly validates commit messagesThe GitHub Actions workflow is properly configured to trigger on pull requests, check out the correct ref (including submodules), set up Node.js, install dependencies, and run
commitlint
between the base and head SHAs. It meets the objective of enforcing commit message standards in CI.commitlint.config.js (1)
1-43
: Commitlint configuration looks solidThe config extends the conventional preset, enforces body/footer/header length, and restricts types and scopes (including the new
git-hooks
scope). All rules align with the PR objective to standardize commit messages.README.md (1)
21-24
: Commit hooks introduction looks goodThe new “Setting Up Commit Hooks” section clearly explains the Node‑powered Git hooks for a Java project and outlines the setup steps. No changes needed here.
@@ -0,0 +1 @@ | |||
npx --no -- commitlint --edit $1 |
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.
🛠️ Refactor suggestion
Add Husky hook boilerplate header
Husky hook scripts require a shebang and sourcing of the Husky runner. Please add at the top of this file before the npx --no -- commitlint --edit $1
line:
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
"version": "1.0.0", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepare": "husky", |
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 Husky prepare script
Husky v7+ uses husky install
to setup Git hooks. The current "prepare": "husky"
will not install them. Update as follows:
- "prepare": "husky",
+ "prepare": "husky install",
📝 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.
"prepare": "husky", | |
"prepare": "husky install", |
### Key APIs in COMMON-PAI service | ||
* Care Context Services | ||
* e-Aushadhi | ||
* ABHA Card Services | ||
* OP Consultation Record Sharing | ||
* Diagnostic Report Record Sharing | ||
* Prescription Record Sharing | ||
* Higher Health Facility |
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.
🛠️ Refactor suggestion
Adjust heading level and improve content hierarchy
The “Key APIs in COMMON-PAI service” section uses an H3 (###
) right after an H1 (#
), skipping H2. For better hierarchy and consistency, change it to H2 (##
):
- ### Key APIs in COMMON-PAI service
+ ## Key APIs in COMMON-PAI service
📝 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.
### Key APIs in COMMON-PAI service | |
* Care Context Services | |
* e-Aushadhi | |
* ABHA Card Services | |
* OP Consultation Record Sharing | |
* Diagnostic Report Record Sharing | |
* Prescription Record Sharing | |
* Higher Health Facility | |
## Key APIs in COMMON-PAI service | |
* Care Context Services | |
* e-Aushadhi | |
* ABHA Card Services | |
* OP Consultation Record Sharing | |
* Diagnostic Report Record Sharing | |
* Prescription Record Sharing | |
* Higher Health Facility |
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
@blazethunderstorm reminder to update the PR. |
Yeah will do it today |
|
@drtechie i have made the required changes |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.gitignore
(1 hunks).husky/pre-commit
(1 hunks)package.json
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- .gitignore
- package.json
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no -- commitlint --edit ${1} |
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.
Incorrect hook type for commitlint command
There appears to be a hook type mismatch. This file is named pre-commit
, but the command being run (commitlint --edit ${1}
) is typically used in a commit-msg
hook, not a pre-commit
hook.
Pre-commit hooks run before the commit message is created and are intended for code quality checks like linting and testing. The commit message (${1}) isn't available at this pre-commit stage.
For proper implementation:
- A
pre-commit
hook should run commands likelint-staged
or other code quality checks - The commitlint command should be in a
commit-msg
hook file instead
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
-npx --no -- commitlint --edit ${1}
+npx lint-staged
And ensure you have a separate .husky/commit-msg
file containing:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no -- commitlint --edit ${1}
Implemented it for Common-API
📋 Description
JIRA ID: Fixes PSMRI/AMRIT#79
This PR introduces commit message standardization for the FHIR-API project by setting up Commitlint, Husky, and Commitizen.
The goal is to enforce a consistent commit message format across the repository, improving collaboration, readability,
and enabling future automation (like changelogs and versioning).
These tools are now integrated:
PS: Implemented with the same standardization as for the UI repositories to ensure clean and well-maintained code.
✅ Type of Change
ℹ️ Additional Information
🧪 Testing & Validation:
PROOF(SCREENSHOTS)
Summary by CodeRabbit
New Features
consistent commit message standards.
Chores
dependencies management.
Summary by CodeRabbit
.gitignore
to excludenode_modules/
and.history/
directories.