Skip to content

CI: enable codespell - #16302

Merged
xiaoxiang781216 merged 3 commits into
apache:masterfrom
sumpfralle:ci-enable-codespell
May 5, 2025
Merged

xiaoxiang781216 merged 3 commits into
apache:masterfrom
sumpfralle:ci-enable-codespell

Conversation

@sumpfralle

Copy link
Copy Markdown
Contributor

Summary

These commits add a .codespellrc configuration file with suitable defaults and comments for all relevant use-cases in nuttx.

Additionally the github workflow "check" is extended to run the codespell check on changed files.
The log message of the check refers to the .codespellrc file in order to help people skip valid false positives.

At the moment, 1990 out of 25838 files in the nuttx repository are reported by codespell as containing errors. I already prepared two pull requests, which will reduce the number of reported files to 630. In case I can keep the mood up, I may grind this number down to zero in the next days.

Impact

CI

CI tests will start to fail, if a file contains a spelling problem (as detected by codespell).

In case of a problem the PR submitter will:

  1. Notice the failed CI workflow "check".
  2. Take a look at that CI job log.
  3. In case of a real spelling mistake:
    1. Fix the issue and update the PR.
  4. In case of a misdetected spelling issue:
    1. Notice the reference to the file .codespellrc in the CI log.
    2. Take a look at the file .codespellrc and hopefully understands easily, which approach would be suitable for this issue (exclude the word, line or file).

pre-commit

The pre-commit check displays spelling problems in changed files.
The configuration file (.codespellrc) is mentioned.

Testing

CI

I did not test the CI workflow for now. This PR will be the first example.

pre-commit

The pre-commit hook now detects spelling problems in changed files:

$ git diff HEAD~..HEAD
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0402b282d3..065b3494b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,4 @@
+# foo
 # ##############################################################################
 # CMakeLists.txt
 #
$ pre-commit run --from HEAD~ --to HEAD
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for added large files..............................................Passed
cmake-format.............................................................Passed
nxstyle..................................................................Failed
- hook id: nxstyle
- exit code: 1

Used config files:
    1: .codespellrc
CMakeLists.txt:162: inital ==> initial
CMakeLists.txt:271: platfrom ==> platform
CMakeLists.txt:318: Unsupport ==> Unsupported
CMakeLists.txt:385: extenstion ==> extension

@github-actions github-actions Bot added Area: CI Size: S The size of the change in this PR is small labels May 2, 2025
@nuttxpr

nuttxpr commented May 2, 2025

Copy link
Copy Markdown

[Experimental Bot, please feedback here]

Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary.

Yes, this PR meets the NuttX requirements, although the Testing section could be improved.

Strengths:

  • Clear Summary: The summary explains the "why," "what," and "how" of the change effectively.
  • Thorough Impact Assessment: The impact section covers all relevant areas and clearly explains the potential effects of the change, especially on CI and pre-commit workflows.
  • Provides Context: The summary provides valuable context about the current state of spelling errors in the repository and your plan to address them.

Weaknesses:

  • Incomplete Testing: While pre-commit testing is shown, the crucial CI testing is missing. You must test and demonstrate the CI integration before merging. Include the CI logs after the changes are implemented showing the successful codespell check. Since this PR introduces the CI check, showing it working is essential.
  • Missing Build Host/Target Information: Even though the core change is not platform-specific, it's still good practice to provide information about the environment where you developed and tested these changes (OS, compiler, etc.). While the changes affect the CI pipeline, which runs on various systems, specifying your local development environment is helpful for reproducibility.

Recommendation:

Before merging, add the following:

  1. CI Test Results: Run the CI workflow with this PR and include the successful logs in the Testing section. Show how the CI reacts both to a file with a spelling error and a file without.
  2. Development Environment Details: Add details about your build host in the Testing section (OS, CPU architecture, compiler). Even if it's not strictly required for this change, it's good practice and improves reproducibility.

By addressing these points, your PR will be even stronger and demonstrate that the changes are thoroughly tested and ready for integration.

@xiaoxiang781216 xiaoxiang781216 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for enabling the spell check.

Comment thread .github/workflows/check.yml Resolved
@sumpfralle
sumpfralle force-pushed the ci-enable-codespell branch from 49a322b to 039f04d Compare May 3, 2025 04:09

@xiaoxiang781216 xiaoxiang781216 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks.

@hartmannathan hartmannathan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding codespell to CI!

Comment thread .codespell-ignore-lines Resolved
sumpfralle added 3 commits May 5, 2025 01:39
This file can be extended in order to cover all spelling check
exceptions (perceived as misspellings).
@sumpfralle
sumpfralle force-pushed the ci-enable-codespell branch from 039f04d to cc3f0f7 Compare May 4, 2025 23:41
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@sumpfralle you could add the spell check fix in this PR, so we can proceed more quickly.

@xiaoxiang781216
xiaoxiang781216 merged commit 4d70fa7 into apache:master May 5, 2025
@sumpfralle
sumpfralle deleted the ci-enable-codespell branch May 5, 2025 11:24
@simbit18

simbit18 commented May 5, 2025 •

Copy link
Copy Markdown
Contributor

@sumpfralle

Copy link
Copy Markdown
Contributor Author

need to do the same also in the nuttx-apps repository

Yes, I plan to take a look at the apps repository, after everything is finished for the nuttx repository.

@simbit18

simbit18 commented May 8, 2025

Copy link
Copy Markdown
Contributor

@sumpfralle Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CI Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants