Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/config/gitlint/gitlint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Config for linting git commit messages
[general]
extra-path=.github/config/gitlint/rules

[title-match-regex]
regex=^(feat|fix|docs|style|refactor|perf|test|chore)(\(.*\))?: .*

[author-valid-email]
regex=[^@ ]+@[^@ ]+\.[^@ ]+
34 changes: 34 additions & 0 deletions .github/config/gitlint/rules/github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from gitlint.rules import CommitRule, RuleViolation
from gitlint.options import IntOption
import re

class SignedOffBy(CommitRule):
""" This rule will enforce that each commit contains a "Signed-off-by" line with a name and email address.
"""
id = "SIGNOFF"
name = "body-requires-signed-off-by"

signOffRegex = re.compile('^(DCO 1.1 )?Signed-off-by: .* <[^@ ]+@[^@ ]+\.[^@ ]+>')

def validate(self, commit):
for line in commit.message.body:
if self.signOffRegex.match(line):
return

return [RuleViolation(self.id, "Body does not contain a valid 'Signed-off-by' line", line_nr=1)]


class GithubIssue(CommitRule):
""" This rule will enforce that each commit is associated with a Github issue that explains what the commit is for.
"""
id = "COMMIT"
name = "commit-require-github-issue"

githubIssueRegex = re.compile('(Resolves|Closes|Contributes to|Reverts):? [a-z\-/]*#[0-9]+')

def validate(self, commit):
for line in commit.message.body:
if self.githubIssueRegex.match(line):
return

return [RuleViolation(self.id, "Body does not contain a github issue reference", line_nr=1)]
20 changes: 20 additions & 0 deletions .github/workflows/gitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Gitlint

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
name: Gitlint

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install gitlint
run: pip install gitlint
- name: Execute gitlint
run: gitlint --config=.github/config/gitlint/gitlint.cfg --debug