diff options
author | Gergely Nagy <gergely.nagy@arm.com> | 2023-12-13 19:07:28 +0000 |
---|---|---|
committer | Gergely Nagy <gergely.nagy@arm.com> | 2024-01-23 12:53:01 +0000 |
commit | 732d8ef0bba9d23c731611dbed25e2e24a8a30d2 (patch) | |
tree | f369a01301e8a4634e232a9b0c21854e22f63b69 | |
parent | 54eec806272b7574a0757c77a913a369a9ecdc70 (diff) | |
download | mlia-732d8ef0bba9d23c731611dbed25e2e24a8a30d2.tar.gz |
build: Integrate Commitizen to check commit messages and generate changelog
The commit messages are checked against the Conventional Commits
(https://www.conventionalcommits.org) specification, along with minor
customizations (eg, capitalized header, some irrelevant commit types removed
Checking messages is integrated into `tox -e lint`.
Changelog generation is integrated into "tox -e changelog", which runs
`cz changelog` command underneath and incrementally updates RELEASES.md.
Change-Id: I86f21f6c78a166d3bb92450a027a2d7e71ce22cf
Signed-off-by: Gergely Nagy <gergely.nagy@arm.com>
-rw-r--r-- | .pre-commit-config.yaml | 6 | ||||
-rw-r--r-- | CONTRIBUTING.md | 4 | ||||
-rw-r--r-- | pyproject.toml | 22 | ||||
-rw-r--r-- | tox.ini | 7 |
4 files changed, 38 insertions, 1 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81e0acb..67bd90b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -118,3 +118,9 @@ repos: entry: pylint language: system types: [python] + +- repo: https://github.com/commitizen-tools/commitizen + rev: v3.13.0 + hooks: + - id: commitizen-branch + args: [--rev-range, HEAD~1..HEAD] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df12003..de70378 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,10 @@ Below is an overview on contributing code to MLIA. git commit -s ``` +- For the commit messages, the codebase follows [Conventional Commits](https://www.conventionalcommits.org), + with some customizations. Header description is be capitalized, and the following + commit types are allowed: build, ci, docs, feat, fix, perf, refactor, style, test. + - Push patch for code review ```bash diff --git a/pyproject.toml b/pyproject.toml index 827ae30..0c4cc8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-FileCopyrightText: Copyright (c) 2012-2022 Jukka Lehtosalo and contributors # SPDX-FileCopyrightText: Copyright (c) 2015-2022 Dropbox, Inc. # SPDX-License-Identifier: Apache-2.0 AND MIT @@ -73,3 +73,23 @@ module = [ "requests" ] ignore_missing_imports = true + +[tool.commitizen] +# This simply signifies that we want to customize the commitizen configuration +name = "cz_customize" +# name = "cz_conventional_commits" +tag_format = "$version" +version_scheme = "semver" +version_provider = "scm" +update_changelog_on_bump = true + +[tool.commitizen.customize] +# Schema pattern is used by `cz check`, and `tox -e lint` in turn. Builtin CC pattern: +# (?s)(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\\(\\S+\\))?!?:( [^\\n\\r]+)((\\n\\n.*)|(\\s*))?$ +# We customize this slightly by removing types that don't seem relevant now: +schema_pattern = "(?s)(build|ci|docs|feat|fix|perf|refactor|style|test)(\\(\\S+\\))?!?:( [A-Z][^\\n\\r]+)((\\n\\n.*)|(\\s*))?$" +schema = "<type>(<scope>): <Subject-capitalized>\n<BLANK LINE>\n<body>\n<BLANK LINE>\n(BREAKING CHANGE: )<footer>" +# Commit parser is used to render the commits for RELEASES.md +commit_parser = "^((?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\\((?P<scope>[^()\\r\\n]*)\\)|\\()?(?P<breaking>!)?|\\w+!):\\s(?P<message>.*)?" +# Change type map to render the title for that category as per {tag:title} +change_type_map = {'feat' = 'Feature changes', 'fix' = 'Bug fix', 'perf' = 'Performance improvements'} @@ -74,3 +74,10 @@ deps = commands = sphinx-apidoc -f -o docs/source src/mlia make --directory docs html + +[testenv:changelog] +description = Generate changelog using Commitizen. +deps = + commitizen==3.13.0 +commands = + cz changelog --file-name RELEASES.md --incremental |