Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ jobs:
path: test/testdata
only_warn: 1

test_write:
name: Test that writes work
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ./
with:
path: test/testdata
only_warn: 1
write_changes: true
- name: Check git status
run: |
if git diff --quiet; then echo "For some reason, no write was performed. This appears to be a bug." && exit 1; else exit 0; fi

codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,15 @@ uses: codespell-project/actions-codespell@v2
with:
only_warn: 1
```

### Parameter: write_changes

Write changes. Note that this will not commit or push; you will need to handle that in the workflow.

This parameter is optional; by default `codespell` will run in "dry-run" mode.

```yml
uses: codespell-project/actions-codespell@v2
with:
write_changes: 1
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ inputs:
description: 'If set, only warn, never error'
required: false
default: ''
write_changes:
description: 'Write fixes automatically'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if [ -n "${INPUT_CHECK_HIDDEN}" ]; then
echo "Checking hidden"
command_args="${command_args} --check-hidden"
fi
echo "Write changes? '${INPUT_WRITE_CHANGES}'"
if [ -n "${INPUT_WRITE_CHANGES}" ]; then
echo "Writing changes"
fi
echo "Config '${INPUT_CONFIG}'"
if [ "x${INPUT_CONFIG}" != "x" ]; then
command_args="${command_args} --config ${INPUT_CONFIG}"
Expand Down Expand Up @@ -54,7 +58,13 @@ res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5;
if [ "$res" = "0" ]; then
echo "Codespell found no problems"
else
echo "Codespell found one or more problems"
if [ -n "${INPUT_WRITE_CHANGES}" ]; then
echo "Codespell found one or more problems to be fixed"
command_args="${command_args} --write-changes"
codespell --count ${command_args} ${INPUT_PATH} &> /dev/null
else
echo "Codespell found one or more problems"
fi
fi

# Remove the matchers, so no other jobs hit them.
Expand Down