2021-05-22 22:15:05 +00:00
name : Commit linter
on : [ pull_request_target]
2021-07-27 19:37:17 +00:00
# Make sure to update Meta/lint-commit.sh to match this script when adding new checks!
2021-05-22 22:15:05 +00:00
jobs :
lint_commits :
runs-on : ubuntu-20.04
2021-07-09 19:36:39 +00:00
if : always() && github.repository == 'SerenityOS/serenity'
2021-05-22 22:15:05 +00:00
steps :
- name : Get PR Commits
id : 'get-pr-commits'
uses : IdanHo/get-pr-commits@d94b66d146a31ef91e54a2597dee4fb523157232
with :
token : ${{ secrets.GITHUB_TOKEN }}
- name : Check linebreaks
if : ${{ success() || failure() }}
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
pattern : '^[^\r]*$'
error : 'Commit message contains CRLF line breaks (only unix-style LF linebreaks are allowed)'
- name : Check Line Length
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
2021-07-23 12:43:15 +00:00
pattern : '^.{0,72}(?:\n(?:(.{0,72})|(.*?([a-z]+:\/\/)?(([a-zA-Z0-9_]|-)+\.)+[a-z]{2,}(:\d+)?([a-zA-Z_0-9@:%\+.~\?&/=]|-)+).*?))*$'
error : 'Commit message lines are too long (maximum allowed is 72 characters, except for URLs)'
2021-05-22 22:15:05 +00:00
- name : Check subsystem
if : ${{ success() || failure() }}
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
2021-07-13 18:54:36 +00:00
pattern: '^\S.*?\S : .+'
2021-05-22 22:15:05 +00:00
error : 'Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)'
2021-06-16 13:41:17 +00:00
- name : Check first word of title for capitalization
if : ${{ success() || failure() }}
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^\S.*? : [ A-Z0-9]'
2021-06-16 20:04:48 +00:00
error : 'First word of commit after the subsystem is not capitalized'
2021-06-16 13:41:17 +00:00
2021-05-22 22:15:05 +00:00
- name : Check title
if : ${{ success() || failure() }}
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
pattern : '^.+[^.\n](\n.*)*$'
error : 'Commit title ends in a period'
2021-09-07 19:36:17 +00:00
- name : Check body for sign off
if : ${{ success() || failure() }}
uses : tim-actions/commit-message-checker-with-regex@v0.3.1
with :
commits : ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^((?!Signed-off-by : )[\s\S])*$'
error : 'Commit body contains a Signed-off-by tag'
2021-05-22 22:15:05 +00:00
- name : Comment on PR
2021-07-09 19:36:39 +00:00
if : ${{ failure() && !github.event.pull_request.draft }}
2021-05-23 22:37:45 +00:00
uses : IdanHo/comment-on-pr@5f51df338210754f519f721f8320d8f72525a4d0
2021-05-22 22:15:05 +00:00
env :
GITHUB_TOKEN : ${{ secrets.BUGGIEBOT }}
with :
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."