generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 35
CSpell Action #75
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
CSpell Action #75
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b1831bb
Swap to cspell for spelling action
Skptak b222cf7
Merge branch 'main' into cSpellChanges
Skptak 9027c90
Merge branch 'main' into cSpellChanges
Skptak 1cb55cf
Update the spell check action to be faster, add in exclude dirs and f…
Skptak bd095e8
Update the cSpell config file
Skptak 1a8525c
Merge branch 'main' into cSpellChanges
Skptak 540db26
Merge branch 'main' into cSpellChanges
Skptak 577cee9
Remove the get files script
Skptak 94fc998
Merge branch 'main' into cSpellChanges
Skptak 184f886
Merge branch 'main' into cSpellChanges
Skptak 40efc28
Changes to the cspell action to account for running in a different di…
Skptak dc7095f
Merge branch 'main' into cSpellChanges
Skptak f7cd0a9
Merge branch 'main' into cSpellChanges
Skptak 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
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 |
|---|---|---|
| @@ -1,29 +1,123 @@ | ||
| name: 'spellings' | ||
| description: 'CI spellings check' | ||
| description: 'cSpell CI spelling check' | ||
| inputs: | ||
| path: | ||
| description: 'Path to repository folder to check spellings in.' | ||
| required: false | ||
| default: ./ | ||
| exclude-dirs: | ||
| description: "Comma separated list of directories to not spell check" | ||
| required: false | ||
| exclude-files: | ||
| description: "Comma separated list of files to not spell check" | ||
| required: false | ||
| include-extensions: | ||
| description: "Comma separated list of files to match to regex" | ||
| required: false | ||
|
|
||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install spell | ||
| run: | | ||
| sudo apt-get install spell | ||
| sudo apt-get install util-linux | ||
| shell: bash | ||
| - name: Check spelling | ||
| working-directory: ${{ inputs.path }} | ||
| run: | | ||
| PATH=$PATH:$GITHUB_ACTION_PATH/tools | ||
| for lexfile in `find ./ -name lexicon.txt` | ||
| do dir=${lexfile%/lexicon.txt} | ||
| echo $dir | ||
| find-unknown-comment-words --directory $dir | ||
| if [ $? -ne "0" ] | ||
| then | ||
| exit 1 | ||
| fi | ||
| done | ||
| shell: bash | ||
| - env: | ||
| bashPass: \033[32;1mPASSED - | ||
| bashInfo: \033[33;1mINFO - | ||
| bashFail: \033[31;1mFAILED - | ||
| bashEnd: \033[0m | ||
| stepName: Set-Up The Spell Checker | ||
| name: ${{ env.stepName }} | ||
| id: spell-checker-setup | ||
| shell: bash | ||
| run: | | ||
| # ${{ env.stepName }} | ||
| echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" | ||
|
|
||
| # Install the Dependencies we need to run the spell-checker | ||
| sudo apt-get install util-linux -y | ||
| sudo apt-get install fd-find -y | ||
| sudo apt-get install npm -y | ||
| sudo npm install -g cspell | ||
| echo -e "::endgroup::" | ||
|
|
||
| # Add the Github Action Path to PATH | ||
| export PATH="$GITHUB_ACTION_PATH:$PATH" | ||
|
|
||
| # Account for starting with an alternate path in a repository | ||
| # Do this by copying the cspell config and wordlist to the desired path | ||
| # Wrap in a set +e so Github doesn't throw an error if the file or | ||
| # directory already exists. | ||
| set +e | ||
| cp cspell.config.yaml ${{ inputs.path }} | ||
| mkdir ${{ inputs.path }}/.github | ||
| cp .github/.cSpellWords.txt ${{ inputs.path }}/.github | ||
| cd ${{ inputs.path }} | ||
| set -e | ||
|
|
||
| # Make sure we have all the commands we need. | ||
| echo -e "${{ env.bashInfo }} fdfind --version $(fdfind --version) ${{ env.bashEnd }}" | ||
| echo -e "${{ env.bashInfo }} cspell --version $(cspell --version) ${{ env.bashEnd }}" | ||
|
|
||
| # Only reach this line if no errors were hit above | ||
| echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" | ||
|
|
||
| - env: | ||
| bashPass: \033[32;1mPASSED - | ||
| bashInfo: \033[33;1mINFO - | ||
| bashFail: \033[31;1mFAILED - | ||
| bashEnd: \033[0m | ||
| stepName: Spell Checker | ||
| name: ${{ env.stepName }} | ||
| id: run-spell-checker | ||
| working-directory: ${{ inputs.path }} | ||
| shell: bash | ||
| run: | | ||
| # ${{ env.stepName }} | ||
| #echo -e "::group::${{ env.stepName }}" | ||
| export PATH="$GITHUB_ACTION_PATH:$PATH" | ||
| exitStatus=0 | ||
|
|
||
| # Parse the optional inputs | ||
| args="" | ||
|
|
||
| # fd-find uses -E to exclude a file or directory | ||
| if [ -n "${{ inputs.exclude-dirs }}" ]; then | ||
| dirs=" -E " | ||
| dirs+="${{ inputs.exclude-dirs }}" | ||
| dirs="${dirs//,/ -E }" | ||
| args+=" ${dirs}" | ||
| fi | ||
|
|
||
| # fd-find uses -E to exclude a file or directory | ||
| if [ -n "${{ inputs.exclude-files }}" ]; then | ||
| files=" -E " | ||
| files+="${{ inputs.exclude-files }}" | ||
| files="${files//,/ -E }" | ||
| args+=" ${files}" | ||
| fi | ||
|
|
||
| # fd-find uses -e to exclude a file extension | ||
| if [ -n "${{ inputs.include-file-types }}" ]; then | ||
| file_types=" -e " | ||
| file_types+="${{ inputs.include-file-types }}" | ||
| file_types="${file_types//,/ -e }" | ||
| args+=" ${file_types}" | ||
| fi | ||
|
|
||
| echo -e "${{ env.bashInfo }} Running: fdfind -e c -e h -e md -e txt -e readme ${args} --exec cspell lint --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml ${{ env.bashEnd }}" | ||
|
|
||
| # Wrap in a set +e so Github doesn't stop the spell check from running | ||
| set +e | ||
|
|
||
| # Find all relevant files, then check them for spelling mistakes | ||
| fdfind -e c -e h -e md -e txt -e readme ${args} --exec-batch \ | ||
| cspell lint --language-id C --color --show-context --show-suggestions --no-must-find-files -c cspell.config.yaml | ||
| exitStatus=$? | ||
| set -e | ||
|
|
||
| echo -e "::endgroup::" | ||
| if [ $exitStatus -eq 0 ]; then | ||
| echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" | ||
Skptak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else | ||
| echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" | ||
| fi | ||
| exit $exitStatus | ||
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,31 @@ | ||
| --- | ||
| $schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json | ||
| version: '0.2' | ||
| # Allows things like stringLength | ||
| allowCompoundWords: true | ||
|
|
||
| # Read files not to spell check from the git ignore | ||
| useGitignore: true | ||
|
|
||
| # Language settings for C | ||
| languageSettings: | ||
| - caseSensitive: false | ||
| enabled: true | ||
| languageId: c | ||
| locale: "*" | ||
|
|
||
| # Add a dictionary, and the path to the word list | ||
| dictionaryDefinitions: | ||
| - name: freertos-words | ||
| path: '.github/.cSpellWords.txt' | ||
| addWords: true | ||
|
|
||
| dictionaries: | ||
| - freertos-words | ||
|
|
||
| # Paths and files to ignore | ||
| ignorePaths: | ||
| - 'dependency' | ||
| - 'docs' | ||
| - 'ThirdParty' | ||
| - 'History.txt' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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.