-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pre-commit for conventional commit #4082
Open
davidspek
wants to merge
1
commit into
distribution:main
Choose a base branch
from
davidspek:conventional-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Conventional Commits | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
name: Conventional Commits | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Conventional Commit | ||
uses: webiny/action-conventional-commits@v1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/compilerla/conventional-pre-commit | ||
rev: v2.4.0 | ||
hooks: | ||
- id: conventional-pre-commit | ||
stages: [commit-msg] | ||
args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,30 @@ You should follow the basic GitHub workflow: | |
Refer to [containerd's contribution guide](https://github.com/containerd/project/blob/master/CONTRIBUTING.md#successful-changes) | ||
for tips on creating a successful contribution. | ||
|
||
## Commit Formatting | ||
|
||
This project adheres to [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#specification) for commit formatting. To make adhering to Conventional Commit easier [pre-commit](https://pre-commit.com/) can be used to validate commit messages before they are created. To install the [pre-commit](https://pre-commit.com/) and the git hook please run the following commands: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add an example, or a list of the tags? |
||
### Install pre-commit | ||
|
||
davidspek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```bash | ||
pip install pre-commit | ||
``` | ||
|
||
Or on Mac: | ||
|
||
```bash | ||
brew install pre-commit | ||
``` | ||
|
||
For more options please see the pre-commit [installation instructions](https://pre-commit.com/#install) | ||
|
||
### Install the git hook | ||
|
||
```bash | ||
pre-commit install | ||
``` | ||
|
||
## Sign your work | ||
|
||
The sign-off is a simple line at the end of the explanation for the patch. Your | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should this be
distribution/distribution
? I'm reading this but I might be missing something https://github.com/compilerla/conventional-pre-commit#usageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's the repo where
pre-commit
is getting the source code forconventional-pre-commit
. You can also usepre-commit
to manage all sorts of other git hooks and their versions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, so that's basically saying: code in repo X will make the checks. Well that's not clear from their README 🫠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really a huge fan of this solution for managing git hooks. But all the other ones I've found that look better are really focused on Node based projects and I'm not sure they'd integrate nicely. I did find a way it could be done using Go, but either we'd add additional dependencies to the project or I'd need to create a new tool that we can then use (which I might down the line).