Skip to content

Commit

Permalink
Changes to the cspell action to account for running in a different di…
Browse files Browse the repository at this point in the history
…rectory, updating the config file as well
  • Loading branch information
Skptak committed Sep 5, 2023
1 parent 184f886 commit 40efc28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
20 changes: 13 additions & 7 deletions spellings/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
shell: bash
run: |
# ${{ env.stepName }}
echo -e "::group::Install Dependencies"
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
Expand All @@ -39,16 +39,20 @@ runs:
sudo npm install -g cspell
echo -e "::endgroup::"
# Add the current directory to PATH
# Add the Github Action Path to PATH
export PATH="$GITHUB_ACTION_PATH:$PATH"
# cp has an error code if it's asked to copy to the same file
# Wrap it in a set +e in case the input path is the working directory
# 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 $GITHUB_ACTION_PATH/cspell.config.yaml ${{ inputs.path }}
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 }}"
Expand Down Expand Up @@ -99,10 +103,12 @@ runs:
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
echo -e 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 }}"
# 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=$?
Expand Down
16 changes: 10 additions & 6 deletions spellings/cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ $schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell
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:
- allowCompoundWords: true
caseSensitive: false
- caseSensitive: false
enabled: true
languageId: c
locale: "*"
# Could split this up? And do a dictionary for each repo?
# But feel like if this isn't super slow
# That having just one single dictionary might be nicer?

# 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:
- '.cSpellWords.txt'
- 'dependency'
- 'docs'
- 'ThirdParty'
Expand Down

0 comments on commit 40efc28

Please sign in to comment.