Skip to content
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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/conventional-commit.yml
@@ -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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
Copy link
Member

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#usage

Copy link
Collaborator Author

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 for conventional-pre-commit. You can also use pre-commit to manage all sorts of other git hooks and their versions.

Copy link
Member

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 🫠

Copy link
Collaborator Author

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).

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]
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -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:

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Expand Down