From beacaa27368900c3e1246725c5f4016760ad42cb Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 1 Sep 2020 21:34:11 +0100 Subject: [PATCH 1/5] Sort the options --- action.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index e900b00..40a22c7 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,10 @@ name: 'Codespell with annotations' author: 'Peter Newman' description: 'Codespell with annotations for Pull Request' inputs: + builtin: + description: 'Comma-separated list of builtin dictionaries to include' + required: false + default: '' check_filenames: description: 'If set, check file names as well' required: false @@ -14,14 +18,6 @@ inputs: description: 'File with lines that should not be checked for spelling mistakes' required: false default: '' - skip: - description: 'Comma-separated list of files to skip (it accepts globs as well)' - required: false - default: './.git' - 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 @@ -34,6 +30,10 @@ inputs: description: 'Path to run codespell in' required: false default: '' + skip: + description: 'Comma-separated list of files to skip (it accepts globs as well)' + required: false + default: './.git' only_warn: description: 'If set, only warn, never error' required: false From 3d3e9d364cbabff45ca26bf9266e2667b6305bcc Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 1 Sep 2020 21:35:30 +0100 Subject: [PATCH 2/5] Add codespell config --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index 40a22c7..3e915f2 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: description: 'If set, check hidden files (those starting with ".") as well' required: false default: '' + config: + description: 'Path to a codespell config file' + required: false + default: '' exclude_file: description: 'File with lines that should not be checked for spelling mistakes' required: false From 325a4bf27ccf83b09e56a9e98b0c52de8c3649fe Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 1 Sep 2020 21:38:17 +0100 Subject: [PATCH 3/5] Sort the options in the entrypoint script --- entrypoint.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1afc65c..cb8d1a9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,10 @@ echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" # e.g. PIPESTATUS and pipestatus only work in bash/zsh respectively. echo "Running codespell on '${INPUT_PATH}' with the following options..." command_args="" +echo "Builtin dictionaries '${INPUT_BUILTIN}'" +if [ "x${INPUT_BUILTIN}" != "x" ]; then + command_args="${command_args} --builtin ${INPUT_BUILTIN}" +fi echo "Check filenames? '${INPUT_CHECK_FILENAMES}'" if [ -n "${INPUT_CHECK_FILENAMES}" ]; then echo "Checking filenames" @@ -24,14 +28,6 @@ echo "Exclude file '${INPUT_EXCLUDE_FILE}'" if [ "x${INPUT_EXCLUDE_FILE}" != "x" ]; then command_args="${command_args} --exclude-file ${INPUT_EXCLUDE_FILE}" fi -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}" @@ -40,6 +36,10 @@ 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 "Skipping '${INPUT_SKIP}'" +if [ "x${INPUT_SKIP}" != "x" ]; then + command_args="${command_args} --skip ${INPUT_SKIP}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` From eba76d33fb7abc2706e0e59ff65ec9c57ebf89bc Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 1 Sep 2020 21:38:34 +0100 Subject: [PATCH 4/5] Add the config option --- entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index cb8d1a9..27614da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,6 +24,10 @@ if [ -n "${INPUT_CHECK_HIDDEN}" ]; then echo "Checking hidden" command_args="${command_args} --check-hidden" fi +echo "Config '${INPUT_CONFIG}'" +if [ "x${INPUT_CONFIG}" != "x" ]; then + command_args="${command_args} --config ${INPUT_CONFIG}" +fi echo "Exclude file '${INPUT_EXCLUDE_FILE}'" if [ "x${INPUT_EXCLUDE_FILE}" != "x" ]; then command_args="${command_args} --exclude-file ${INPUT_EXCLUDE_FILE}" From c7be22a7b0b1ae5545ea86735a7a6e9706e74809 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Mon, 7 Dec 2020 20:40:35 +0000 Subject: [PATCH 5/5] Add a basic config file test --- test/test.bats | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test.bats b/test/test.bats index db7ac8f..a67b1e5 100644 --- a/test/test.bats +++ b/test/test.bats @@ -92,6 +92,13 @@ function setup() { [ "${lines[-4 - $errorCount]}" == "$errorCount" ] } +@test "Check with a non-existent config file set in INPUT_CONFIG" { + expectedExitStatus=64 + INPUT_CONFIG="./foo/bar" + run "./entrypoint.sh" + [ $status -eq $expectedExitStatus ] +} + @test "Use an exclude file" { errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXCLUDED_MISSPELLING_COUNT)) # codespell's exit status is 0, or 65 if there are errors found