From 014c25bfaa40222d34f8d67a14373745aeb67990 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Wed, 24 Jul 2019 13:11:36 -0400 Subject: [PATCH] chore: add commitlint and husky Change CONTRIBUTING.md Resolves #117 Signed-off-by: Olivier Albertini --- .commitlintrc.yml | 29 +++++++++++++++++++++++++++++ CONTRIBUTING.md | 11 +++++++++++ package.json | 8 ++++++++ 3 files changed, 48 insertions(+) create mode 100644 .commitlintrc.yml diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 0000000000..1a5e5ac793 --- /dev/null +++ b/.commitlintrc.yml @@ -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; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47de6fedec..e822e2944a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,17 @@ Please read project contribution [guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md) 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 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`. diff --git a/package.json b/package.json index 27899c1a0c..c24c127fdb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,15 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "devDependencies": { + "@commitlint/cli": "^8.1.0", + "@commitlint/config-conventional": "^8.1.0", + "husky": "^3.0.1", "lerna": "^3.13.4", "typescript": "^3.4.5" + }, + "husky": { + "hooks": { + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } } }