Skip to content

Commit 6ae77c3

Browse files
authored
Merge branch 'master' into patch-2
2 parents 65dbe65 + c460eef commit 6ae77c3

File tree

10 files changed

+81
-26
lines changed

10 files changed

+81
-26
lines changed

.github/workflows/publish_master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: Publish master image
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- name: Build
1818
run: |
1919
GITHUB_REPOSITORY_LC=$(echo "${GITHUB_REPOSITORY}" | tr [A-Z] [a-z])

.github/workflows/publish_stable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Publish stable image
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- name: Build
1515
run: |
1616
GITHUB_REPOSITORY_LC=$(echo "${GITHUB_REPOSITORY}" | tr [A-Z] [a-z])

.github/workflows/testing.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2323

2424
- name: Set up Python
25-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
2626
with:
2727
python-version: '3.10'
2828

@@ -48,7 +48,7 @@ jobs:
4848
name: Test run action
4949
runs-on: ubuntu-latest
5050
steps:
51-
- uses: actions/checkout@v4
51+
- uses: actions/checkout@v5
5252
- uses: ./
5353
with:
5454
path: test/testdata
@@ -58,7 +58,7 @@ jobs:
5858
name: Check for spelling errors
5959
runs-on: ubuntu-latest
6060
steps:
61-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v5
6262
- uses: ./
6363
with:
6464
check_filenames: true
@@ -86,9 +86,9 @@ jobs:
8686
include:
8787
- codespell_pip_version: 'git+https://github.com/codespell-project/codespell.git'
8888
steps:
89-
- uses: actions/checkout@v4
89+
- uses: actions/checkout@v5
9090
- name: Set up Python
91-
uses: actions/setup-python@v5
91+
uses: actions/setup-python@v6
9292
- run: pip3 --quiet --quiet install ${{ matrix.codespell_pip_version }}
9393
- run: |
9494
# Simulate the Dockerfile COPY command

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/codespell-project/codespell
3-
rev: v2.3.0
3+
rev: v2.4.0
44
hooks:
55
- id: codespell
66
args: [--ignore-words-list, "abandonned,ackward,bu"]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COPY LICENSE \
77
requirements.txt \
88
/code/
99

10-
RUN pip install -r /code/requirements.txt
10+
RUN pip install --no-cache-dir -r /code/requirements.txt
1111

1212
ENTRYPOINT ["/code/entrypoint.sh"]
1313
CMD []

action.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: 'Codespell with annotations'
22
author: 'Peter Newman'
33
description: 'Codespell with annotations for Pull Request'
44
inputs:
5+
builtin:
6+
description: 'Comma-separated list of builtin dictionaries to include'
7+
required: false
8+
default: ''
59
check_filenames:
610
description: 'If set, check file names as well'
711
required: false
@@ -10,16 +14,12 @@ inputs:
1014
description: 'If set, check hidden files (those starting with ".") as well'
1115
required: false
1216
default: ''
13-
exclude_file:
14-
description: 'File with lines that should not be checked for spelling mistakes'
17+
config:
18+
description: 'Path to a codespell config file'
1519
required: false
1620
default: ''
17-
skip:
18-
description: 'Comma-separated list of files to skip (it accepts globs as well)'
19-
required: false
20-
default: './.git'
21-
builtin:
22-
description: 'Comma-separated list of builtin dictionaries to include'
21+
exclude_file:
22+
description: 'File with lines that should not be checked for spelling mistakes'
2323
required: false
2424
default: ''
2525
ignore_words_file:
@@ -38,6 +38,10 @@ inputs:
3838
description: 'Path to run codespell in'
3939
required: false
4040
default: ''
41+
skip:
42+
description: 'Comma-separated list of files to skip (it accepts globs as well)'
43+
required: false
44+
default: './.git'
4145
only_warn:
4246
description: 'If set, only warn, never error'
4347
required: false

entrypoint.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json"
1010
# e.g. PIPESTATUS and pipestatus only work in bash/zsh respectively.
1111
echo "Running codespell on '${INPUT_PATH}' with the following options..."
1212
command_args=""
13+
echo "Builtin dictionaries '${INPUT_BUILTIN}'"
14+
if [ "x${INPUT_BUILTIN}" != "x" ]; then
15+
command_args="${command_args} --builtin ${INPUT_BUILTIN}"
16+
fi
1317
echo "Check filenames? '${INPUT_CHECK_FILENAMES}'"
1418
if [ -n "${INPUT_CHECK_FILENAMES}" ]; then
1519
echo "Checking filenames"
@@ -20,18 +24,14 @@ if [ -n "${INPUT_CHECK_HIDDEN}" ]; then
2024
echo "Checking hidden"
2125
command_args="${command_args} --check-hidden"
2226
fi
27+
echo "Config '${INPUT_CONFIG}'"
28+
if [ "x${INPUT_CONFIG}" != "x" ]; then
29+
command_args="${command_args} --config ${INPUT_CONFIG}"
30+
fi
2331
echo "Exclude file '${INPUT_EXCLUDE_FILE}'"
2432
if [ "x${INPUT_EXCLUDE_FILE}" != "x" ]; then
2533
command_args="${command_args} --exclude-file ${INPUT_EXCLUDE_FILE}"
2634
fi
27-
echo "Skipping '${INPUT_SKIP}'"
28-
if [ "x${INPUT_SKIP}" != "x" ]; then
29-
command_args="${command_args} --skip ${INPUT_SKIP}"
30-
fi
31-
echo "Builtin dictionaries '${INPUT_BUILTIN}'"
32-
if [ "x${INPUT_BUILTIN}" != "x" ]; then
33-
command_args="${command_args} --builtin ${INPUT_BUILTIN}"
34-
fi
3535
echo "Ignore words file '${INPUT_IGNORE_WORDS_FILE}'"
3636
if [ "x${INPUT_IGNORE_WORDS_FILE}" != "x" ]; then
3737
command_args="${command_args} --ignore-words ${INPUT_IGNORE_WORDS_FILE}"
@@ -44,6 +44,10 @@ echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'"
4444
if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then
4545
command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}"
4646
fi
47+
echo "Skipping '${INPUT_SKIP}'"
48+
if [ "x${INPUT_SKIP}" != "x" ]; then
49+
command_args="${command_args} --skip ${INPUT_SKIP}"
50+
fi
4751
echo "Resulting CLI options ${command_args}"
4852
exec 5>&1
4953
res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`

test/test.bats

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function setup() {
3939
export INPUT_EXCLUDE_FILE=""
4040
export INPUT_SKIP=""
4141
export INPUT_BUILTIN=""
42+
export INPUT_CONFIG=""
4243
export INPUT_IGNORE_WORDS_FILE=""
4344
export INPUT_IGNORE_WORDS_LIST=""
4445
export INPUT_URI_IGNORE_WORDS_LIST=""
@@ -94,6 +95,50 @@ function setup() {
9495
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
9596
}
9697

98+
@test "Pass an ill-formed file to INPUT_CONFIG" {
99+
# codespell's exit status is 78 for a configparser.Error exception
100+
expectedExitStatus=78
101+
INPUT_CONFIG="./test/testdata/.badcfg"
102+
run "./entrypoint.sh"
103+
[ $status -eq $expectedExitStatus ]
104+
}
105+
106+
@test "Pass a non-existing file to INPUT_CONFIG" {
107+
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT))
108+
# codespell's exit status is 0, or 65 if there are errors found
109+
if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi
110+
INPUT_CONFIG="./foo"
111+
run "./entrypoint.sh"
112+
[ $status -eq $expectedExitStatus ]
113+
114+
# Check output
115+
[ "${lines[0]}" == "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" ]
116+
outputRegex="^Running codespell on '${INPUT_PATH}'"
117+
[[ "${lines[1]}" =~ $outputRegex ]]
118+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
119+
[ "${lines[-3]}" == "Codespell found one or more problems" ]
120+
[ "${lines[-2]}" == "::remove-matcher owner=codespell-matcher-default::" ]
121+
[ "${lines[-1]}" == "::remove-matcher owner=codespell-matcher-specified::" ]
122+
}
123+
124+
@test "Pass a valid file to INPUT_CONFIG" {
125+
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT))
126+
# codespell's exit status is 0, or 65 if there are errors found
127+
if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi
128+
INPUT_CONFIG="./test/testdata/.goodcfg"
129+
run "./entrypoint.sh"
130+
[ $status -eq $expectedExitStatus ]
131+
132+
# Check output
133+
[ "${lines[0]}" == "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" ]
134+
outputRegex="^Running codespell on '${INPUT_PATH}'"
135+
[[ "${lines[1]}" =~ $outputRegex ]]
136+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
137+
[ "${lines[-3]}" == "Codespell found one or more problems" ]
138+
[ "${lines[-2]}" == "::remove-matcher owner=codespell-matcher-default::" ]
139+
[ "${lines[-1]}" == "::remove-matcher owner=codespell-matcher-specified::" ]
140+
}
141+
97142
@test "Use an exclude file" {
98143
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXCLUDED_MISSPELLING_COUNT))
99144
# codespell's exit status is 0, or 65 if there are errors found

test/testdata/.badcfg

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

test/testdata/.goodcfg

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

0 commit comments

Comments
 (0)