Skip to content

Commit fd68e60

Browse files
IdanHoawesomekling
authored andcommitted
CI: Make BuggieBot reply to pull requests that fail the commit linter
This should help reduce the repeating "Please check the contributing guide" replies from reviewers.
1 parent 873eb47 commit fd68e60

File tree

2 files changed

+55
-43
lines changed

2 files changed

+55
-43
lines changed

.github/workflows/cmake.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -245,50 +245,8 @@ jobs:
245245
UBSAN_OPTIONS: "halt_on_error=1"
246246
if: ${{ matrix.with-fuzzers == 'NO_FUZZ' }}
247247

248-
lint_commits:
249-
runs-on: ubuntu-20.04
250-
if: always() && github.event_name == 'pull_request'
251-
252-
steps:
253-
- name: Get PR Commits
254-
id: 'get-pr-commits'
255-
uses: tim-actions/get-pr-commits@55b867b9b28954e6f5c1a0fe2f729dc926c306d0
256-
with:
257-
token: ${{ secrets.GITHUB_TOKEN }}
258-
259-
- name: Check linebreaks
260-
if: ${{ success() || failure() }}
261-
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
262-
with:
263-
commits: ${{ steps.get-pr-commits.outputs.commits }}
264-
pattern: '^[^\r]*$'
265-
error: 'Commit message contains CRLF line breaks (only unix-style LF linebreaks are allowed)'
266-
267-
- name: Check Line Length
268-
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
269-
with:
270-
commits: ${{ steps.get-pr-commits.outputs.commits }}
271-
pattern: '^.{0,72}(\n.{0,72})*$'
272-
error: 'Commit message lines are too long (maximum allowed is 72 characters)'
273-
274-
- name: Check subsystem
275-
if: ${{ success() || failure() }}
276-
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
277-
with:
278-
commits: ${{ steps.get-pr-commits.outputs.commits }}
279-
pattern: '^\S.*?: .+'
280-
error: 'Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)'
281-
282-
- name: Check title
283-
if: ${{ success() || failure() }}
284-
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
285-
with:
286-
commits: ${{ steps.get-pr-commits.outputs.commits }}
287-
pattern: '^.+[^.\n](\n.*)*$'
288-
error: 'Commit title ends in a period'
289-
290248
notify_irc:
291-
needs: [build_and_test_serenity, build_and_test_lagom, lint_commits]
249+
needs: [build_and_test_serenity, build_and_test_lagom]
292250
runs-on: ubuntu-20.04
293251
if: always() && github.repository == 'SerenityOS/serenity' && (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master'))
294252

.github/workflows/lintcommits.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Commit linter
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
lint_commits:
7+
runs-on: ubuntu-20.04
8+
if: always() && github.repository == 'SerenityOS/serenity'
9+
10+
steps:
11+
- name: Get PR Commits
12+
id: 'get-pr-commits'
13+
uses: IdanHo/get-pr-commits@d94b66d146a31ef91e54a2597dee4fb523157232
14+
with:
15+
token: ${{ secrets.GITHUB_TOKEN }}
16+
17+
- name: Check linebreaks
18+
if: ${{ success() || failure() }}
19+
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
20+
with:
21+
commits: ${{ steps.get-pr-commits.outputs.commits }}
22+
pattern: '^[^\r]*$'
23+
error: 'Commit message contains CRLF line breaks (only unix-style LF linebreaks are allowed)'
24+
25+
- name: Check Line Length
26+
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
27+
with:
28+
commits: ${{ steps.get-pr-commits.outputs.commits }}
29+
pattern: '^.{0,72}(\n.{0,72})*$'
30+
error: 'Commit message lines are too long (maximum allowed is 72 characters)'
31+
32+
- name: Check subsystem
33+
if: ${{ success() || failure() }}
34+
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
35+
with:
36+
commits: ${{ steps.get-pr-commits.outputs.commits }}
37+
pattern: '^\S.*?: .+'
38+
error: 'Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)'
39+
40+
- name: Check title
41+
if: ${{ success() || failure() }}
42+
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
43+
with:
44+
commits: ${{ steps.get-pr-commits.outputs.commits }}
45+
pattern: '^.+[^.\n](\n.*)*$'
46+
error: 'Commit title ends in a period'
47+
48+
- name: Comment on PR
49+
if: ${{ failure() }}
50+
uses: unsplash/comment-on-pr@85a56be792d927ac4bfa2f4326607d38e80e6e60
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.BUGGIEBOT }}
53+
with:
54+
msg: "One or more of the commits in this PR do not match the [code submission policy](https://github.com/SerenityOS/serenity/blob/master/CONTRIBUTING.md#code-submission-policy), please check the `lint_commits` CI job for more details."

0 commit comments

Comments
 (0)