Skip to content

Commit

Permalink
feat: conventional commits (cometbft#1995)
Browse files Browse the repository at this point in the history
Check PR title follows the Conventional Commits spec.

---

#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
  • Loading branch information
melekes authored Jan 23, 2024
1 parent 1ca5487 commit 0b6c8ab
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ https://github.com/orgs/cometbft/projects/1
- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments

- [ ] Title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
51 changes: 51 additions & 0 deletions .github/workflows/conventional-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Conventional PR Title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
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 }}
```
General format: `type(scope): msg`
Breaking change: `type(scope)!: msg`
Multi-scope change: `type: msg`
Types: `feat`, `fix`, `build`, `chore`, `ci`, `docs`, `refactor`, `perf`, `test`, `revert`.
Example: `fix(cmd/cometbft/commands/debug): execute p.Signal only when p is not nil`
# 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
18 changes: 12 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,24 @@ Before merging a pull request:

### Git Commit Style

We follow the [Go style guide on commit messages][go-git-commit-style]. Write
concise commits that start with the package name and have a description that
finishes the sentence "This change modifies CometBFT to...". For example,
We follow the [Conventional Commits][conventional-commits] spec. Write concise
commits that start with a type (`fix`, `feat`, `chore`, `ci`, `docs`, etc.) and
an optional scope - package name (e.g., `feat(internal/consensus)`), followed
by a description that finishes the sentence "This change modifies CometBFT
to...".

If the commit introduces a breaking change, append the `!` after the scope
(e.g., `feat(internal/consensus)!`).

For example,

```sh
cmd/debug: execute p.Signal only when p is not nil
fix(cmd/cometbft/commands/debug): execute p.Signal only when p is not nil

[potentially longer description in the body]

Fixes #nnnn
```

Each PR should have one commit once it lands on `main`; this can be accomplished
by using the "squash and merge" button on GitHub. Be sure to edit your commit
message, though!
Expand Down Expand Up @@ -576,8 +582,8 @@ in the [OpenAPI file](./rpc/openapi/openapi.yaml)**.
[`clang-format`]: https://clang.llvm.org/docs/ClangFormat.html
[unclog]: https://github.com/informalsystems/unclog
[git-squash]: https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git
[go-git-commit-style]: https://tip.golang.org/doc/contribute.html#commit_messages
[go-testing]: https://golang.org/pkg/testing/
[Fuzz tests]: https://en.wikipedia.org/wiki/Fuzzing
[delve]: https://github.com/go-delve/delve
[log-lazy]: https://github.com/cometbft/cometbft/blob/main/libs/log/lazy.go
[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/

0 comments on commit 0b6c8ab

Please sign in to comment.