Skip to content

Commit 02e04d0

Browse files
authored
Merge pull request #72 from Zapper9982/feat/issue-89
feat(commit): setup Husky, Commitlint,Commitzen
2 parents 2ecec43 + fe2c666 commit 02e04d0

7 files changed

Lines changed: 3365 additions & 1 deletion

File tree

.github/workflows/commit-lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Commit Compliance
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
commitlint:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code with submodule
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.event.pull_request.head.ref }}
16+
repository: ${{ github.event.pull_request.head.repo.full_name }}
17+
submodules: true
18+
fetch-depth: 0
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
25+
- name: Install dependencies
26+
run: npm ci --legacy-peer-deps
27+
28+
- name: Run commitlint on PR
29+
run: |
30+
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,59 @@ Detailed information on API endpoints can be found in the [API Guide](https://pi
2222

2323
## Usage
2424
All features have been exposed as REST endpoints. Refer to the SWAGGER API specification for details.
25+
26+
## Setting Up Commit Hooks
27+
28+
This project uses Git hooks to enforce consistent code quality and commit message standards. Even though this is a Java project, the hooks are powered by Node.js. Follow these steps to set up the hooks locally:
29+
30+
### Prerequisites
31+
- Node.js (v14 or later)
32+
- npm (comes with Node.js)
33+
34+
### Setup Steps
35+
36+
1. **Install Node.js and npm**
37+
- Download and install from [nodejs.org](https://nodejs.org/)
38+
- Verify installation with:
39+
```
40+
node --version
41+
npm --version
42+
```
43+
44+
2. **Install dependencies**
45+
- From the project root directory, run:
46+
```
47+
npm ci
48+
```
49+
- This will install all required dependencies including Husky and commitlint
50+
51+
3. **Verify hooks installation**
52+
- The hooks should be automatically installed by Husky
53+
- You can verify by checking if the `.husky` directory contains executable hooks
54+
55+
### Commit Message Convention
56+
57+
This project follows a specific commit message format:
58+
- Format: `type(scope): subject`
59+
- Example: `feat(login): add remember me functionality`
60+
61+
Types include:
62+
- `feat`: A new feature
63+
- `fix`: A bug fix
64+
- `docs`: Documentation changes
65+
- `style`: Code style changes (formatting, etc.)
66+
- `refactor`: Code changes that neither fix bugs nor add features
67+
- `perf`: Performance improvements
68+
- `test`: Adding or fixing tests
69+
- `build`: Changes to build process or tools
70+
- `ci`: Changes to CI configuration
71+
- `chore`: Other changes (e.g., maintenance tasks, dependencies)
72+
73+
Your commit messages will be automatically validated when you commit, ensuring project consistency.
2574
2675
## Filing Issues
2776
28-
If you encounter any issues, bugs, or have feature requests, please file them in the [main AMRIT repository](https://github.com/PSMRI/AMRIT/issues). Centralizing all feedback helps us streamline improvements and address concerns efficiently.
77+
If you encounter any issues, bugs, or have feature requests, please file them in the [main AMRIT repository](https://github.com/PSMRI/AMRIT/issues). Centralizing all feedback helps us streamline improvements and address concerns efficiently.
2978
3079
## Join Our Community
3180

commitlint.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'body-leading-blank': [1, 'always'],
5+
'body-max-line-length': [2, 'always', 100],
6+
'footer-leading-blank': [1, 'always'],
7+
'footer-max-line-length': [2, 'always', 100],
8+
'header-max-length': [2, 'always', 100],
9+
'subject-case': [
10+
2,
11+
'never',
12+
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
13+
],
14+
'subject-empty': [2, 'never'],
15+
'subject-full-stop': [2, 'never', '.'],
16+
'type-case': [2, 'always', 'lower-case'],
17+
'type-empty': [2, 'never'],
18+
'type-enum': [
19+
2,
20+
'always',
21+
[
22+
'build',
23+
'chore',
24+
'ci',
25+
'docs',
26+
'feat',
27+
'fix',
28+
'perf',
29+
'refactor',
30+
'revert',
31+
'style',
32+
'test'
33+
],
34+
],
35+
},
36+
};

0 commit comments

Comments
 (0)