diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 422339a..3e7bbe9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -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 diff --git a/action.yml b/action.yml index 6355bc1..2168fb0 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 53182e3..1afc65c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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` diff --git a/test/ignore-words-file.txt b/test/ignore-words-file.txt new file mode 100644 index 0000000..3eda6e1 --- /dev/null +++ b/test/ignore-words-file.txt @@ -0,0 +1 @@ +abandonned diff --git a/test/test.bats b/test/test.bats index a842cde..51d0a69 100644 --- a/test/test.bats +++ b/test/test.bats @@ -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 @@ -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="" } @@ -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" diff --git a/test/testdata/example:2.txt b/test/testdata/example:2.txt index 50a0985..d5f415f 100644 --- a/test/testdata/example:2.txt +++ b/test/testdata/example:2.txt @@ -1 +1 @@ -It's ackward when you make a spelling mistake. +It's ackward when you make a spelling mistake. My name is Tim.