Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Add commitlint - use conventional commits consistently #595

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 21 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 15
java-version: 11
- name: Cache Gradle
uses: actions/cache@v2
env:
java-version: 15
java-version: 11
with:
path: |
~/.gradle/caches
Expand All @@ -38,14 +38,31 @@ jobs:
- name: Gradle Check
run: ./gradlew --info build -x test

commitlint:
name: Validate conventional commits
runs-on: ubuntu-latest
needs: validation
steps:
- uses: actions/checkout@v2
name: Checkout
with:
fetch-depth: 0
- uses: actions/setup-node@v1
name: Setup Node
with:
node-version: 14
- run: cd commitlint && npm audit
name: Security audit of NPM packages
- run: cd commitlint && npm ci && git ls-remote https://github.com/graphql-java-kickstart/graphql-spring-boot.git HEAD | grep -o '[0-9a-f]*' | xargs -I{} npx commitlint --from {} --verbose
name: Run commitlint
test:
name: Test run
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
java: [ 8, 11, 16 ]
needs: validation
needs: [validation, commitlint, verify-google-java-format]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -78,7 +95,7 @@ jobs:

build:
name: Sonar analysis
needs: validation
needs: test
runs-on: ubuntu-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ fabric.properties
# Mac

.DS_Store

# Node

**/node_modules
**/.husky
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,26 @@ It would also be very helpful to install the SonarLint plugin in your IDE and fi
SonarLint issues before pushing a PR. We're aware that the current state of the code raises a lot of
SonarLint issues out of the box, but any help in reducing that is appreciated. More importantly we
don't increase that technical debt.

###Commit messages

This project uses the [Conventional Commits](https://www.conventionalcommits.org) specification for commit messages.
The CI pipeline validates that commit messages adhere to the specification using
[commitlint](https://github.com/conventional-changelog/commitlint).

**Note**: *Historical commits, made before applying this convention may not fulfill the requirements of the
specification. These commits are exempt from this check.*

To check commit messages before committing, go to the `commitlint` folder and run `npm ci && npm run add-commitlint-git-hook`
(you will need NodeJS installed on your machine). This command sets up a git hook to run commitlint before each commit,
to prevent committing with invalid commit messages in the first place.

**Note**: *Please always use `npm ci` instead of `install` to prevent unwanted changes to `package-lock.json`.*

To remove the git hook, just delete the `commitlint/.husky` folder.

As for the optional scope part of the commit message:
- if your commit addresses an issue, please refer the issue number in the scope - e.g. `fix(#123): ...`
- otherwise, if applicable, please use the modified / affected subproject name, without the repetitive prefix/postfix
parts (like `graphql-kickstart-spring-boot`, `spring-boot-starter` or `autoconfigure`) - e.g. `feat(webflux): ...`

1 change: 1 addition & 0 deletions commitlint/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
Loading