Skip to content

Commit 44214ac

Browse files
OlivierAlbertinimayurkale22
authored andcommitted
chore: add commitlint and husky (open-telemetry#128)
Change CONTRIBUTING.md Resolves open-telemetry#117 Signed-off-by: Olivier Albertini <[email protected]>
1 parent 02a2001 commit 44214ac

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.commitlintrc.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extends:
2+
- '@commitlint/config-conventional'
3+
rules:
4+
header-max-length: [1, 'always', 72]
5+
type-enum:
6+
- 2
7+
- always
8+
- - ci
9+
- feat
10+
- fix
11+
- docs
12+
- style
13+
- refactor
14+
- perf
15+
- test
16+
- revert
17+
- chore
18+
help: |
19+
**Possible types**:
20+
`ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle CI, BrowserStack, SauceLabs)
21+
`feat`: Adds a new feature.
22+
`fix`: Solves a bug.
23+
`docs`: Adds or alters documentation. (example scopes: readme, worker, code_of_conduct, contributors)
24+
`style`: Improves formatting, white-space.
25+
`refactor`: Rewrites code without feature, performance or bug changes.
26+
`perf`: Improves performance.
27+
`test`: Adds or modifies tests. (example scopes: functionals, unit-tests)
28+
`revert`: Changes that reverting other changes
29+
`chore`: No production code change. Updating grunt tasks etc;

CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Please read project contribution
1919
[guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md)
2020
for general practices for OpenTelemetry project.
2121

22+
#### Conventional commit
23+
24+
The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages. You can see examples [here](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#examples).
25+
We use [commitlint](https://github.com/conventional-changelog/commitlint) and [husky](https://github.com/typicode/husky) to prevent bad commit message.
26+
For example, you want to submit the following commit message `git commit -s -am "my bad commit"`.
27+
You will receive the following error :
28+
```
29+
✖ type must be one of [ci, feat, fix, docs, style, refactor, perf, test, revert, chore] [type-enum]
30+
```
31+
Here an exemple that will pass the verification: `git commit -s -am "chore(opentelemetry-core): update deps"`
32+
2233
### Fork
2334

2435
In the interest of keeping this repository clean and manageable, you should work from a fork. To create a fork, click the 'Fork' button at the top of the repository, then clone the fork locally using `git clone [email protected]:USERNAME/opentelemetry-js.git`.

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@
2727
"author": "OpenTelemetry Authors",
2828
"license": "Apache-2.0",
2929
"devDependencies": {
30+
"@commitlint/cli": "^8.1.0",
31+
"@commitlint/config-conventional": "^8.1.0",
32+
"husky": "^3.0.1",
3033
"lerna": "^3.13.4",
3134
"typescript": "^3.4.5"
35+
},
36+
"husky": {
37+
"hooks": {
38+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
39+
}
3240
}
3341
}

0 commit comments

Comments
 (0)