Skip to content

Commit 26f2941

Browse files
ci: Add automatic check for commit message format
- Added GitHub Actions workflow to lint commit messages on push and pull request events. - Created custom commitlint configuration file (.commitlintrc.json) to enforce commit message standards. - Documentated commit message format in CONTRIBUTING.md Signed-off-by: Shamitha Shashidhara <[email protected]>
1 parent 157c3c4 commit 26f2941

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

.commitlintrc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"rules": {
3+
"type-enum": [1, "always", [
4+
"build",
5+
"ci",
6+
"docs",
7+
"feat",
8+
"fix",
9+
"perf",
10+
"refactor",
11+
"revert",
12+
"style",
13+
"test"
14+
]],
15+
"header-full-stop": [2, "never"],
16+
"header-trim": [2, "always"],
17+
"subject-empty": [1, "never"],
18+
"subject-full-stop": [2, "never", "."],
19+
"subject-max-length": [1, "always", 50],
20+
"subject-case": [2, "always", "sentence-case"],
21+
"body-leading-blank": [2, "always"],
22+
"body-max-line-length": [1, "always", 72],
23+
"body-case": [1, "always", "sentence-case"],
24+
"signed-off-by": [1, "always", "Signed-off-by:"]
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Check Commit Message Format
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
commitmessage:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Commit message format
14+
uses: wagoid/commitlint-github-action@v5
15+
with:
16+
configFile: .commitlintrc.json

CONTRIBUTING.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,90 @@ To contribute your work you need to...
4343
4. Push to the Branch (`git push origin newBranchName`)
4444
5. Open a Pull Request
4545

46+
### Commit Message Format
47+
48+
We have very precise rules over how our Git commit messages must be formatted.
49+
This format leads to **easier to read commit history**.
50+
51+
Each commit message consists of a **header**, a **body**, and a **footer**.
52+
53+
```
54+
<header>
55+
<BLANK LINE>
56+
<body>
57+
<BLANK LINE>
58+
<footer>
59+
```
60+
61+
#### Commit Message Header
62+
63+
```
64+
<type>: <subject line>
65+
│ │
66+
│ └─⫸ Subject in present tense. Capitalized. No period at the end.
67+
68+
69+
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test|revert|style
70+
```
71+
72+
The `<type>` and `<subject line>` fields are mandatory.
73+
74+
##### Type
75+
76+
Must be one of the following:
77+
78+
* **build**: Changes that affect the build system
79+
* **ci**: Changes to our CI configuration files and scripts
80+
* **docs**: Documentation changes
81+
* **feat**: A new feature
82+
* **fix**: A bug fix
83+
* **perf**: A code change that improves performance
84+
* **refactor**: A code change that neither fixes a bug nor adds a feature
85+
* **test**: Adding missing tests or correcting existing tests
86+
* **revert**: To undo previous commits
87+
* **style**: Changes related to formatting or whitespace adjustments
88+
89+
##### Subject line
90+
91+
Use the subject field to provide a breif description of the change:
92+
93+
* Use the imperative, present tense: "change" not "changed" nor "changes".
94+
* Stick to plain text in the subject.
95+
* Limit the subject line to 50 characters.
96+
* Capitalize the subject line.
97+
* Do not end the subject line with a period (.).
98+
99+
#### Commit Message Body
100+
101+
Explain the motivation for the change in the commit message body. This commit message should
102+
explain why you are making the change.
103+
You can include a comparison of the previous behavior with the new behavior in order to
104+
illustrate the impact of the change.
105+
It should also wrap up within 72 characters per line.
106+
If the subject line is sufficiently descriptive, the body can be optional.
107+
108+
#### Commit Message Footer
109+
110+
The footer section is used for additional information that doesn't fit into the subject or body.
111+
This can include references to GitHub issues, Jira tickets, and other PRs related discussions.
112+
A common practice is to include a "Signed-off-by" line in the footer. This line indicates
113+
who is responsible for the commit and is formatted as follows:
114+
115+
```
116+
Signed-off-by: Full Name <[email protected]>
117+
```
118+
119+
### Revert commits
120+
121+
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header
122+
of the reverted commit.
123+
124+
The content of the commit message body should contain:
125+
126+
- Information about the SHA ID of the commit being reverted in the following format:
127+
`This reverts commit <SHA ID>`.
128+
- A clear description of the reason for reverting the commit message.
129+
46130
## Eclipse Contributor Agreement
47131

48132
Before your contribution can be accepted by the project team contributors must

0 commit comments

Comments
 (0)