Skip to content

Commit

Permalink
build: add commit message format requirements
Browse files Browse the repository at this point in the history
From now on, all new commit messages must adhere to the conventional
commits v1.0.0 spec and their max line length is limited to 72
characters. The rules are enforced with commitlint, which is run as a
pre-commit hook and also as a stage in the GitHub CI pipeline.
  • Loading branch information
tuomas777 committed Dec 11, 2023
1 parent 1e714ed commit f61063e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ jobs:
linters: isort
run: isort . --check-only --diff

- name: Check commitlint
uses: wagoid/commitlint-github-action@0d749a1a91d4770e983a7b8f83d4a3f0e7e0874e # v5.4.4

# With pytest-cov use: --cov=.
# Some errors, skipping --doctest-modules for now
- name: Run tests
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Keep tool versions in sync with the versions in requirements-dev.txt
default_language_version:
python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit, manual]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -25,3 +27,9 @@ repos:
hooks:
- id: isort
exclude: "migrations"
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.10.0
hooks:
- id: commitlint
stages: [commit-msg, manual]
additional_dependencies: ["@commitlint/config-conventional"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ git config blame.ignoreRevsFile .git-blame-ignore-revs
```


## Commit message format

New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/)
specification, and line length is limited to 72 characters.

When [`pre-commit`](https://pre-commit.com/) is in use, [`commitlint`](https://github.com/conventional-changelog/commitlint)
checks new commit messages for the correct format.


## Search

Linkedevents uses Elasticsearch for generating results on the /search-endpoint. If you wish to use that functionality, proceed like so:
Expand Down
10 changes: 10 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Configuration = {
extends: ['@commitlint/config-conventional'],
rules: {
'header-max-length': [2, 'always', 72],
'body-max-line-length': [2, 'always', 72],
'body-leading-blank': [2, 'always'],
},
};

module.exports = Configuration;

0 comments on commit f61063e

Please sign in to comment.