Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git-hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

npx --yes @commitlint/cli --edit "$1"
29 changes: 14 additions & 15 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: Commit Compliance
name: Commit Message Check

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
commitlint:
commit-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code with submodule
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '20'

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Run commitlint on PR
- name: Validate commit messages
run: |
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
set -eo pipefail
commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
for sha in $commits; do
tmp=$(mktemp)
git log -1 --pretty=format:"%B" "$sha" > "$tmp"
npx --yes @commitlint/cli@20.4.3 --edit "$tmp"
rm "$tmp"
done
1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

52 changes: 5 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,15 @@ Prerequisites
* MySQL

## Environment and setup

1. Install dependencies `mvn clean install`
2. You can copy `admin_example.properties` to `admin_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder.
3. Run the spring server with local configuration `mvn spring-boot:run -DENV_VAR=local`
1. Enable git hooks (run once after cloning):
- Run the command `git config core.hooksPath .git-hooks`.
2. Install dependencies `mvn clean install`
3. You can copy `admin_example.properties` to `admin_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder.
4. Run the spring server with local configuration `mvn spring-boot:run -DENV_VAR=local`

## Installation
This service has been tested on Wildfly as the application server. To install the admin module, kindly refer to Installation Guide for [API Repository](https://piramal-swasthya.gitbook.io/amrit/developer-guide/development-environment-setup/installation-instructions/for-api-repositories) for guidance.

## Setting Up Commit Hooks

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:

### Prerequisites
- Node.js (v18 or later)
- npm (comes with Node.js)

### Setup Steps

1. **Install Node.js and npm**
- Download and install from [nodejs.org](https://nodejs.org/)
- Verify installation with:
```
node --version
npm --version
```
2. **Install dependencies**
- From the project root directory, run:
```
npm ci
```
- This will install all required dependencies including Husky and commitlint
3. **Verify hooks installation**
- The hooks should be automatically installed by Husky
- You can verify by checking if the `.husky` directory contains executable hooks
### Commit Message Convention
This project follows a specific commit message format:
- Format: `type(scope): subject`
- Example: `feat(login): add remember me functionality`
Types include:
- `feat`: A new feature
- `fix`: A bug fix
- `docs`: Documentation changes
- `style`: Code style changes (formatting, etc.)
- `refactor`: Code changes that neither fix bugs nor add features
- `perf`: Performance improvements
- `test`: Adding or fixing tests
- `build`: Changes to build process or tools
- `ci`: Changes to CI configuration
- `chore`: Other changes (e.g., maintenance tasks, dependencies)
Your commit messages will be automatically validated when you commit, ensuring project consistency.

## Usage
All the features have been exposed as REST endpoints.
Refer to the SWAGGER API specification for details.
Expand Down
3 changes: 1 addition & 2 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
Expand Down Expand Up @@ -32,5 +31,5 @@ module.exports = {
'test',
],
],
}
},
};
Loading