Skip to content

Commit

Permalink
ci(pre-commit): enforce conventional-commits message structure
Browse files Browse the repository at this point in the history
This adds pre-commit and ci checks to ensure that commit messages follow
[`conventional-commits`](https://www.conventionalcommits.org/en/v1.0.0/).

From their site: Conventional Commits is:
`A specification for adding human and machine readable meaning to commit messages`

Commit messages must follow the following format:
```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

In general, this means that you will provide a topic:
* feat
* fix
* ci
* refactor

Followed by a description.

Following this standard allows for automatic semantic versioning and
release note generation.

* `.commitlintrc.yaml` - defines the commit message format for linting
* `.cz.json` - configuration for [`commitizen-cli`](http://commitizen.github.io/cz-cli/)
  • Loading branch information
greenkiwi committed Feb 23, 2022
1 parent 7d24279 commit b3854ea
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .commitlintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- "@commitlint/config-conventional"
4 changes: 4 additions & 0 deletions .cz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"maxHeaderWidth": 72,
"path": "cz-conventional-changelog"
}
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- uses: wagoid/commitlint-github-action@v2
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ repos:
- id: go-fmt
- id: go-mod-tidy
- id: go-build
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v5.0.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ the hooks by running the following command in the root of the repository:
pre-commit install
```

This repository following `Conventional Commits` for message formatting.
See: https://www.conventionalcommits.org/en/v1.0.0/

```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```

You can use commitizen to help generate commit messages.
See: http://commitizen.github.io/cz-cli/

### Running Project Built Locally

#### Terraform v0.12
Expand Down

0 comments on commit b3854ea

Please sign in to comment.