The checkpatch.pl
is a perl script to verify that your code conforms to the Linux kernel coding style. This project uses checkpatch.pl
to automatically review and leave comments on pull requests.
You can also check the comments directly in the console log.
.github/workflows/main.yml
name: checkpatch review
on: [pull_request]
jobs:
my_review:
name: checkpatch review
runs-on: ubuntu-latest
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Run checkpatch review
uses: webispy/checkpatch-action@v9
For using a custom checkpatch script, pass the CHECKPATCH_COMMAND
environment
variable. For example, for DPDK's checkpatches.sh
script use:
name: checkpatch review
on: [pull_request]
jobs:
my_review:
name: checkpatch review
runs-on: ubuntu-latest
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Run DPDK checkpatches.sh review
uses: webispy/checkpatch-action@v9
env:
DPDK_CHECKPATCH_PATH: /usr/bin/checkpatch.pl
CHECKPATCH_COMMAND: ./devtools/checkpatches.sh
Note: For private repositories this action needs access to the GITHUB_TOKEN
. It needs read access to contents
and pull-requests
as minimum permissions. For example:
name: checkpatch review
on: [pull_request]
jobs:
my_review:
name: checkpatch review
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Run checkpatch review
uses: webispy/checkpatch-action@v9
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
The checkpatch.pl
tool supports a configuration file for setting options. Just create a .checkpatch.conf
file in the top-level directory of your project and specify options in it.
https://docs.kernel.org/dev-tools/checkpatch.html#type-descriptions
# This isn't actually a Linux kernel tree
--no-tree
--ignore CONFIG_DESCRIPTION
--ignore FILE_PATH_CHANGES
--ignore GERRIT_CHANGE_ID
--ignore GIT_COMMIT_ID
--ignore NEW_TYPEDEFS
--ignore SPDX_LICENSE_TAG
--ignore SPACING
--ignore CONST_STRUCT
--ignore EMBEDDED_FUNCTION_NAME
--exclude externals
--exclude examples
Following files are used to this project.
- https://github.com/raw/torvalds/linux/master/scripts/checkpatch.pl
- https://github.com/raw/torvalds/linux/master/scripts/spelling.txt
From zephyr project:
You can find the Dockerfile from docker branch of this repository.
The checkpatch.pl
file is a script in the Linux kernel source tree, so checkpatch-action projects and forked projects must comply with the GPL-2.0 license (kernel license).