Skip to content

Commit da31b11

Browse files
authored
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
1 parent 5cce0c1 commit da31b11

6 files changed

Lines changed: 55 additions & 1 deletion

File tree

.github/workflows/testing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ jobs:
7171
export INPUT_CHECK_FILENAMES=""
7272
export INPUT_CHECK_HIDDEN=""
7373
export INPUT_EXCLUDE_FILE=""
74+
export INPUT_SKIP=""
75+
export INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt"
76+
export INPUT_IGNORE_WORDS_LIST=""
7477
export INPUT_PATH="./test/testdata"
7578
export INPUT_ONLY_WARN=""
7679
./entrypoint.sh

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ inputs:
1818
description: 'Comma-separated list of files to skip (it accepts globs as well)'
1919
required: false
2020
default: ''
21+
builtin:
22+
description: 'Comma-separated list of builtin dictionaries to include'
23+
required: false
24+
default: ''
25+
ignore_words_file:
26+
description: 'File with a list of words to be ignored'
27+
required: false
28+
default: ''
29+
ignore_words_list:
30+
description: 'Comma-separated list of words to be ignored'
31+
required: false
32+
default: ''
2133
path:
2234
description: 'Path to run codespell in'
2335
required: false

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ echo "Skipping '${INPUT_SKIP}'"
2828
if [ "x${INPUT_SKIP}" != "x" ]; then
2929
command_args="${command_args} --skip ${INPUT_SKIP}"
3030
fi
31+
echo "Builtin dictionaries '${INPUT_BUILTIN}'"
32+
if [ "x${INPUT_BUILTIN}" != "x" ]; then
33+
command_args="${command_args} --builtin ${INPUT_BUILTIN}"
34+
fi
35+
echo "Ignore words file '${INPUT_IGNORE_WORDS_FILE}'"
36+
if [ "x${INPUT_IGNORE_WORDS_FILE}" != "x" ]; then
37+
command_args="${command_args} --ignore-words ${INPUT_IGNORE_WORDS_FILE}"
38+
fi
39+
echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'"
40+
if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then
41+
command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}"
42+
fi
3143
echo "Resulting CLI options ${command_args}"
3244
exec 5>&1
3345
res=`{ { codespell ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`

test/ignore-words-file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abandonned

test/test.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ROOT_MISSPELLING_COUNT=5
77
FILENAME_MISSPELLING_COUNT=1
88
HIDDEN_MISSPELLING_COUNT=1
99
EXCLUDED_MISSPELLING_COUNT=1
10+
BUILTIN_NAMES_MISSPELLING_COUNT=1
11+
IGNORE_WORDS_MISSPELLING_COUNT=6
1012
SUBFOLDER_MISSPELLING_COUNT=1
1113
# From all files called example.txt
1214
EXAMPLE_MISSPELLING_COUNT=5
@@ -20,6 +22,9 @@ function setup() {
2022
export INPUT_CHECK_HIDDEN=""
2123
export INPUT_EXCLUDE_FILE=""
2224
export INPUT_SKIP=""
25+
export INPUT_BUILTIN=""
26+
export INPUT_IGNORE_WORDS_FILE=""
27+
export INPUT_IGNORE_WORDS_LIST=""
2328
export INPUT_PATH="./test/testdata"
2429
export INPUT_ONLY_WARN=""
2530
}
@@ -79,6 +84,27 @@ function setup() {
7984
[ $status -eq $expectedExitStatus ]
8085
}
8186

87+
@test "Use an additional builtin dictionary" {
88+
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT + BUILTIN_NAMES_MISSPELLING_COUNT))
89+
INPUT_BUILTIN="clear,rare,names"
90+
run "./entrypoint.sh"
91+
[ $status -eq $expectedExitStatus ]
92+
}
93+
94+
@test "Use an ignore words file" {
95+
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - IGNORE_WORDS_MISSPELLING_COUNT))
96+
INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt"
97+
run "./entrypoint.sh"
98+
[ $status -eq $expectedExitStatus ]
99+
}
100+
101+
@test "Use an ignore words list" {
102+
expectedExitStatus=$((ROOT_MISSPELLING_COUNT + HIDDEN_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - IGNORE_WORDS_MISSPELLING_COUNT))
103+
INPUT_IGNORE_WORDS_LIST="abandonned"
104+
run "./entrypoint.sh"
105+
[ $status -eq $expectedExitStatus ]
106+
}
107+
82108
@test "Custom path" {
83109
expectedExitStatus=$((SUBFOLDER_MISSPELLING_COUNT))
84110
INPUT_PATH="./test/testdata/subfolder"

test/testdata/example:2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
It's ackward when you make a spelling mistake.
1+
It's ackward when you make a spelling mistake. My name is Tim.

0 commit comments

Comments
 (0)