aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/checkpatch.yml
blob: 0da6c541094171680571130c31a6092f03c95b65 (plain) (blame)
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
name: Checkpatch

on:
  pull_request:
    types: [opened, synchronize, reopened]
    branches:
      - master

jobs:
  checkpatch:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      with:
        fetch-depth: 0
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y perl
    - name: Run checkpatch.pl
      run: |
        if [ -z "${{ github.base_ref }}" ]; then
          echo "Not a pull request, skipping checkpatch"
          exit 0
        fi
        git fetch origin ${{ github.base_ref }}
        base_commit=$(git merge-base origin/${{ github.base_ref }} HEAD)
        echo "Base commit: $base_commit"
        echo "Running checkpatch.pl on all commits in the PR:"
        git rev-list --reverse $base_commit..HEAD | while read commit; do
          # Skip dependabot commits - we do not have control over it
          if git log -1 --format='%ae' $commit | grep -q "dependabot"; then
            echo "Skipping dependabot commit: $commit"
            continue
          fi
          subject=$(git log -1 --format=%s $commit)
          echo "Checking commit: $commit - $subject"
          if ! ./checkpatch.pl --max-line-length=100 --no-tree --ignore MAINTAINERS,SPDX_LICENSE_TAG,COMMIT_MESSAGE,FILE_PATH_CHANGES,EMAIL_SUBJECT,AVOID_EXTERNS,GIT_COMMIT_ID,ENOSYS_SYSCALL,ENOSYS,FROM_SIGN_OFF_MISMATCH,QUOTED_COMMIT_ID,PREFER_ATTRIBUTE_ALWAYS_UNUSED,PREFER_DEFINED_ATTRIBUTE_MACRO  -g $commit; then
            echo "checkpatch.pl found issues in commit $commit - $subject"
            exit 1
          fi
        done