Commit 209559ca authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason Committed by Shinya Maeda
Browse files

ci: add commitlint for conventional commits

parent a8a5b569
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
.DS_Store
.idea
*.log
tmp/
node_modules/
+11 −0
Original line number Diff line number Diff line
@@ -469,3 +469,14 @@ rspec:
    - gem install --no-document rspec
  script:
    - rspec test/rspec

commitlint:
  stage: test
  image: node:12
  needs: []
  before_script:
    - npm install
  script:
    - npx --quiet commitlint --from="$CI_MERGE_REQUEST_DIFF_BASE_SHA" --help-url 'https://gitlab.com/gitlab-org/cluster-integration/auto-deploy-image#git-commit-guidelines'
  rules:
    - if: "$CI_MERGE_REQUEST_EVENT_TYPE != 'merge_train' && $CI_MERGE_REQUEST_DIFF_BASE_SHA"
+27 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ that will build and tag the new image

This project uses [Semantic Versioning](https://semver.org). We use commit
messages to automatically determine the version bumps, so they should adhere to
the conventions of [Conventional Commits (v1.0.0-beta.2)](https://www.conventionalcommits.org/en/v1.0.0-beta.2/).
the conventions of [Conventional Commits (v1.0.0)](https://www.conventionalcommits.org/en/v1.0.0).

### TL;DR

@@ -54,6 +54,32 @@ the conventions of [Conventional Commits (v1.0.0-beta.2)](https://www.convention
- Commit title starting with `feat: ` trigger a minor version bump
- Commit body contains `BREAKING CHANGE: ` trigger a major version bump. This can be part of commits of any _type_.

### Tip: Test commit messages locally

Testing the commit message locally can speed up the iteration cycle. It can be configured as follows:

``` sh
# install dev dependencies, if necessary
npm install

# usage
npx commitlint --from=master # if targeting latest
npx commitlint --from=1.x # if targeting 1.x stable
```

### Tip: Use a git hook with commitlint

To save yourself the manual step of testing the commit message, you can use a commit hook.

At the root of this project, add `.git/hooks/commit-msg` with the following contents:

``` sh
#!/bin/sh
npx commitlint --edit
```

Then, run `chmod +x .git/hooks/commit-msg` to make it executable.

## Automatic versioning

Each push to `master` triggers a [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/)

commitlint.config.js

0 → 100644
+3 −0
Original line number Diff line number Diff line
module.exports = {
    extends: ['@commitlint/config-conventional'],
};

package-lock.json

0 → 100644
+3264 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading