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 some more options to the action #14

Merged
merged 11 commits into from
Jun 15, 2020
3 changes: 3 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ jobs:
export INPUT_CHECK_FILENAMES=""
export INPUT_CHECK_HIDDEN=""
export INPUT_EXCLUDE_FILE=""
export INPUT_SKIP=""
export INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt"
export INPUT_IGNORE_WORDS_LIST=""
export INPUT_PATH="./test/testdata"
export INPUT_ONLY_WARN=""
./entrypoint.sh
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ inputs:
description: 'Comma-separated list of files to skip (it accepts globs as well)'
required: false
default: ''
builtin:
description: 'Comma-separated list of builtin dictionaries to include'
required: false
default: ''
ignore_words_file:
description: 'File with a list of words to be ignored'
required: false
default: ''
ignore_words_list:
description: 'Comma-separated list of words to be ignored'
required: false
default: ''
path:
description: 'Path to run codespell in'
required: false
Expand Down
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ echo "Skipping '${INPUT_SKIP}'"
if [ "x${INPUT_SKIP}" != "x" ]; then
command_args="${command_args} --skip ${INPUT_SKIP}"
fi
echo "Builtin dictionaries '${INPUT_BUILTIN}'"
if [ "x${INPUT_BUILTIN}" != "x" ]; then
command_args="${command_args} --builtin ${INPUT_BUILTIN}"
fi
echo "Ignore words file '${INPUT_IGNORE_WORDS_FILE}'"
if [ "x${INPUT_IGNORE_WORDS_FILE}" != "x" ]; then
command_args="${command_args} --ignore-words ${INPUT_IGNORE_WORDS_FILE}"
fi
echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'"
if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then
command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}"
fi
echo "Resulting CLI options ${command_args}"
exec 5>&1
res=`{ { codespell ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`
Expand Down
1 change: 1 addition & 0 deletions test/ignore-words-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abandonned
26 changes: 26 additions & 0 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ROOT_MISSPELLING_COUNT=5
FILENAME_MISSPELLING_COUNT=1
HIDDEN_MISSPELLING_COUNT=1
EXCLUDED_MISSPELLING_COUNT=1
BUILTIN_NAMES_MISSPELLING_COUNT=1
IGNORE_WORDS_MISSPELLING_COUNT=6
SUBFOLDER_MISSPELLING_COUNT=1
# From all files called example.txt
EXAMPLE_MISSPELLING_COUNT=5
Expand All @@ -20,6 +22,9 @@ function setup() {
export INPUT_CHECK_HIDDEN=""
export INPUT_EXCLUDE_FILE=""
export INPUT_SKIP=""
export INPUT_BUILTIN=""
export INPUT_IGNORE_WORDS_FILE=""
export INPUT_IGNORE_WORDS_LIST=""
export INPUT_PATH="./test/testdata"
export INPUT_ONLY_WARN=""
}
Expand Down Expand Up @@ -79,6 +84,27 @@ function setup() {
[ $status -eq $expectedExitStatus ]
}

@test "Use an additional builtin dictionary" {
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT + BUILTIN_NAMES_MISSPELLING_COUNT))
INPUT_BUILTIN="clear,rare,names"
run "./entrypoint.sh"
[ $status -eq $expectedExitStatus ]
}

@test "Use an ignore words file" {
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - IGNORE_WORDS_MISSPELLING_COUNT))
INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt"
run "./entrypoint.sh"
[ $status -eq $expectedExitStatus ]
}

@test "Use an ignore words list" {
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - IGNORE_WORDS_MISSPELLING_COUNT))
INPUT_IGNORE_WORDS_LIST="abandonned"
run "./entrypoint.sh"
[ $status -eq $expectedExitStatus ]
}

@test "Custom path" {
expectedExitStatus=$((SUBFOLDER_MISSPELLING_COUNT))
INPUT_PATH="./test/testdata/subfolder"
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/example:2.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
It's ackward when you make a spelling mistake.
It's ackward when you make a spelling mistake. My name is Tim.