diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg new file mode 100644 index 0000000..63ea7d1 --- /dev/null +++ b/.git-hooks/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +set -e + +npx --yes @commitlint/cli@20.4.3 --edit "$1" diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 0000000..aaad8ad --- /dev/null +++ b/.github/workflows/commit-lint.yml @@ -0,0 +1,29 @@ +name: Commit Message Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + commit-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Validate commit messages + run: | + 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 diff --git a/README.md b/README.md index 889d83e..24774dc 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,15 @@ For steps to clone and set up this Repository, refer to the [Developer Guide](ht To build the ECD module from source, follow these steps: 1. Clone the repository to your local machine. -2. Install the required dependencies and build the module using the following command: +2. Enable git hooks (run once after cloning): + - Run the command `git config core.hooksPath .git-hooks`. +3. Install the required dependencies and build the module using the following command: - Execute the following command: ``` mvn clean install ``` -3. You can copy `ecd_example.properties` to `ecd_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` +4. You can copy `ecd_example.properties` to `ecd_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder. +5. Run the spring server with local configuration `mvn spring-boot:run -DENV_VAR=local` - Open your browser and navigate to http://localhost:8080/swagger-ui.html#!/ diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..abc565a --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,35 @@ +module.exports = { + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 100], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 100], + 'header-max-length': [2, 'always', 100], + 'subject-case': [ + 2, + 'never', + ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], + ], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], + ], + }, +}; \ No newline at end of file