Skip to content
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

Add option for multiple custom dictionaries to the action #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ COPY LICENSE \
requirements.txt \
/code/

RUN apk add --no-cache bash

RUN pip install -r /code/requirements.txt

ENTRYPOINT ["/code/entrypoint.sh"]
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,43 @@ Any warnings or errors will be annotated in the Pull Request.
uses: codespell-project/actions-codespell@master
```

## Possible use for checking a pull request
```
# GitHub Action to automate the identification of common misspellings in text files.
# https://github.com/codespell-project/actions-codespell
# https://github.com/codespell-project/codespell

name: Codespell
on:
pull_request_target:

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]

- name: Get the latest dictionary
run: |
wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt

- name: Get the latest rare dictionary
run: |
wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary_rare.txt

- uses: codespell-project/actions-codespell@master
with:
dictionary: dictionary.txt,dictionary_rare.txt
path: ${{ steps.changed-files.outputs.all_changed_files }}
```



### Parameter: check_filenames

If set, check file names for spelling mistakes as well.
Expand Down Expand Up @@ -57,6 +94,17 @@ with:
skip: foo,bar
```

### Parameter: dictionary

Comma-separated list of custom dictionaries to use.
This parameter is optional; by default `codespell` will use the builtin dictionaries.

```
uses: codespell-project/actions-codespell@master
with:
dictionary: dictionary.txt,dictionary2.txt
```

### Parameter: builtin

Comma-separated list of builtin dictionaries to use.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: 'Comma-separated list of files to skip (it accepts globs as well)'
required: false
default: './.git'
dictionary:
description: 'Comma-separated list of custom dictionary files that contains spelling corrections.'
required: false
default: ''
builtin:
description: 'Comma-separated list of builtin dictionaries to include'
required: false
Expand Down
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Copy the matcher to the host system; otherwise "add-matcher" can't find it.
cp /code/codespell-matcher.json /github/workflow/codespell-matcher.json
Expand Down Expand Up @@ -28,6 +28,13 @@ echo "Skipping '${INPUT_SKIP}'"
if [ "x${INPUT_SKIP}" != "x" ]; then
command_args="${command_args} --skip ${INPUT_SKIP}"
fi
echo "Custom dictionary '${INPUT_DICTIONARY}'"
if [ "x${INPUT_DICTIONARY}" != "x" ]; then
IFS=',' read -ra DICTIONARY <<< "${INPUT_DICTIONARY}"
for i in "${DICTIONARY[@]}"; do
command_args="${command_args} --dictionary $i"
done
fi
echo "Builtin dictionaries '${INPUT_BUILTIN}'"
if [ "x${INPUT_BUILTIN}" != "x" ]; then
command_args="${command_args} --builtin ${INPUT_BUILTIN}"
Expand Down