From 46169d0bff7b6fcccf6c59417e930fe9937a04d0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 21 Mar 2023 14:44:24 +0100 Subject: [PATCH] ci: add changelog reminder (#15459) --- .github/PULL_REQUEST_TEMPLATE.md | 38 +++---- .github/workflows/changelog-reminder.yml | 19 ++++ .github/workflows/lint-pr.yml | 29 ++++- Makefile | 1 + cliff.toml | 128 +++++++++++++++++++++++ contrib/devtools/Makefile | 2 +- contrib/githooks/pre-commit | 2 +- math/CHANGELOG.md | 75 ++++++++++--- scripts/update-swagger-ui-statik.sh | 2 - 9 files changed, 254 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/changelog-reminder.yml create mode 100644 cliff.toml delete mode 100755 scripts/update-swagger-ui-statik.sh diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0a9d960e8cfd..ef76a1033ad3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -21,17 +21,17 @@ please add links to any relevant follow up issues.* I have... -- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title -- [ ] added `!` to the type prefix if API or client breaking change -- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) -- [ ] provided a link to the relevant issue or specification -- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) -- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) -- [ ] added a changelog entry to `CHANGELOG.md` -- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) -- [ ] updated the relevant documentation or specification -- [ ] reviewed "Files changed" and left comments if necessary -- [ ] confirmed all CI checks have passed +* [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title +* [ ] added `!` to the type prefix if API or client breaking change +* [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) +* [ ] provided a link to the relevant issue or specification +* [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) +* [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) +* [ ] added a changelog entry to `CHANGELOG.md` +* [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) +* [ ] updated the relevant documentation or specification +* [ ] reviewed "Files changed" and left comments if necessary +* [ ] confirmed all CI checks have passed ### Reviewers Checklist @@ -40,11 +40,11 @@ your handle next to the items reviewed if you only reviewed selected items.* I have... -- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title -- [ ] confirmed `!` in the type prefix if API or client breaking change -- [ ] confirmed all author checklist items have been addressed -- [ ] reviewed state machine logic -- [ ] reviewed API design and naming -- [ ] reviewed documentation is accurate -- [ ] reviewed tests and test coverage -- [ ] manually tested (if applicable) +* [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title +* [ ] confirmed `!` in the type prefix if API or client breaking change +* [ ] confirmed all author checklist items have been addressed +* [ ] reviewed state machine logic +* [ ] reviewed API design and naming +* [ ] reviewed documentation is accurate +* [ ] reviewed tests and test coverage +* [ ] manually tested (if applicable) diff --git a/.github/workflows/changelog-reminder.yml b/.github/workflows/changelog-reminder.yml new file mode 100644 index 000000000000..f20648777080 --- /dev/null +++ b/.github/workflows/changelog-reminder.yml @@ -0,0 +1,19 @@ +# Checks if a changelog is missing in the PR diff +name: Changelog Reminder +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: ["**/*.go"] +permissions: + pull-requests: write +jobs: + remind: + name: Changelog Reminder + runs-on: ubuntu-latest + # Skip draft PRs and PRs starting with: revert, test, chore, ci, docs, style, build, refactor + if: ${{ !github.event.pull_request.draft }} && !contains(github.event.pull_request.title, 'revert') && !contains(github.event.pull_request.title, 'test') && !contains(github.event.pull_request.title, 'chore') && !contains(github.event.pull_request.title, 'ci') && !contains(github.event.pull_request.title, 'docs') && !contains(github.event.pull_request.title, 'style') && !contains(github.event.pull_request.title, 'build') && !contains(github.event.pull_request.title, 'refactor') + steps: + - uses: actions/checkout@v3 + - uses: mskelton/changelog-reminder-action@v3 + with: + message: "@${{ github.actor }} your pull request is missing a changelog!" diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index d66554bc299e..7fc1f5ae949f 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -13,10 +13,35 @@ permissions: jobs: main: permissions: - pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs - statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR + pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs + statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR runs-on: ubuntu-latest steps: - uses: amannn/action-semantic-pull-request@v5.2.0 + id: lint_pr_title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. + if: always() && (steps.lint_pr_title.outputs.error_message != null) + with: + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true diff --git a/Makefile b/Makefile index 96dfdd054eb3..16187935e11a 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,7 @@ go.sum: go.mod godocs: @echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types" + go install golang.org/x/tools/cmd/godoc@latest godoc -http=:6060 build-docs: diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 000000000000..7c023e1b54e6 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,128 @@ +# configuration file for git-cliff (0.1.0) + +[changelog] +# changelog header +header = """ + + +# Changelog + +""" +# template for the changelog body +body = """ +{% if version %}\ + ## [{{ version }}](https://github.com/cosmos/cosmos-sdk/releases/tag/{{version}}) - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [Unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + * {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ + +""" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = true +# regex for preprocessing the commit messages +commit_preprocessors = [ + { pattern = '.*', replace_command = 'sed -E "s/^(\S+)\s(.+)\s\((#[0-9]+)\)$/\1 (\3) \2/"' }, + # A reference to an issue is appened to commits that looks like "(#1234)", this will be replaced + # with a link to that issue, e.g. "[#$1234](https://github.com/cosmos/cosmos-sdk/issues/1234)". + { pattern = '\(#(\d+)\)', replace = "[#${1}](https://github.com/cosmos/cosmos-sdk/issues/${1})" }, + # replace multiple spaces with one space + { pattern = " +", replace = " "}, + + # the following patterns only exist because "split_commits" is set to true, and we are processesing + # each line of the commit as a separate message. + # these exist to filter out common messages that appear in commit messages that are technically + # conventional, but we do not way to include in the changelog. + { pattern = '^Signed-off-by:.*', replace='' }, + { pattern = '^Co-authored-by:.*', replace='' }, + # don't include references to issues as changelog entries. + { pattern = '^ref:.*', replace='' }, + # exclude CVSS format, CVE can still be included in regular conventinal commits. + { pattern = 'CVSS:.*', replace='' }, + # don't include dependabot auto merge entries. + { pattern = '.*dependabot-automerge-.*', replace='' }, + # don't include statements saying which issue is closed. + { pattern = '^closes:.*|Closes:.*', replace='' }, + # remove standalone links in the commit messages. + { pattern = '^https://.*', replace='' }, + # remove lines with html. + { pattern = '^<.*', replace='' }, +] + +# regex for parsing and grouping commits +commit_parsers = [ + # specifying the number in a comment is a workaround to enable ordering of groups. + # these comments are stripped out of the markdown with the filter "{{ group | striptags | trim | upper_first }}" + # above in the body template. + { message = "^((?i)feature|(?i)feat)", group = "Features" }, + { message = "^((?i)improvements|(?i)imp|(?i)impr|(?i)perf)", group = "Improvements" }, + { message = "^((?i)fix|(?i)bug)", group = "Bug Fixes" }, + { message = '^.*\(api\)!', group = "API Breaking" }, + { message = '^.*\(statemachine\)!', group = "State Machine Breaking" }, + { message = "^((?i)test)", group = "Testing" }, + { message = "^((?i)doc|(?i)docs|(?i)documentation)", group = "Documentation" }, + { message = "^((?i)deprecated)", group = "Deprecated" }, + { message = "^((?i)deps|(?i)dep|(?i)build)", group = "Dependencies" }, + { message = "^revert|^ci|^chore|^refactor", skip = true} # explicitly skips changelog for reverts, CI, chore and refactor commits +] +# filter out the commits that are not matched by commit parsers +filter_commits = true +# glob pattern for matching git tags +# note SDK tags are purposely ignored, only submodules are included. +tag_pattern = "**/v[0-9]*" +# regex for skipping tags +skip_tags = "" +# regex for ignoring tags +ignore_tags = "" +# sort the tags chronologically +date_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "newest" \ No newline at end of file diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 44ce235878cf..e302695bdb18 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -63,7 +63,7 @@ $(RUNSIM): @go install github.com/cosmos/tools/cmd/runsim@v1.0.0 tools-clean: - rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) + rm -f $(GOLANGCI_LINT) $(RUNSIM) rm -f tools-stamp .PHONY: tools-clean runsim \ No newline at end of file diff --git a/contrib/githooks/pre-commit b/contrib/githooks/pre-commit index 2a9ad27af683..1913defd4a66 100755 --- a/contrib/githooks/pre-commit +++ b/contrib/githooks/pre-commit @@ -25,7 +25,7 @@ f_check_cmds if [[ $STAGED_GO_FILES != "" ]]; then f_echo_stderr "[pre-commit] fmt'ing staged files..." for file in $STAGED_GO_FILES; do - if [[ $file =~ vendor/ ]] || [[ $file =~ client/docs/statik/ ]] || [[ $file =~ tests/mocks/ ]] || [[ $file =~ \.pb\.go ]]; then + if [[ $file =~ vendor/ ]] || [[ $file =~ tests/mocks/ ]] || [[ $file =~ \.pb\.go ]]; then continue fi diff --git a/math/CHANGELOG.md b/math/CHANGELOG.md index 3efa0e274b59..43e36e120b6f 100644 --- a/math/CHANGELOG.md +++ b/math/CHANGELOG.md @@ -11,28 +11,69 @@ Mention whether you follow Semantic Versioning. Usage: -Change log entries are to be added to the Unreleased section under the -appropriate stanza (see below). Each entry should ideally include a tag and -the Github issue reference in the following format: +Changelog entries are generated by git cliff ref: https://github.com/orhun/git-cliff -* () [#] Changelog message. +Each commit should be conventional, the following message groups are supported. -Types of changes (Stanzas): +* feat: A new feature +* fix: A bug fix +* docs: Documentation only changes +* style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) +* refactor: A code change that neither fixes a bug nor adds a feature +* perf: A code change that improves performance +* test: Adding missing tests or correcting existing tests +* build: Changes that affect the build system or external dependencies (example scopes: go, npm) +* ci: Changes to our CI configuration files and scripts (example scopes: GH Actions) +* chore: Other changes that don't modify src or test files +* revert: Reverts a previous commit -"Features" for new features. -"Improvements" for changes in existing functionality. -"Deprecated" for soon-to-be removed features. -"Bug Fixes" for any bug fixes. -"API Breaking" for breaking exported APIs used by developers building on SDK. -Ref: https://keepachangelog.com/en/1.0.0/ +When a change is made that affects the API or state machine, the commit message prefix should be suffixed with `!`. + +Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json --> # Changelog -## [Unreleased] +## [math/v1.0.0-rc.0](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.0.0-rc.0) - 2023-03-13 + +### Features + +* [#15043](https://github.com/cosmos/cosmos-sdk/issues/15043) add rand funcs to math + +### Bug Fixes + +* [#14922](https://github.com/cosmos/cosmos-sdk/issues/14922) check for negative precision + +### Testing + +* [#15215](https://github.com/cosmos/cosmos-sdk/issues/15215) fix `FormatDec` test + +## [math/v1.0.0-beta.6](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.0.0-beta.6) - 2023-02-06 + +### Features + +* [#14760](https://github.com/cosmos/cosmos-sdk/issues/14760) add collections key encoders and value encoders for common types. +* [#14166](https://github.com/cosmos/cosmos-sdk/issues/14166) math: add generics versions of Max, Min to cater to all numeric types +* [#13381](https://github.com/cosmos/cosmos-sdk/issues/13381) add uint `IsNil` method + +### Improvements + +* [#14010](https://github.com/cosmos/cosmos-sdk/issues/14010) math: optimize and test FormatInt + simplify LegacyNewDecFromStr +* [#12794](https://github.com/cosmos/cosmos-sdk/issues/12794) math: precompute & use square of precisionReuse instead of 2 repeated computations + +### Bug Fixes + +* [#14691](https://github.com/cosmos/cosmos-sdk/issues/14691) do not flatten events attributes by event types +* [#14252](https://github.com/cosmos/cosmos-sdk/issues/14252) math: add LegacyNewDecFromStr fuzzers + remove unnecessary error wrapping + +### Testing + +* [#14576](https://github.com/cosmos/cosmos-sdk/issues/14576) Added test cases for precisionMultiplier + +## [math/v1.0.0-beta.3](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.0.0-beta.3) - 2022-07-20 + +### Bug Fixes + +* [#11996](https://github.com/cosmos/cosmos-sdk/issues/11996) math: fix Uint.Unmarshal's lack of negative value checking -* [#14010](https://github.com/cosmos/cosmos-sdk/pull/14010) Optimize FormatInt to not do plain string concentation when formatting thousands and instead build it more efficiently. -* [#13381](https://github.com/cosmos/cosmos-sdk/pull/13381) Add uint `IsNil` method. -* [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package, call it `LegacyDec`. -* [#14166](https://github.com/cosmos/cosmos-sdk/pull/14166) Add generics versions of Max and Min, catering to all numeric types and allow for variadic calls, replacing the prior typed and strenuous code -* [#15043](https://github.com/cosmos/cosmos-sdk/pull/15043) Add rand functions for testing purposes + diff --git a/scripts/update-swagger-ui-statik.sh b/scripts/update-swagger-ui-statik.sh deleted file mode 100755 index f58b2e755763..000000000000 --- a/scripts/update-swagger-ui-statik.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -statik -src=./client/docs/swagger-ui -dest=./client/docs -f