From 2eff89324a595d796a581851e57d99f011f18e77 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 5 Jun 2020 19:09:58 +0100 Subject: [PATCH 1/9] Update the docs with the correct repo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f0de7e8..b3740aa 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Any warnings or errors will be annotated in the Pull Request. ## Usage ``` -uses: peternewman/actions-codespell@master +uses: codespell-project/actions-codespell@master ``` ### Parameter: path @@ -17,7 +17,7 @@ This can be useful if your project has code you don't want to spell check for so This parameter is optional; by default `codespell` will run on your whole repository. ``` -uses: peternewman/actions-codespell@master +uses: codespell-project/actions-codespell@master with: path: src ``` @@ -31,7 +31,7 @@ All errors and warnings are annotated in Pull Requests, but it will act like eve This parameter is optional; setting this to any value will enable it. ``` -uses: peternewman/actions-codespell@master +uses: codespell-project/actions-codespell@master with: only_warn: 1 ``` From 31e217abf1e2056f8ae24fd00ce979cc297b69d5 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:04:09 +0100 Subject: [PATCH 2/9] Document some more parameters --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index b3740aa..86ec47a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,54 @@ Any warnings or errors will be annotated in the Pull Request. uses: codespell-project/actions-codespell@master ``` +### Parameter: check_filenames + +If set, check file names for spelling mistakes as well. + +This parameter is optional; by default `codespell` will only check the file contents. + +``` +uses: codespell-project/actions-codespell@master +with: + check_filenames: true +``` + +### Parameter: check_hidden + +If set, check hidden files (those starting with ".") for spelling mistakes as well. + +This parameter is optional; by default `codespell` will not check hidden files. + +``` +uses: codespell-project/actions-codespell@master +with: + check_hidden: true +``` + +### Parameter: exclude_file + +File with lines that should not be checked for spelling mistakes. + +This parameter is optional; by default `codespell` will check all lines. + +``` +uses: codespell-project/actions-codespell@master +with: + exclude_file: src/foo +``` + +### Parameter: skip + +Comma-separated list of files to skip (it accepts globs as well). + +This parameter is optional; by default `codespell` won't skip any files. + +``` +uses: codespell-project/actions-codespell@master +with: + skip: foo,bar +``` + ### Parameter: path Indicates the path to run `codespell` in. From ba475bf46ec001f5abb7fae873aa438548a23fae Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:05:34 +0100 Subject: [PATCH 3/9] Clarify the exclude_file input option behaviour --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e65adf0..dad0d7c 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,7 @@ inputs: requred: false default: '' exclude_file: - description: 'FILE with lines that should not be changed' + description: 'File with lines that should not be checked for spelling mistakes' requred: false default: '' skip: From a8f562b04792b39c6c14afea09145c9ec7151fae Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:12:30 +0100 Subject: [PATCH 4/9] Codespell our action --- .github/workflows/testing.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d1297d1..cf8438d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 @@ -41,12 +41,22 @@ jobs: name: Test run action runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: ./ with: path: test/testdata only_warn: 1 + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + with: + check_filenames: true + check_hidden: true + diagnose_bats: name: Diagnose bats runs-on: ubuntu-latest From 3d7936c5bd39df83b45cf30deb9dcc72b9e8ddb2 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:18:46 +0100 Subject: [PATCH 5/9] Skip some test folders --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index cf8438d..c811e55 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -56,6 +56,8 @@ jobs: with: check_filenames: true check_hidden: true + # When using this Action in other repos, the --skip option below can be removed + skip: ./.git/,./codespell-problem-matcher/test/,./test/ diagnose_bats: name: Diagnose bats From 0b02c63f023fc13b13be495ea150b5d10684f462 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:19:49 +0100 Subject: [PATCH 6/9] Try fixing our skip config --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c811e55..422339a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -57,7 +57,7 @@ jobs: check_filenames: true check_hidden: true # When using this Action in other repos, the --skip option below can be removed - skip: ./.git/,./codespell-problem-matcher/test/,./test/ + skip: ./.git,./codespell-problem-matcher/test,./test diagnose_bats: name: Diagnose bats From 08fe393e92a4210eef4e9badbdf3eadf2e58fb02 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 6 Jun 2020 02:24:40 +0100 Subject: [PATCH 7/9] Fix the config typos codespell found --- action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index e65adf0..16315cd 100644 --- a/action.yml +++ b/action.yml @@ -4,27 +4,27 @@ description: 'Codespell with annotations for Pull Request' inputs: check_filenames: description: 'If set, check file names as well' - requred: false + required: false default: '' check_hidden: description: 'If set, check hidden files (those starting with ".") as well' - requred: false + required: false default: '' exclude_file: description: 'FILE with lines that should not be changed' - requred: false + required: false default: '' skip: description: 'Comma-separated list of files to skip (it accepts globs as well)' - requred: false + required: false default: '' path: description: 'Path to run codespell in' - requred: false + required: false default: '' only_warn: description: 'If set, only warn, never error' - requred: false + required: false default: '' runs: using: 'docker' From da31b11da4307a916a8cce8e46fe57052e919cff Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Mon, 15 Jun 2020 15:17:35 +0100 Subject: [PATCH 8/9] Add some more options to the action (#14) * Add some more options to the action * Add the options to the action script * Add the ignore words tests * Create ignore-words-file.txt * More work on the tests * Add some missing descriptions * Diagnose our latest bats test failure * Correct the IGNORE_WORDS_MISSPELLING_COUNT in the tests * Add a test for a builtin dictionary * Add a names typo * Fix the test counts --- .github/workflows/testing.yml | 3 +++ action.yml | 12 ++++++++++++ entrypoint.sh | 12 ++++++++++++ test/ignore-words-file.txt | 1 + test/test.bats | 26 ++++++++++++++++++++++++++ test/testdata/example:2.txt | 2 +- 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test/ignore-words-file.txt 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. From f53408792b98a46c92075dfc0112858bc97be05d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 18 Aug 2020 15:21:14 +0100 Subject: [PATCH 9/9] Skip .git by default given we're using Git as our VCS (#18) --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2168fb0..e900b00 100644 --- a/action.yml +++ b/action.yml @@ -17,7 +17,7 @@ inputs: skip: description: 'Comma-separated list of files to skip (it accepts globs as well)' required: false - default: '' + default: './.git' builtin: description: 'Comma-separated list of builtin dictionaries to include' required: false