|
| 1 | +name: Commit Message Check |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: |
| 5 | + - opened |
| 6 | + - reopened |
| 7 | + - synchronize |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +env: |
| 14 | + error_msg: |+ |
| 15 | + See the document below for help on formatting commits for the project. |
| 16 | + https://github.com/kata-containers/community/blob/main/CONTRIBUTING.md#patch-format |
| 17 | +jobs: |
| 18 | + commit-message-check: |
| 19 | + runs-on: ubuntu-22.04 |
| 20 | + env: |
| 21 | + PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
| 22 | + name: Commit Message Check |
| 23 | + steps: |
| 24 | + - name: Get PR Commits |
| 25 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} |
| 26 | + id: 'get-pr-commits' |
| 27 | + uses: tim-actions/[email protected] |
| 28 | + with: |
| 29 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + # Filter out revert commits |
| 31 | + # The format of a revert commit is as follows: |
| 32 | + # |
| 33 | + # Revert "<original-subject-line>" |
| 34 | + # |
| 35 | + # The format of a re-re-vert commit as follows: |
| 36 | + # |
| 37 | + # Reapply "<original-subject-line>" |
| 38 | + filter_out_pattern: '^Revert "|^Reapply "' |
| 39 | + |
| 40 | + - name: DCO Check |
| 41 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} |
| 42 | + uses: tim-actions/dco@2fd0504dc0d27b33f542867c300c60840c6dcb20 |
| 43 | + with: |
| 44 | + commits: ${{ steps.get-pr-commits.outputs.commits }} |
| 45 | + |
| 46 | + - name: Commit Body Missing Check |
| 47 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} |
| 48 | + uses: tim-actions/[email protected] |
| 49 | + with: |
| 50 | + commits: ${{ steps.get-pr-commits.outputs.commits }} |
| 51 | + |
| 52 | + - name: Check Subject Line Length |
| 53 | + if: ${{ (env.PR_AUTHOR != 'dependabot[bot]') && !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} |
| 54 | + uses: tim-actions/[email protected] |
| 55 | + with: |
| 56 | + commits: ${{ steps.get-pr-commits.outputs.commits }} |
| 57 | + pattern: '^.{0,75}(\n.*)*$' |
| 58 | + error: 'Subject too long (max 75)' |
| 59 | + post_error: ${{ env.error_msg }} |
| 60 | + |
| 61 | + - name: Check Body Line Length |
| 62 | + if: ${{ (env.PR_AUTHOR != 'dependabot[bot]') && !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} |
| 63 | + uses: tim-actions/[email protected] |
| 64 | + with: |
| 65 | + commits: ${{ steps.get-pr-commits.outputs.commits }} |
| 66 | + # Notes: |
| 67 | + # |
| 68 | + # - The subject line is not enforced here (see other check), but has |
| 69 | + # to be specified at the start of the regex as the action is passed |
| 70 | + # the entire commit message. |
| 71 | + # |
| 72 | + # - This check will pass if the commit message only contains a subject |
| 73 | + # line, as other body message properties are enforced elsewhere. |
| 74 | + # |
| 75 | + # - Body lines *can* be longer than the maximum if they start |
| 76 | + # with a non-alphabetic character or if there is no whitespace in |
| 77 | + # the line. |
| 78 | + # |
| 79 | + # This allows stack traces, log files snippets, emails, long URLs, |
| 80 | + # etc to be specified. Some of these naturally "work" as they start |
| 81 | + # with numeric timestamps or addresses. Emails can but quoted using |
| 82 | + # the normal ">" character, markdown bullets ("-", "*") are also |
| 83 | + # useful for lists of URLs, but it is always possible to override |
| 84 | + # the check by simply space indenting the content you need to add. |
| 85 | + # |
| 86 | + # - A SoB comment can be any length (as it is unreasonable to penalise |
| 87 | + # people with long names/email addresses :) |
| 88 | + pattern: '(^[^\n]+$|^.+(\n([a-zA-Z].{0,150}|[^a-zA-Z\n].*|[^\s\n]*|Signed-off-by:.*|))+$)' |
| 89 | + error: 'Body line too long (max 150)' |
| 90 | + post_error: ${{ env.error_msg }} |
| 91 | + |
| 92 | + - name: Check Subsystem |
| 93 | + if: ${{ (env.PR_AUTHOR != 'dependabot[bot]') && !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') && ( success() || failure() ) }} |
| 94 | + uses: tim-actions/[email protected] |
| 95 | + with: |
| 96 | + commits: ${{ steps.get-pr-commits.outputs.commits }} |
| 97 | + pattern: '^[\s\t]*[^:\s\t]+[\s\t]*:' |
| 98 | + error: 'Failed to find subsystem in subject' |
| 99 | + post_error: ${{ env.error_msg }} |
0 commit comments