Skip to content

Commit

Permalink
📝 (README.md): improve grammar and clarity in documentation
Browse files Browse the repository at this point in the history
✨ (action.yml, entrypoint.sh): add support for custom configuration file input

Enhance the README.md for better readability and understanding by fixing grammatical errors and improving sentence structure. Add support for a custom configuration file input in action.yml and entrypoint.sh to allow users to specify a custom configuration file for spell checking, increasing the flexibility and usability of the GitHub Action.
  • Loading branch information
MrHinsh committed Sep 11, 2024
1 parent a5c8ea7 commit 0f12623
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 31 deletions.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ Repository is created for the support of any languages that you need for spell c

## Features

- Customizable configuration of spell checking using [Aspell](http://aspell.net) and [Hunspell](http://hunspell.github.io) due to [docs](https://facelessuser.github.io/pyspelling/configuration/)
- Support any formats of file to check
- Customizable configuration of spell checking using [Aspell](http://aspell.net) and [Hunspell](http://hunspell.github.io) due to [docs](https://facelessuser.github.io/pyspelling/configuration/)
- Support for any formats of file to check
- Supports any languages from the list for [Aspell](https://ftp.gnu.org/gnu/aspell/dict/0index.html) and any languages for [Hunspell](https://en.wikipedia.org/wiki/Hunspell).

## Configuration

1. First you have to add a configuration for the spelling checker
2. Create a file named: `.spellcheck.yml` or `.spellcheck.yaml`, do note if both files exist the prior will have precedence. Do note the recommendation is _hidden_ files since these configuration files are not first rate citizens of your repository
3. Paste the contents of the outlined example, which is a configuration for Markdown, useful for your README file
1. First, you have to add a configuration for the spelling checker.
2. Create a file named: `.spellcheck.yml` or `.spellcheck.yaml`. Note that if both files exist, `.spellcheck.yml` will take precedence. Hidden files are recommended for configuration since these files are not primary content of your repository.
3. Paste the contents of the outlined example, which is a configuration for Markdown, useful for your README file.

Do note that this action requires the contents of the repository, so it is recommended used with [the Checkout action][actioncheckout].
Do note that this action requires the contents of the repository, so it is recommended to use it with [the Checkout action][actioncheckout].

You have to define this part in your workflow, since it not a part of the action itself.
You have to define this part in your workflow, as it is not a part of the action itself.

Example:
### Example Workflow

```yaml
# This is workflow for spell checking using PySpelling lib (https://pypi.org/project/pyspelling/)
# This is a workflow for spell checking using PySpelling lib (https://pypi.org/project/pyspelling/)
name: Spellcheck
# Controls when the action will run.
on:
Expand All @@ -46,15 +46,17 @@ jobs:
- uses: actions/checkout@v2
- uses: igsekor/pyspelling-any@v0.0.2
name: Spellcheck
with:
configFile: '.my-custom-config.yml' # Optional field
```
Note the step: `- uses: actions/checkout@master`
This file must live in a the `.github/workflows/` directory.
For example, it could be `.github/workflows/spellcheck.yml`
### Optional Field
## Checking For Bad Spelling
The action supports an optional `configFile` input parameter to specify a custom configuration file name. By default, it looks for `.spellcheck.yml` or `.spellcheck.yaml` files. You can override this default by providing a `configFile` input in the workflow as shown above.

The GitHub Action helps you make sure _most_ spelling errors do not make it into your repository. You can however check your spelling prior to committing and pushing to your repository.
### Checking For Bad Spelling

The GitHub Action helps you make sure _most_ spelling errors do not make it into your repository. You can, however, check your spelling prior to committing and pushing to your repository.

This simply uses the contents of our spelling toolchain:

Expand All @@ -67,14 +69,14 @@ Misspelled words:
!!!Spelling check failed!!!
```

And at some point we get:
And at some point, you get:

```bash
$ pyspelling -c .spellcheck.yml
Spelling check passed :)
```

Now we should be good to go.
Now you should be good to go.

Do note you could also use the `entrypoint.sh`, which is the script used in the Docker image.

Expand All @@ -97,4 +99,5 @@ The original author of this GitHub Action is Igor Korovchenko (@igsekor)

## Copyright and License

This repository is licensed under the MIT license.
This repository is licensed under the MIT license.

11 changes: 9 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: 'GitHub Spellcheck'
description: 'A Github Action that spell checks for any languages by aspell / hunspell'
description: 'A GitHub Action that spell checks for any languages by aspell / hunspell'
author: Igor Korovchenko
branding:
color: green
icon: type
inputs:
configFile:
description: 'The configuration file to use for spellchecking'
required: true
default: '.pyspelling.yml'
runs:
using: docker
image: 'docker://igsekor/pyspelling-any'
image: 'docker://igsekor/pyspelling-any'
args:
- ${{ inputs.configFile }}
28 changes: 16 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/sh -l

SPELLCHECK_CONFIG_FILE=''

if [ -f "./.spellcheck.yml" ]; then
SPELLCHECK_CONFIG_FILE=".spellcheck.yml"
elif [ -f "./.spellcheck.yaml" ]; then
SPELLCHECK_CONFIG_FILE=".spellcheck.yaml"
elif [ -f "./spellcheck.yml" ]; then
SPELLCHECK_CONFIG_FILE="spellcheck.yml"
else
SPELLCHECK_CONFIG_FILE="spellcheck.yaml"
# Default to an empty config file if not specified
SPELLCHECK_CONFIG_FILE="${INPUT_CONFIGFILE}"

# If no config file is provided, fallback to predefined file names
if [ -z "$SPELLCHECK_CONFIG_FILE" ]; then
if [ -f "./.spellcheck.yml" ]; then
SPELLCHECK_CONFIG_FILE=".spellcheck.yml"
elif [ -f "./.spellcheck.yaml" ]; then
SPELLCHECK_CONFIG_FILE=".spellcheck.yaml"
elif [ -f "./spellcheck.yml" ]; then
SPELLCHECK_CONFIG_FILE="spellcheck.yml"
else
SPELLCHECK_CONFIG_FILE="spellcheck.yaml"
fi
fi

echo ""
Expand All @@ -36,8 +40,8 @@ pyspelling --config $SPELLCHECK_CONFIG_FILE

EXITCODE=$?

test $EXITCODE -gt 1 && echo "\033[91Spelling check action failed, please check diagnostics\033[39m";
test $EXITCODE -gt 1 && echo "\033[91mSpelling check action failed, please check diagnostics\033[39m"

test $EXITCODE -eq 1 && echo "\033[91mFiles in repository contain spelling errors\033[39m";
test $EXITCODE -eq 1 && echo "\033[91mFiles in repository contain spelling errors\033[39m"

exit $EXITCODE

0 comments on commit 0f12623

Please sign in to comment.