mirror of
https://github.com/OpenAMP/open-amp.git
synced 2026-02-06 02:54:32 +08:00
CI: add codespell support to check typos
Enable the use of codespell tool in checkpatch.pl For this the checkpatch.pl as been partially rebased on the Linux one. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This commit is contained in:
committed by
Arnaud Pouliquen
parent
f27850d74d
commit
b90535e319
2
.github/workflows/compliance.yml
vendored
2
.github/workflows/compliance.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: Install python dependencies
|
||||
run: |
|
||||
pip3 install setuptools
|
||||
pip3 install junitparser==1.6.3 gitlint
|
||||
pip3 install junitparser==1.6.3 gitlint codespell
|
||||
- name: Run Compliance Tests
|
||||
continue-on-error: true
|
||||
id: compliance
|
||||
|
||||
@@ -56,6 +56,7 @@ my $min_conf_desc_length = 4;
|
||||
my $spelling_file = "$D/spelling.txt";
|
||||
my $codespell = 0;
|
||||
my $codespellfile = "/usr/share/codespell/dictionary.txt";
|
||||
my $user_codespellfile = "";
|
||||
my $conststructsfile = "$D/const_structs.checkpatch";
|
||||
my $typedefsfile = "";
|
||||
my $color = "auto";
|
||||
@@ -115,7 +116,7 @@ Options:
|
||||
--ignore-perl-version override checking of perl version. expect
|
||||
runtime errors.
|
||||
--codespell Use the codespell dictionary for spelling/typos
|
||||
(default:/usr/share/codespell/dictionary.txt)
|
||||
(default:$codespellfile)
|
||||
--codespellfile Use this codespell dictionary
|
||||
--typedefsfile Read additional types from this file
|
||||
--color[=WHEN] Use colors 'always', 'never', or only when output
|
||||
@@ -223,7 +224,7 @@ GetOptions(
|
||||
'debug=s' => \%debug,
|
||||
'test-only=s' => \$tst_only,
|
||||
'codespell!' => \$codespell,
|
||||
'codespellfile=s' => \$codespellfile,
|
||||
'codespellfile=s' => \$user_codespellfile,
|
||||
'typedefsfile=s' => \$typedefsfile,
|
||||
'color=s' => \$color,
|
||||
'no-color' => \$color, #keep old behaviors of -nocolor
|
||||
@@ -234,6 +235,27 @@ GetOptions(
|
||||
|
||||
help(0) if ($help);
|
||||
|
||||
if ($user_codespellfile) {
|
||||
# Use the user provided codespell file unconditionally
|
||||
$codespellfile = $user_codespellfile;
|
||||
} elsif (!(-f $codespellfile)) {
|
||||
# If /usr/share/codespell/dictionary.txt is not present, try to find it
|
||||
# under codespell's install directory: <codespell_root>/data/dictionary.txt
|
||||
if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") {
|
||||
my $python_codespell_dict = << "EOF";
|
||||
|
||||
import os.path as op
|
||||
import codespell_lib
|
||||
codespell_dir = op.dirname(codespell_lib.__file__)
|
||||
codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt')
|
||||
print(codespell_file, end='')
|
||||
EOF
|
||||
|
||||
my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`;
|
||||
$codespellfile = $codespell_dict if (-f $codespell_dict);
|
||||
}
|
||||
}
|
||||
|
||||
list_types(0) if ($list_types);
|
||||
|
||||
$fix = 1 if ($fix_inplace);
|
||||
|
||||
@@ -194,7 +194,8 @@ class CheckPatch(ComplianceTest):
|
||||
diff = subprocess.Popen(('git', 'diff', COMMIT_RANGE),
|
||||
stdout=subprocess.PIPE)
|
||||
try:
|
||||
subprocess.check_output(checkpatch + ' --mailback' + ' --no-tree' + ' -',
|
||||
subprocess.check_output(checkpatch + ' --mailback' + ' --codespell' +
|
||||
' --no-tree' + ' -',
|
||||
stdin=diff.stdout,
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=True, cwd=GIT_TOP)
|
||||
|
||||
Reference in New Issue
Block a user