-
Notifications
You must be signed in to change notification settings - Fork 137
Fix spelling and grammar issues + add CI detection #501
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
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Configuration for codespell (https://github.com/codespell-project/codespell) | ||
| # Shared by the CI workflow and local runs: just run `codespell` from the repo root. | ||
| [codespell] | ||
| skip = ./.git,./build,./third_party,*.svg | ||
| # codespell only flags words from its curated misspelling dictionary, but it is not | ||
| # language-aware. Add identifiers/terms that collide with real words here (comma-separated). | ||
| ignore-words-list = te,pevents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: Codespell Comment | ||
|
|
||
| # Posts the codespell report produced by the "Codespell" workflow back onto the | ||
| # pull request. Because it is triggered by workflow_run it runs in the base | ||
| # repository context with a writable token, so it can comment on fork PRs | ||
| # without ever checking out or executing untrusted PR code. | ||
| # | ||
| # A comment is only created when spelling issues are found; an existing report | ||
| # comment is updated in place (and flipped to "resolved" once issues are fixed). | ||
| # | ||
| # NOTE: workflow_run only triggers from workflow files on the default branch, so | ||
| # this begins working once merged to master. | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: [Codespell] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| comment: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.event == 'pull_request' | ||
| steps: | ||
| - name: Download report | ||
| uses: actions/download-artifact@v4 | ||
| continue-on-error: true | ||
| with: | ||
| name: codespell-report | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Post or update PR comment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const marker = '<!-- codespell-report -->'; | ||
| const { owner, repo } = context.repo; | ||
|
|
||
| if (!fs.existsSync('pr_number.txt')) { | ||
| core.info('No report artifact found; nothing to comment on.'); | ||
| return; | ||
| } | ||
| const issue_number = parseInt(fs.readFileSync('pr_number.txt', 'utf8').trim(), 10); | ||
| if (!Number.isInteger(issue_number)) { | ||
| core.info('Invalid PR number; skipping.'); | ||
| return; | ||
| } | ||
|
|
||
| const findings = fs.existsSync('codespell.txt') | ||
| ? fs.readFileSync('codespell.txt', 'utf8').trim() | ||
| : ''; | ||
|
|
||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner, repo, issue_number, per_page: 100, | ||
| }); | ||
| const existing = comments.find(c => c.body && c.body.includes(marker)); | ||
|
|
||
| let body; | ||
| if (!findings) { | ||
| if (!existing) return; // nothing to report and nothing to update | ||
| body = `${marker}\n:white_check_mark: **codespell** found no spelling issues.`; | ||
| } else { | ||
| body = [ | ||
| marker, | ||
| '### :abc: codespell found possible spelling issues', | ||
| '', | ||
| '```', | ||
| findings, | ||
| '```', | ||
| '', | ||
| 'If any are false positives (for example a variable name or acronym), ' | ||
| + 'add them to `ignore-words-list` in `.codespellrc`.', | ||
| ].join('\n'); | ||
| } | ||
|
|
||
| if (existing) { | ||
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); | ||
| } else { | ||
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Codespell | ||
|
|
||
| # Spell-checks pull requests with codespell. This job runs in the (untrusted) | ||
| # pull_request context, so it only produces results that need no write access: | ||
| # * inline warning annotations on the changed files, and | ||
| # * a failed check so the problem is not easy to miss. | ||
| # The PR comment is posted by the companion "Codespell Comment" workflow, which | ||
| # runs from the base repo via workflow_run and therefore has a writable token | ||
| # even for fork PRs. Configuration (skip/ignore lists) lives in .codespellrc. | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| codespell: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.x' | ||
| - name: Install codespell | ||
| run: pip install codespell==2.4.3 | ||
| - name: Run codespell | ||
| run: | | ||
| codespell > codespell.txt 2>&1 || true | ||
| cat codespell.txt | ||
| # Emit an inline warning annotation for each finding. | ||
| awk -F: 'NF>=3 { | ||
| f=$1; sub(/^\.\//,"",f); | ||
| l=$2; | ||
| msg=$0; sub(/^[^:]*:[^:]*: /,"",msg); | ||
| printf "::warning file=%s,line=%s::codespell: %s\n", f, l, msg | ||
| }' codespell.txt | ||
| - name: Save PR number | ||
| run: echo "${{ github.event.number }}" > pr_number.txt | ||
| - name: Upload report | ||
| # Consumed by the "Codespell Comment" workflow to post the PR comment. | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: codespell-report | ||
| path: | | ||
| codespell.txt | ||
| pr_number.txt | ||
| retention-days: 1 | ||
| - name: Fail if spelling issues were found | ||
| run: | | ||
| if [ -s codespell.txt ]; then | ||
| echo "codespell found spelling issues; see the annotations above and the PR comment." | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.