chore: add commitlint and husky (#128)

Change CONTRIBUTING.md
Resolves #117

Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
This commit is contained in:
Olivier Albertini 2019-07-25 12:36:15 -04:00 committed by Mayur Kale
parent 02a2001c37
commit 44214acc21
3 changed files with 48 additions and 0 deletions

29
.commitlintrc.yml Normal file
View File

@ -0,0 +1,29 @@
extends:
- '@commitlint/config-conventional'
rules:
header-max-length: [1, 'always', 72]
type-enum:
- 2
- always
- - ci
- feat
- fix
- docs
- style
- refactor
- perf
- test
- revert
- chore
help: |
**Possible types**:
`ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle CI, BrowserStack, SauceLabs)
`feat`: Adds a new feature.
`fix`: Solves a bug.
`docs`: Adds or alters documentation. (example scopes: readme, worker, code_of_conduct, contributors)
`style`: Improves formatting, white-space.
`refactor`: Rewrites code without feature, performance or bug changes.
`perf`: Improves performance.
`test`: Adds or modifies tests. (example scopes: functionals, unit-tests)
`revert`: Changes that reverting other changes
`chore`: No production code change. Updating grunt tasks etc;

View File

@ -19,6 +19,17 @@ Please read project contribution
[guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md) [guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md)
for general practices for OpenTelemetry project. for general practices for OpenTelemetry project.
#### Conventional commit
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).
We use [commitlint](https://github.com/conventional-changelog/commitlint) and [husky](https://github.com/typicode/husky) to prevent bad commit message.
For example, you want to submit the following commit message `git commit -s -am "my bad commit"`.
You will receive the following error :
```
✖ type must be one of [ci, feat, fix, docs, style, refactor, perf, test, revert, chore] [type-enum]
```
Here an exemple that will pass the verification: `git commit -s -am "chore(opentelemetry-core): update deps"`
### Fork ### Fork
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 git@github.com:USERNAME/opentelemetry-js.git`. 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 git@github.com:USERNAME/opentelemetry-js.git`.

View File

@ -27,7 +27,15 @@
"author": "OpenTelemetry Authors", "author": "OpenTelemetry Authors",
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"husky": "^3.0.1",
"lerna": "^3.13.4", "lerna": "^3.13.4",
"typescript": "^3.4.5" "typescript": "^3.4.5"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
} }
} }