1name: checkpatch
2
3on:
4  pull_request:
5    branches: [ main ]
6
7permissions: read-all
8
9jobs:
10  checkpatch:
11    runs-on: ubuntu-22.04
12    steps:
13    - name: Checkout Code
14      uses: actions/checkout@v4
15
16    - name: Download Checkpatch Files from Zephyr RTOS
17      shell: bash
18      run: |
19        wget https://github.com/zephyrproject-rtos/zephyr/raw/main/scripts/checkpatch.pl -O ./checkpatch.pl
20        chmod +x ./checkpatch.pl
21        wget https://github.com/zephyrproject-rtos/zephyr/raw/main/.checkpatch.conf -O ./.checkpatch.conf
22        wget https://github.com/zephyrproject-rtos/zephyr/raw/main/scripts/spelling.txt -O ./spelling.txt
23        echo "--ignore PREFER_ALIGNED" >> ./.checkpatch.conf
24        echo "--ignore NEW_TYPEDEFS" >> ./.checkpatch.conf
25        echo "--ignore PREFER_PACKED" >> ./.checkpatch.conf
26        echo "--ignore CONSTANT_COMPARISON" >> ./.checkpatch.conf
27        echo "--ignore FUNCTION_ARGUMENTS" >> ./.checkpatch.conf
28
29    - name: Set Git Base
30      shell: bash
31      run: |
32        git fetch origin ${{ github.event.pull_request.base.ref }}
33        echo "checkpatch base is: $(git show FETCH_HEAD --oneline --raw)"
34
35    - name: Run Checkpath
36      shell: bash
37      run:
38        git diff --patch FETCH_HEAD | ./checkpatch.pl --no-tree --codespellfile ./spelling.txt -
39