Skip to content

Commit 50d1313

Browse files
authored
chore: integrated git cliff into the code base to automate generation of changelogs (cosmos#2772)
1 parent aa189ce commit 50d1313

File tree

5 files changed

+176
-7
lines changed

5 files changed

+176
-7
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+29-6
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,41 @@ are the most critical to review.
1212

1313
closes: #XXXX
1414

15+
16+
### Commit Message / Changelog Entry
17+
18+
```bash
19+
type: commit message
20+
```
21+
22+
see the [guidelines](../CONTRIBUTING.md#commit-messages) for commit messages. (view raw markdown for examples)
23+
24+
25+
<!--
26+
Example commit messages:
27+
28+
fix: skip emission of unpopulated memo field in ics20
29+
deps: updating sdk to v0.46.4
30+
chore: removed unused variables
31+
e2e: adding e2e upgrade test for ibc-go/v6
32+
docs: ics27 v6 documentation updates
33+
feat: add semantic version utilities for e2e tests
34+
feat(api)!: this is an api breaking feature
35+
fix(statemachine)!: this is a statemachine breaking fix
36+
-->
37+
1538
---
1639

1740
Before we can merge this PR, please make sure that all the following items have been
1841
checked off. If any of the checklist items are not applicable, please leave them but
1942
write a little note why.
2043

21-
- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
44+
- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)).
2245
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
2346
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules/10-structure.md).
24-
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
25-
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
47+
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing).
48+
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`).
2649
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
27-
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
28-
- [ ] Re-reviewed `Files changed` in the Github PR explorer
29-
- [ ] Review `Codecov Report` in the comment section below once CI passes
50+
- [ ] Provide a [commit message](../CONTRIBUTING.md#commit-messages) to be used for the changelog entry in the PR description for review.
51+
- [ ] Re-reviewed `Files changed` in the Github PR explorer.
52+
- [ ] Review `Codecov Report` in the comment section below once CI passes.

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Types of changes (Stanzas):
2828
"Bug Fixes" for any bug fixes.
2929
"Client Breaking" for breaking CLI commands and REST routes used by end-users.
3030
"API Breaking" for breaking exported APIs used by developers building on SDK.
31-
"State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList.
31+
"State Machine Breaking" for any changes that result in a different AppState given the same genesisState and txList.
3232
Ref: https://keepachangelog.com/en/1.0.0/
3333
-->
3434

CONTRIBUTING.md

+23
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,29 @@ All PRs require an approval from at least one CODEOWNER before merge. PRs which
8585
- If you sat down with the PR submitter and did a pairing review please note that in the `Approval`, or your PR comments.
8686
- If you are only making "surface level" reviews, submit any notes as `Comments` without adding a review.
8787

88+
### Commit Messages
89+
90+
Commit messages should be [conventional](https://www.conventionalcommits.org/en/v1.0.0/).
91+
92+
If opening a PR, include the proposed commit message in the PR description.
93+
94+
The commit message type should be one of:
95+
96+
* `feat` / `feature` for feature work.
97+
* `bug` / `fix` for bug fixes.
98+
* `imp` / `improvements` for improvements.
99+
* `doc` / `docs` / `documentation` for any documentation changes.
100+
* `test` / `e2e` for addition or improvements of unit, integration and e2e tests or their corresponding infrastructure.
101+
* `deprecated` for deprecation changes.
102+
* `deps` / `build` for changes to dependencies.
103+
* `chore` / `misc` / `nit` for any miscellaneous changes that don't fit into another category.
104+
105+
**Note**: If any change is breaking, the following format must be used:
106+
* `type` + `(api)!` for api breaking changes, e.g. `fix(api)!: api breaking fix`
107+
* `type` + `(statemachine)!` for state machine breaking changes, e.g. `fix(statemachine)!: state machine breaking fix`
108+
109+
**`api` breaking changes take precedence over `statemachine` breaking changes.**
110+
88111
### Updating Documentation
89112

90113
If you open a PR on ibc-go, it is mandatory to update the relevant documentation in /docs.

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ view-docs:
207207
@cd docs && \
208208
npm install && npm run serve
209209

210+
211+
changelog:
212+
docker run --rm -v "$$(pwd)"/.git:/app/ -v "$$(pwd)/cliff.toml":/app/cliff.toml orhunp/git-cliff:latest --unreleased --tag $(tag)
213+
210214
.PHONY: build-docs
211215

212216
###############################################################################

cliff.toml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# configuration file for git-cliff (0.1.0)
2+
3+
[changelog]
4+
# changelog header
5+
header = """
6+
<!--
7+
Usage:
8+
9+
Change log entries are generated by git cliff ref: https://github.com/orhun/git-cliff
10+
This can be run using "make changelog tag=vx.y.z"
11+
12+
Each commit should be conventional, the following message groups are supported.
13+
14+
* feat, feature
15+
* imp
16+
* bug, fix
17+
* deprecated
18+
* (api)!
19+
* (statemachine)!
20+
21+
Types of changes (Stanzas):
22+
23+
"Features" for new features. (feat, feature)
24+
"Improvements" for changes in existing functionality. (imp)
25+
"Deprecated" for soon-to-be removed features.
26+
"Bug Fixes" for any bug fixes. (bug, fix)
27+
"API Breaking" for breaking exported APIs used by developers building on SDK. Add (api)! e.g. fix(api)!: api breaking fix
28+
"State Machine Breaking" for any changes that result in a different AppState given the same genesisState and txList. Add (statemachine)! e.g. fix(statemachine)!: state machine breaking fix
29+
Ref: https://keepachangelog.com/en/1.0.0/
30+
-->
31+
32+
# Changelog
33+
All notable changes to this project will be documented in this file.
34+
"""
35+
# template for the changelog body
36+
# https://tera.netlify.app/docs/#introduction
37+
body = """
38+
{% if version %}\
39+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
40+
{% else %}\
41+
## [unreleased]
42+
{% endif %}\
43+
{% for group, commits in commits | group_by(attribute="group") %}
44+
### {{ group | striptags | trim | upper_first }}
45+
{% for commit in commits %}
46+
* {{ commit.message | upper_first }}\
47+
{% endfor %}
48+
{% endfor %}\n
49+
"""
50+
# remove the leading and trailing whitespace from the template
51+
trim = true
52+
# changelog footer
53+
footer = """
54+
<!-- generated by git-cliff -->
55+
"""
56+
57+
[git]
58+
# parse the commits based on https://www.conventionalcommits.org
59+
conventional_commits = true
60+
# filter out the commits that are not conventional
61+
filter_unconventional = true
62+
# process each line of a commit as an individual commit
63+
split_commits = true
64+
# regex for preprocessing the commit messages
65+
commit_preprocessors = [
66+
# A reference to an issue is appened to commits that looks like "(#1234)", this will be replaced
67+
# with a link to that issue, e.g. "[#$1234](https://github.com/cosmos/ibc-go/issues/1234)".
68+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/cosmos/ibc-go/issues/${2}))" },
69+
# any reference to a pr like "pr-1234" will be replaced with a link to the PR.
70+
{ pattern = '\(pr-([0-9]+)\)', replace = "([#${1}](https://github.com/cosmos/ibc-go/pulls/${1}))" },
71+
72+
# the following patterns only exist because "split_commits" is set to true, and we are processesing
73+
# each line of the commit as a separate message.
74+
# these exist to filter out common messages that appear in commit messages that are technically
75+
# conventional, but we do not way to include in the changelog.
76+
{ pattern = '^Signed-off-by:.*', replace='' },
77+
{ pattern = '^Co-authored-by:.*', replace='' },
78+
# don't include references to issues as changelog entries.
79+
{ pattern = '^ref:.*', replace='' },
80+
# exclude CVSS format, CVE can still be included in regular conventinal commits.
81+
{ pattern = 'CVSS:.*', replace='' },
82+
# don't include dependabot auto merge entries.
83+
{ pattern = '.*dependabot-automerge-.*', replace='' },
84+
# don't include statements saying which issue is closed.
85+
{ pattern = '^closes:.*', replace='' },
86+
# remove standalone links in the commit messages.
87+
{ pattern = '^https://.*', replace='' },
88+
# remove lines with html.
89+
{ pattern = '^<.*', replace='' },
90+
]
91+
92+
# regex for parsing and grouping commits
93+
commit_parsers = [
94+
# specifying the number in a comment is a workaround to enable ordering of groups.
95+
# these comments are stripped out of the markdown with the filter "{{ group | striptags | trim | upper_first }}"
96+
# above in the body template.
97+
{ message = "^((?i)deps|(?i)dep|(?i)build)", group = "<!-- 0 -->Dependencies" },
98+
{ message = '^.*\(api\)!', group = "<!-- 1 -->API Breaking" },
99+
{ message = '^.*\(statemachine\)!', group = "<!-- 2 -->State Machine Breaking" },
100+
{ message = "^((?i)improvements|(?i)imp)", group = "<!-- 3 -->Improvements" },
101+
{ message = "^((?i)feature|(?i)feat)", group = "<!-- 4 -->Features" },
102+
{ message = "^((?i)fix|(?i)bug)", group = "<!-- 5 -->Bug Fixes" },
103+
{ message = "^((?i)doc|(?i)docs|(?i)documentation)", group = "<!-- 6 -->Documentation" },
104+
{ message = "^((?i)test|(?i)e2e)", group = "<!-- 7 -->Testing" },
105+
{ message = "^((?i)deprecated)", group = "<!-- 8 -->Deprecated" },
106+
{ message = "^((?i)chore|(?i)misc|(?i)nit)", group = "<!-- 9 -->Miscellaneous Tasks" },
107+
]
108+
# filter out the commits that are not matched by commit parsers
109+
filter_commits = false
110+
# glob pattern for matching git tags
111+
tag_pattern = "v[0-9]*"
112+
# regex for skipping tags
113+
skip_tags = ""
114+
# regex for ignoring tags
115+
ignore_tags = ""
116+
# sort the tags chronologically
117+
date_order = false
118+
# sort the commits inside sections by oldest/newest order
119+
sort_commits = "oldest"

0 commit comments

Comments
 (0)