summaryrefslogtreecommitdiff
path: root/.github/workflows/lintcommits.yml
blob: 229e5f5c176fa5a7d3f694174c03b0a9a942730f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Commit linter

on: [pull_request_target]

jobs:
  lint_commits:
    runs-on: ubuntu-20.04
    if: always() && github.repository == 'SerenityOS/serenity' && !github.event.pull_request.draft

    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 }}
          pattern: '^.{0,72}(\n.{0,72})*$'
          error: 'Commit message lines are too long (maximum allowed is 72 characters)'

      - 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 }}
          pattern: '^\S.*?: .+'
          error: 'Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)'

      - 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]'
          error: 'First word of commit after the subsystem is not capitalized'

      - 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'

      - name: Comment on PR
        if: ${{ failure() }}
        uses: IdanHo/comment-on-pr@5f51df338210754f519f721f8320d8f72525a4d0
        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."