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