GHA/checksrc: expand spellcheck, fix issues found

- codespell: break logic out into its own runnable script. Allowing
  to run it on local machines.
- codespell: install via `pip`, bump to latest version.
- codespell: show version number in CI log.
- codespell: drop no longer needed word exception: `msdos`.
- codespell: include all curl source tree, except `packages` and
  `winbuild`. Drop an obsolete file exclusion.
- add new spellchecker job using the `typos` tool. It includes
  the codespell dictionary and a couple more. Use linuxbrew to install
  it. This takes 10 seconds, while installing via `cargo` from source
  would take over a minute.
- codespell: introduce an inline ignore filter compatible with `cspell`
  Make `typos` recognize it, too. Move single exceptions inline.

Fix new typos found. Also rename variables and words to keep
spellchecking exceptions at minumum. This involves touching some tests.
Also switch base64 strings to `%b64[]` to avoid false positives.

Ref: https://github.com/crate-ci/typos/blob/master/docs/reference.md
Ref: https://github.com/codespell-project/codespell?tab=readme-ov-file#inline-ignore
Ref: https://github.com/codespell-project/codespell/issues/1212#issuecomment-1721152455
Ref: https://cspell.org/docs/Configuration/document-settings

Closes #17905
This commit is contained in:
Viktor Szakats 2025-07-11 21:50:23 +02:00
parent 792a61e204
commit 0260e8465a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
81 changed files with 279 additions and 206 deletions

View file

@ -1,16 +1,21 @@
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl
anonymou
aNULL
bu
clen
te
wont
statics
nome
wast
numer
anull
CNA
hel
htpt
inout
msdos
ba
fo
ede
PASE
passwor
perfec
proxys
seh
ser
strat
te
UE
WONT

20
.github/scripts/codespell.sh vendored Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# Copyright (C) Viktor Szakats
#
# SPDX-License-Identifier: curl
set -eu
cd "$(dirname "${0}")"/../..
# shellcheck disable=SC2046
codespell \
--skip '.github/scripts/spellcheck.words' \
--skip '.github/scripts/typos.toml' \
--skip 'docs/THANKS' \
--skip 'packages/*' \
--skip 'scripts/wcurl' \
--skip 'winbuild/*' \
--ignore-regex '.*spellchecker:disable-line' \
--ignore-words '.github/scripts/codespell-ignore.txt' \
$(git ls-files)

14
.github/scripts/typos.sh vendored Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
# Copyright (C) Viktor Szakats
#
# SPDX-License-Identifier: curl
set -eu
cd "$(dirname "${0}")"/../..
git ls-files | typos \
--isolated \
--force-exclude \
--config '.github/scripts/typos.toml' \
--file-list -

29
.github/scripts/typos.toml vendored Normal file
View file

@ -0,0 +1,29 @@
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl
[default]
extend-ignore-identifiers-re = [
"^(ba|pn|PN|UE)$",
"^(CNA|ser)$",
"^(ECT0|ECT1|HELO|htpt|PASE)$",
"^[A-Za-z0-9_-]*(EDE|GOST)[A-Z0-9_-]*$", # ciphers
"^0x[0-9a-fA-F]+FUL$", # unsigned long hex literals ending with 'F'
"^[0-9a-zA-Z+]{64,}$", # possibly base64
"^(Januar|eyeballers|HELO_smtp|kno22|MkTypLibCompatible|optin|passin|perfec|__SecURE|SMTP_HELO|v_alue)$",
"^(clen|req_clen|smtp_perform_helo|smtp_state_helo_resp|_stati64)$",
]
extend-ignore-re = [
".*spellchecker:disable-line",
]
[files]
extend-exclude = [
".github/scripts/codespell-ignore.txt",
".github/scripts/spellcheck.words",
"docs/THANKS",
"packages/*",
"scripts/wcurl",
"winbuild/*",
]

View file

@ -45,8 +45,8 @@ jobs:
- name: 'check'
run: scripts/checksrc-all.pl
codespell-cmakelint-pytype-ruff:
name: 'codespell, cmakelint, pytype, ruff'
spellcheck-cmakelint-pytype-ruff:
name: 'spellcheck, cmakelint, pytype, ruff'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@ -61,20 +61,23 @@ jobs:
sudo apt-get -o Dpkg::Use-Pty=0 update
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get -o Dpkg::Use-Pty=0 install \
codespell python3-pip python3-networkx python3-pydot python3-yaml \
python3-pip python3-networkx python3-pydot python3-yaml \
python3-toml python3-markupsafe python3-jinja2 python3-tabulate \
python3-typing-extensions python3-libcst python3-impacket \
python3-websockets python3-pytest python3-filelock python3-pytest-xdist
python3 -m pip install --break-system-packages cmakelang==0.6.13 pytype==2024.10.11 ruff==0.11.9
python3 -m pip install --break-system-packages cmakelang==0.6.13 pytype==2024.10.11 ruff==0.11.9 codespell==2.4.1
- name: 'spellcheck'
- name: 'codespell'
run: |
codespell \
--skip scripts/mk-ca-bundle.pl \
--skip src/tool_hugehelp.c \
--skip scripts/wcurl \
-I .github/scripts/codespell-ignore.txt \
CMake include m4 scripts src lib
codespell --version
.github/scripts/codespell.sh
- name: 'typos'
run: |
/home/linuxbrew/.linuxbrew/bin/brew install typos-cli
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
typos --version
.github/scripts/typos.sh
- name: 'cmakelint'
run: scripts/cmakelint.sh