https://github.com/webispy/checkpatch-action
Github action for checkpatch.pl
https://github.com/webispy/checkpatch-action
action c checkpatch checkpatch-action code-review docker kernel lint
Last synced: about 1 month ago
JSON representation
Github action for checkpatch.pl
- Host: GitHub
- URL: https://github.com/webispy/checkpatch-action
- Owner: webispy
- Created: 2019-10-17T10:33:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T13:12:25.000Z (about 2 years ago)
- Last Synced: 2025-03-25T13:39:16.839Z (about 2 months ago)
- Topics: action, c, checkpatch, checkpatch-action, code-review, docker, kernel, lint
- Language: Shell
- Homepage:
- Size: 20.5 KB
- Stars: 7
- Watchers: 1
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Github action for `checkpatch.pl`
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.
## Screenshots
### Result of checkpatch

### Code annotations

You can also check the comments directly in the console log.

## Action setup guide
### Pull Request
.github/workflows/main.yml
```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:```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 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:
```yml
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}}
```### `checkpatch.pl` configuration
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.
#### Example for `.checkpatch.conf` file
```text
# 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
```## References
### checkpatch tool
Following files are used to this project.
-
-### Patch
#### Add option for excluding directories
From [zephyr](https://github.com/zephyrproject-rtos/zephyr) project:
-
#### Disable warning for "No structs that should be const ..."
-
### Docker image
You can find the Dockerfile from [docker](https://github.com/webispy/checkpatch-action/tree/docker) branch of this repository.
## License
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).