From d1a81d8bd762ad95f5d89444153a872b9aff4bf9 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 21 Mar 2024 15:16:37 +0300 Subject: [PATCH] chore: Use git-cliff changelog generator (#9687) * chore: Use git-cliff changelog generator * Update cliff.toml Co-authored-by: Maxim Filonov <53992153+sl1depengwyn@users.noreply.github.com> * Update cliff.toml Co-authored-by: Fedor Ivanov --------- Co-authored-by: Maxim Filonov <53992153+sl1depengwyn@users.noreply.github.com> Co-authored-by: Fedor Ivanov --- CONTRIBUTING.md | 15 ++++--- PULL_REQUEST_TEMPLATE.md | 1 - cliff.toml | 84 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 cliff.toml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 122503bc252f..694f0e404236 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,13 @@ -## Contributing +# Contributing 1. Fork it ( ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Write tests that cover your work 4. Commit your changes (`git commit -am 'Add some feature'`) 5. Push to the branch (`git push origin my-new-feature`) -6. Create a new Pull Request -7. Update CHANGELOG.md with the link to PR and description of the changes +6. Create a new Pull Request. The title of Pull Request should follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and should start with `feat:`, `fix:`, `chore:`, `doc:`, `perf:`, `refactor:` prefix. -### General +## General * Commits should be one logical change that still allows all tests to pass. Prefer smaller commits if there could be two levels of logic grouping. The goal is to allow contributors in the future (including your own future self) to determine your reasoning for making changes and to allow them to cherry-pick, patch or port those changes in isolation to other branches or forks. * If during your PR you reveal a pre-existing bug: @@ -18,14 +17,14 @@ 2. Commit the fix for the bug. 3. Continue original PR work. -### Enhancements +## Enhancements Enhancements cover all changes that make users lives better: * [feature requests filed as issues](https://github.com/blockscout/blockscout/labels/enhancement) that impact end-user [contributors](https://github.com/blockscout/blockscout/labels/contributor) and [developers](https://github.com/blockscout/blockscout/labels/developer) * changes to the [architecture](https://github.com/blockscout/blockscout/labels/architecture) that make it easier for contributors (in the GitHub sense), dev-ops, and deployers to maintain and run blockscout -### Bug Fixes +## Bug Fixes For bug fixes, whenever possible, there should be at least 2 commits: @@ -34,7 +33,7 @@ For bug fixes, whenever possible, there should be at least 2 commits: This format ensures that we can run the test to reproduce the original bug without depending on the new code in the fix, which could lead to the test falsely passing. -### Incompatible Changes +## Incompatible Changes Incompatible changes can arise as a side-effect of either Enhancements or Bug Fixes. During Enhancements, incompatible changes can occur because, as an example, in order to support showing end-users new data, the database schema may need to be changed and the index rebuilt from scratch. During bug fixes, incompatible changes can occur because in order to fix a bug, the schema had to change, or how certain internal APIs are called changed. @@ -45,7 +44,7 @@ Incompatible changes can arise as a side-effect of either Enhancements or Bug Fi **NOTE**: A database reset and re-index is required ``` -### Pull Request +## Pull Request There is a [PULL_REQUEST_TEMPLATE.md](PULL_REQUEST_TEMPLATE.md) for this repository, but since it can't fill in the title for you, please follow the following steps when opening a Pull Request before filling in the template: diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 001deecbdfeb..bfc691bd1d2f 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -21,7 +21,6 @@ ## Checklist for your Pull Request (PR) - - [ ] I added an entry to `CHANGELOG.md` with this PR - [ ] If I added new functionality, I added tests covering it. - [ ] If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again. - [ ] I checked whether I should update the docs and did so by submitting a PR to https://github.com/blockscout/docs diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 000000000000..dd8e87fbd0f1 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,84 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +# Changelog\n +""" +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## Current +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = false +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/blockscout/blockscout/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "(?i)^feat", group = "🚀 Features" }, + { message = "(?i)^fix", group = "🐛 Bug Fixes" }, + { message = "(?i)^doc", group = "📚 Documentation" }, + { message = "(?i)^perf", group = "⚡ Performance" }, + { message = "(?i)^refactor", group = "🚜 Refactor" }, + { message = "(?i)^chore\\(release\\): prepare for", skip = true }, + { message = "(?i)^chore\\(deps.*\\)", skip = true }, + { message = "(?i)^chore\\(pr\\)", skip = true }, + { message = "(?i)^chore\\(pull\\)", skip = true }, + { message = "(?i)^chore|^ci", group = "⚙️ Miscellaneous Tasks" }, + { body = ".*security", group = "🛡️ Security" }, + { message = "^revert", group = "◀️ Revert" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = true +# regex for matching git tags +# tag_pattern = "v[0-9].*" +# regex for skipping tags +# skip_tags = "" +# regex for ignoring tags +# ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "newest" +# limit the number of commits included in the changelog. +# limit_commits = 42