Skip to content

Commit 8b21462

Browse files
committed
Revert "checkpatch: remove and use clang-format instead"
The reverted commit intended to replace the old and no longer maintained checkpatch with clang-format. While I agree with this direction, the implementation was problematic. The script was completely removed without providing an alternative, leaving no verification for introduced code style. Additionally, the clang-format configuration file that was added is not being used anywhere. Furthermore, checkpatch performed two critical functions: it verified both code quality and commit message format (including signoff requirements). This second aspect was completely overlooked. As a result, commits lacking proper signoff have already been merged. Zephyr provides a better example of how this should be handled: checkpatch was removed from GitHub workflows but remains available in the repository for voluntary developer use. In parallel, CI enforces coding style and commit quality through other dedicated tools. This reverts commit aadcea2. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 5d59752 commit 8b21462

12 files changed

Lines changed: 14558 additions & 123 deletions

.clang-format

Lines changed: 0 additions & 121 deletions
This file was deleted.

.github/workflows/SPDX-README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Read this section if there are some SPDX warnings above.
2-
Adding correct SPDX headers to new files can be tricky because:
2+
Pleasing checkpatch is hard when adding new files because:
33

4-
- a different SPDX style is expected for .c versus .h files.
4+
- checkpatch requests a different SPDX style for .c versus .h files.
55
This is because some .h files are included in linker scripts or
66
assembly code.
77
- Some SOF reviewers reject C99 comments starting with //
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
set -e
5+
6+
# The purpose of this script is not to stop on the first checkpatch
7+
# failure and report at the end instead.
8+
#
9+
# Sample invocation:
10+
# $0 --codespell --strict < PR_SHAs.txt
11+
main()
12+
{
13+
local failures=0
14+
while read -r sha ; do
15+
printf '\n -------------- \n\n'
16+
./scripts/checkpatch.pl $@ -g $sha || failures=$((failures+1))
17+
done
18+
printf '\n -------------- \n\n'
19+
20+
if [ $failures -ne 0 ]; then
21+
cat .github/workflows/SPDX-README.md
22+
fi
23+
24+
return $failures
25+
}
26+
27+
main "$@"

.github/workflows/codestyle.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,44 @@ permissions:
1818
contents: read
1919

2020
jobs:
21+
checkpatch:
22+
runs-on: ubuntu-24.04
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
strictness: [null, --subjective]
28+
29+
env:
30+
PR_NUM: ${{github.event.number}}
31+
# TODO: reduce duplication with scripts/sof-*-commit-hook.sh
32+
# thanks to either some .conf file or some wrapper script
33+
CHK_CMD_OPTS: --ignore UNKNOWN_COMMIT_ID --codespell
34+
35+
steps:
36+
# depth 2 so:
37+
# ^1. we can show the Subject of the current target branch tip
38+
# ^2. we reconnect/graft to the later fetch pull/1234/head,
39+
- uses: actions/checkout@v4
40+
with: {fetch-depth: 2}
41+
42+
- name: install codespell
43+
run: sudo apt-get -y install codespell && dpkg -L codespell | grep dict
44+
45+
# See shallowness issue https://github.com/thesofproject/linux/issues/2556
46+
- name: fetch PR commits
47+
run: |
48+
.github/workflows/shallowfetchPRcommits.sh \
49+
${GITHUB_REPOSITORY} "$PR_NUM"
50+
# show what we got
51+
git --no-pager log --oneline --graph --decorate --max-count=50
52+
53+
- name: checkpatch
54+
env:
55+
STRICTNESS: ${{ matrix.strictness }}
56+
run: .github/workflows/checkpatch_list.sh ${CHK_CMD_OPTS}
57+
${STRICTNESS} < PR_SHAs.txt
58+
2159
yamllint:
2260
runs-on: ubuntu-latest
2361
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tools/test/audio/reports/*
4949
tools/test/audio/zeros_in.raw
5050

5151
__pycache__
52+
.checkpatch-camelcase.git.*
5253

5354
build*/
5455

0 commit comments

Comments
 (0)