Skip to content

Add codespell support (config, workflow to detect/not fix) and make it fix some typos #14454

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yarikoptic
Copy link

More about codespell: https://github.com/codespell-project/codespell .

I personally introduced it to dozens if not hundreds of projects already and so far only positive feedback.

CI workflow has 'permissions' set only to 'read' so also should be safe.

There is some fixes in the code as well, but eyeballing those changes they seems to be kosher... well -- tests should show, right?

@Joibel
Copy link
Member

Joibel commented May 7, 2025

@yarikoptic - thanks for this, it looks interesting and is something we could possibly adopt.

We'd obviously need it to pass CI. My brief take on getting that to happen:

  • Sign DCO
  • We'd need codespell action pinning
  • We'd need codegen to pass, which probably means that the Makefile needs to learn to codespell. make -B codegen inside a devcontainer is the easiest way to see what this will do. It might be necessary to change which files get checked. Ideally codespell would learn not to check generated files - all ours should be detectable.
  • Even if you don't need to make the Makefile know how to codespell for codegen, I'd still want a Makefile target like that so I can know my code passes before pushing.

yarikoptic added 5 commits May 7, 2025 11:22
Signed-off-by: Yaroslav O. Halchenko <[email protected]>
…(but ignoring overall fail due to ambigous ones)

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w || :",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav O. Halchenko <[email protected]>
…os automagically

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w  -w -i 3 -C 4",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav O. Halchenko <[email protected]>
Signed-off-by: Yaroslav O. Halchenko <[email protected]>
@yarikoptic
Copy link
Author

  • Sign DCO

done

  • We'd need codespell action pinning

do you use any helper for that, e.g. smth like https://www.npmjs.com/package/pin-github-action

  • We'd need codegen to pass,

it seems that test fails are due to interaction with other components of argo which still carry those typos, like conditons... yet to see what the "sequence" of fixes across repos to be, please advise

which probably means that the Makefile needs to learn to codespell. make -B codegen inside a devcontainer is the easiest way to see what this will do. It might be necessary to change which files get checked. Ideally codespell would learn not to check generated files - all ours should be detectable.

ATM there is no (easy/built-in) way to skip files based on content (e.g. matching "Code generated by"), could only easily skip based on matching filenames (e.g. *_generated*)... but also raises the question: why generated files should have typos?

  • Even if you don't need to make the Makefile know how to codespell for codegen, I'd still want a Makefile target like that so I can know my code passes before pushing.

done, there is codespell target now. Should it be added to lint or pre-commit dependencies?

@Joibel
Copy link
Member

Joibel commented May 8, 2025

  • Sign DCO

done

Thanks

  • We'd need codespell action pinning

do you use any helper for that, e.g. smth like https://www.npmjs.com/package/pin-github-action

No, we just pin manually.

  • We'd need codegen to pass,

it seems that test fails are due to interaction with other components of argo which still carry those typos, like conditons... yet to see what the "sequence" of fixes across repos to be, please advise

This would require argo-events to be fixed, then a release made, and then us to import that new release in go.mod. (Technically the release could be skipped and we import as a SHA, but for spelling only that feels like it does more harm than good).

which probably means that the Makefile needs to learn to codespell. make -B codegen inside a devcontainer is the easiest way to see what this will do. It might be necessary to change which files get checked. Ideally codespell would learn not to check generated files - all ours should be detectable.

ATM there is no (easy/built-in) way to skip files based on content (e.g. matching "Code generated by"), could only easily skip based on matching filenames (e.g. *_generated*)... but also raises the question: why generated files should have typos?

If generated files have typos but they're imported typos (e.g. we're embedding a documented struct from another project as we do) we can't fix them.

The non-generated file typos should be detected and then the generated files regenerated to be fixed also.

  • Even if you don't need to make the Makefile know how to codespell for codegen, I'd still want a Makefile target like that so I can know my code passes before pushing.

done, there is codespell target now. Should it be added to lint or pre-commit dependencies?

Yes, this must be in the dependencies for pre-commit.

In order that this is satisfactory it should get installed, and we do this (somewhat badly) via the Makefile, so that you can spin up a devcontainer and run make pre-commit and it just works - installing the tools it needs along the way.

@yarikoptic
Copy link
Author

ok, let's then be "sequential" to avoid messing with exclusions etc, and first get

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants