Skip to content

Commit 965569d

Browse files
Merge #56
56: Add commit linting r=matthiasbeyer a=matthiasbeyer This PR adds commit linting in the actions workflows as well as a lint to block PRs that contain `git-commit --fixup` or `git-commit --squash` commits. Co-authored-by: Matthias Beyer <[email protected]>
2 parents 979195b + e4d773e commit 965569d

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

.github/workflows/commit-lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
pull_request:
3+
4+
name: Pull Request Checks
5+
6+
jobs:
7+
block-fixup:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Block fixup commit merge
12+
uses: 13rac1/[email protected]
13+
14+
commit-lint:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'pull_request'
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.x'
24+
- run: pip install gitlint
25+
- run: gitlint --commits $(git merge-base origin/master HEAD)..HEAD

.gitlint

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Edit this file as you like.
2+
#
3+
# All these sections are optional. Each section with the exception of [general] represents
4+
# one rule and each key in it is an option for that specific rule.
5+
#
6+
# Rules and sections can be referenced by their full name or by id. For example
7+
# section "[body-max-line-length]" could also be written as "[B1]". Full section names are
8+
# used in here for clarity.
9+
#
10+
[general]
11+
# Ignore certain rules, this example uses both full name and id
12+
ignore=body-is-missing
13+
14+
# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this
15+
# verbosity = 2
16+
17+
# By default gitlint will ignore merge, revert, fixup and squash commits.
18+
ignore-merge-commits=true
19+
# ignore-revert-commits=true
20+
# ignore-fixup-commits=true
21+
# ignore-squash-commits=true
22+
23+
# Ignore any data send to gitlint via stdin
24+
# ignore-stdin=true
25+
26+
# Fetch additional meta-data from the local repository when manually passing a
27+
# commit message to gitlint via stdin or --commit-msg. Disabled by default.
28+
# staged=true
29+
30+
# Hard fail when the target commit range is empty. Note that gitlint will
31+
# already fail by default on invalid commit ranges. This option is specifically
32+
# to tell gitlint to fail on *valid but empty* commit ranges.
33+
# Disabled by default.
34+
# fail-without-commits=true
35+
36+
# Enable debug mode (prints more output). Disabled by default.
37+
# debug=true
38+
39+
# Enable community contributed rules
40+
# See http://jorisroovers.github.io/gitlint/contrib_rules for details
41+
contrib=CC1
42+
43+
# Set the extra-path where gitlint will search for user defined rules
44+
# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
45+
# extra-path=examples/
46+
47+
# This is an example of how to configure the "title-max-length" rule and
48+
# set the line-length it enforces to 50
49+
# [title-max-length]
50+
# line-length=50
51+
52+
# Conversely, you can also enforce minimal length of a title with the
53+
# "title-min-length" rule:
54+
# [title-min-length]
55+
# min-length=5
56+
57+
# [title-must-not-contain-word]
58+
# Comma-separated list of words that should not occur in the title. Matching is case
59+
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
60+
# will not cause a violation, but "WIP: my title" will.
61+
# words=wip
62+
63+
# [title-match-regex]
64+
# python-style regex that the commit-msg title must match
65+
# Note that the regex can contradict with other rules if not used correctly
66+
# (e.g. title-must-not-contain-word).
67+
# regex=^US[0-9]*
68+
69+
# [body-max-line-length]
70+
# line-length=72
71+
72+
# [body-min-length]
73+
# min-length=5
74+
75+
# [body-is-missing]
76+
# Whether to ignore this rule on merge commits (which typically only have a title)
77+
# default = True
78+
# ignore-merge-commits=false
79+
80+
# [body-changed-file-mention]
81+
# List of files that need to be explicitly mentioned in the body when they are changed
82+
# This is useful for when developers often erroneously edit certain files or git submodules.
83+
# By specifying this rule, developers can only change the file when they explicitly reference
84+
# it in the commit message.
85+
# files=gitlint-core/gitlint/rules.py,README.md
86+
87+
# [body-match-regex]
88+
# python-style regex that the commit-msg body must match.
89+
# E.g. body must end in My-Commit-Tag: foo
90+
# regex=My-Commit-Tag: foo$
91+
92+
# [author-valid-email]
93+
# python-style regex that the commit author email address must match.
94+
# For example, use the following regex if you only want to allow email addresses from foo.com
95+
# regex=[^@][email protected]
96+
97+
# [ignore-by-title]
98+
# Ignore certain rules for commits of which the title matches a regex
99+
# E.g. Match commit titles that start with "Release"
100+
# regex=^Release(.*)
101+
102+
# Ignore certain rules, you can reference them by their id or by their full name
103+
# Use 'all' to ignore all rules
104+
# ignore=T1,body-min-length
105+
106+
# [ignore-by-body]
107+
# Ignore certain rules for commits of which the body has a line that matches a regex
108+
# E.g. Match bodies that have a line that that contain "release"
109+
# regex=(.*)release(.*)
110+
#
111+
# Ignore certain rules, you can reference them by their id or by their full name
112+
# Use 'all' to ignore all rules
113+
# ignore=T1,body-min-length
114+
115+
# [ignore-body-lines]
116+
# Ignore certain lines in a commit body that match a regex.
117+
# E.g. Ignore all lines that start with 'Co-Authored-By'
118+
# regex=^Co-Authored-By
119+
120+
# [ignore-by-author-name]
121+
# Ignore certain rules for commits of which the author name matches a regex
122+
# E.g. Match commits made by dependabot
123+
# regex=(.*)dependabot(.*)
124+
#
125+
# Ignore certain rules, you can reference them by their id or by their full name
126+
# Use 'all' to ignore all rules
127+
# ignore=T1,body-min-length
128+
129+
# This is a contrib rule - a community contributed rule. These are disabled by default.
130+
# You need to explicitly enable them one-by-one by adding them to the "contrib" option
131+
# under [general] section above.
132+
# [contrib-title-conventional-commits]
133+
# Specify allowed commit types. For details see: https://www.conventionalcommits.org/
134+
# types = bugfix,user-story,epic
135+
[contrib-body-requires-signed-off-by]
136+
137+

0 commit comments

Comments
 (0)