Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for misspellings in CI #1825

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d0ec19f
Check for misspellings in CI
szepeviktor Sep 23, 2024
adf3f06
Add typos configuration
szepeviktor Sep 23, 2024
46a333a
Fix typos
szepeviktor Sep 23, 2024
afe3e0c
Check for misspellings in CI
szepeviktor Sep 23, 2024
9998f6c
Add typos configuration
szepeviktor Sep 23, 2024
6c6db6d
Fix typos
szepeviktor Sep 23, 2024
92655d4
Make typos emit only annotations
szepeviktor Sep 24, 2024
beb9c60
Merge branch 'main' into patch-1
szepeviktor Oct 22, 2024
4edcd6b
Merge branch 'main' into patch-1
szepeviktor Oct 28, 2024
c611fd2
Merge branch 'main' into patch-1
szepeviktor Nov 8, 2024
cad692d
Merge branch 'main' into patch-1
szepeviktor Nov 13, 2024
034db56
Merge branch 'main' into patch-1
szepeviktor Nov 20, 2024
590b850
Merge branch 'patch-1' of github.com:szepeviktor/web-features into pa…
szepeviktor Nov 20, 2024
d975580
Check for misspellings in CI
szepeviktor Sep 23, 2024
8d2f0cc
Add typos configuration
szepeviktor Sep 23, 2024
02b1e01
Make typos emit only annotations
szepeviktor Sep 24, 2024
f3fd2b3
Update .typos.toml
szepeviktor Dec 20, 2024
236b8f6
Merge branch 'patch-1' of github.com:szepeviktor/web-features into pa…
szepeviktor Jan 7, 2025
473f167
Merge branch 'main' into patch-1
szepeviktor Jan 9, 2025
f1129b3
Merge branch 'main' into patch-1
szepeviktor Jan 11, 2025
51ca473
Merge branch 'main' into patch-1
szepeviktor Jan 13, 2025
cfd3915
Merge branch 'main' into patch-1
szepeviktor Jan 15, 2025
5b478bd
Merge branch 'main' into patch-1
szepeviktor Jan 20, 2025
1cab68f
Merge branch 'main' into patch-1
szepeviktor Jan 27, 2025
9d30e60
Merge branch 'main' into patch-1
szepeviktor Jan 30, 2025
a4c04e2
Merge branch 'main' into patch-1
szepeviktor Feb 6, 2025
e285c61
Merge branch 'main' into patch-1
szepeviktor Feb 10, 2025
6c5b683
Merge branch 'main' into patch-1
szepeviktor Feb 22, 2025
bd716c3
Merge branch 'main' into patch-1
szepeviktor Feb 26, 2025
b79480b
Update .typos.toml
szepeviktor Feb 27, 2025
084acb9
Merge branch 'main' into patch-1
szepeviktor Mar 3, 2025
7b61209
Merge branch 'main' into patch-1
szepeviktor Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ jobs:
cache: npm
- run: npm ci
- run: npm test
spelling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
set -o pipefail
mkdir -p "${{ runner.temp }}/typos"
RELEASE_ASSET_URL="$(
gh api /repos/crate-ci/typos/releases/latest \
--jq '."assets"[] | select(."name" | test("^typos-.+-x86_64-unknown-linux-musl\\.tar\\.gz$")) | ."browser_download_url"'
)"
Comment on lines +39 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question here: ci/typos seems to be available as a GitHub Action (which I imagine we could pin and upgrade with Dependabot). How does this approach compare to using the Action?

Also, have you seen this used in other open projects with a lot of churn on files? I'd be curious to know what a real-world PR looks like following a workflow like this (I'm curious how contributors respond to the feedback given).

Copy link
Contributor Author

@szepeviktor szepeviktor Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend running typos in "passive" mode as a typo in code could be detrimental.

E.g. Go language encourages programmers to use 2 and 3 letter variable names. They usually look like English misspellings. That is all I know.

Copy link
Contributor Author

@szepeviktor szepeviktor Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos is just a super useful software - I need an LLM to argue.
Please love typos.

wget --quiet --output-document=- "${RELEASE_ASSET_URL}" \
| tar -xz -C "${{ runner.temp }}/typos" ./typos
git grep --files-with-matches --null -I -e '.' \
| xargs --null --verbose -- "${{ runner.temp }}/typos/typos" --format json \
| jq --raw-output '"::warning file=\(.path),line=\(.line_num),col=\(.byte_offset)::\"\(.typo)\" should be \"" + (.corrections // [] | join("\" or \"") + "\".")' \
|| true
Comment on lines +45 to +48
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather complicated! Is there any way this can be broken up or commented to make each step better explained? Or maybe an example showing the transformation going on here? I'm just not sure what this is doing.

Copy link
Contributor Author

@szepeviktor szepeviktor Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is enumerate files -> run typos -> convert output to GitHub check annotations.
All this code is hiding inside the GitHub Action of typos.
We talked about that typos should not stop a PR that is why I've copied the code from the Action and modified errors to warnings.

I've sent around ~500 PR-s advertising typos: https://github.com/pulls?q=is%3Apr+author%3Aszepeviktor+archived%3Afalse+Fix+typos
~5% of the people hate it.

env:
GH_TOKEN: ${{ github.token }}

env:
FORCE_COLOR: 3
28 changes: 28 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[files]
extend-exclude = [
".git/",
]
ignore-hidden = false

[default]
extend-ignore-re = [
"\\bext-shader-texture-lod\\b",
"\\bhttp\\.headers\\.ECT\\b",
"detail \\(LOD\\)",
]

[default.extend-words]
"clonable" = "clonable"
"seeked" = "seeked"
# https://github.com/web-platform-dx/web-features/pull/2484
"seperators" = "seperators"

[default.extend-identifiers]
"EXT_shader_texture_lod" = "EXT_shader_texture_lod"
"gatherND" = "gatherND"
"is_transitionable" = "is_transitionable"
"scatterND" = "scatterND"
"scheme_parameter_openpgp4fpr" = "scheme_parameter_openpgp4fpr"

# Typos
"Github" = "GitHub"