Skip to content

Commit

Permalink
Add check-spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Feb 14, 2022
1 parent d919aea commit 28ffb63
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/actions/spelling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# check-spelling/check-spelling configuration

File | Purpose | Format | Info
-|-|-|-
[dictionary.txt](dictionary.txt) | Replacement dictionary (creating this file will override the default dictionary) | one word per line | [dictionary](https://github.com/check-spelling/check-spelling/wiki/Configuration#dictionary)
[allow.txt](allow.txt) | Add words to the dictionary | one word per line (only letters and `'`s allowed) | [allow](https://github.com/check-spelling/check-spelling/wiki/Configuration#allow)
[reject.txt](reject.txt) | Remove words from the dictionary (after allow) | grep pattern matching whole dictionary words | [reject](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-reject)
[excludes.txt](excludes.txt) | Files to ignore entirely | perl regular expression | [excludes](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-excludes)
[only.txt](only.txt) | Only check matching files (applied after excludes) | perl regular expression | [only](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-only)
[patterns.txt](patterns.txt) | Patterns to ignore from checked lines | perl regular expression (order matters, first match wins) | [patterns](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-patterns)
[expect.txt](expect.txt) | Expected words that aren't in the dictionary | one word per line (sorted, alphabetically) | [expect](https://github.com/check-spelling/check-spelling/wiki/Configuration#expect)
[advice.md](advice.md) | Supplement for GitHub comment when unrecognized words are found | GitHub Markdown | [advice](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice)

Note: you can replace any of these files with a directory by the same name (minus the suffix)
and then include multiple files inside that directory (with that suffix) to merge multiple files together.
25 changes: 25 additions & 0 deletions .github/actions/spelling/advice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice --> <!-- markdownlint-disable MD033 MD041 -->
<details><summary>If the flagged items do not appear to be text</summary>

If items relate to a ...
* well-formed pattern.

If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it,
try adding it to the `patterns.txt` file.

Patterns are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

* binary file.

Please add a file path to the `excludes.txt` file matching the containing file.

File paths are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files.

`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
../tree/HEAD/README.md) (on whichever branch you're using).

</details>
Empty file.
40 changes: 40 additions & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
(?:^|/)(?i)COPYRIGHT
(?:^|/)(?i)LICEN[CS]E
(?:^|/)go\.sum$
(?:^|/)package(?:-lock|)\.json$
(?:^|/)vendor/
ignore$
\.ai$
\.avi$
\.bmp$
\.bz2$
\.crt$
\.DS_Store$
\.eot$
\.gif$
\.gitattributes$
\.graffle$
\.gz$
\.icns$
\.ico$
\.jar$
\.jpe?g$
\.key$
\.lock$
\.map$
\.min\..
\.mod$
\.mp[34]$
\.ocf$
\.otf$
\.pdf$
\.pem$
\.png$
\.psd$
\.svg$
\.ttf$
\.wav$
\.woff2?$
\.zip$
^\.github/
138 changes: 138 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
adhoc
argc
args
argv
asprintf
bindir
BUFSIZ
buildroot
CFLAGS
changelog
cmds
colorizing
compat
compdef
ctype
datastructures
decref
defattr
DESTDIR
DISTFILES
endif
endptr
errno
esac
estrtol
extendedglob
falconindy
fclose
fileno
fopen
fprintf
fread
fstat
gcc
getopt
gmail
grep
horky
http
ifdef
ifndef
isalnum
isatty
itr
jansson
Jiri
journalctl
jshon
JSHONVER
json
jsonp
jsonpipe
jval
keenerd
kkeen
kmkeen
LDLIBS
libjansson
loadf
lseek
malloc
MANFILE
MAPEMPTY
MAPNEXT
MAPPEEK
MAPPOP
MAPPUSH
mapstack
mapstackpointer
maxargs
mdoc
memcpy
mflags
mingw
mkdir
mktemp
newalloc
nonstring
nosplit
nserted
optarg
optchar
optind
optreset
OSX
pbpst
perl
PKGBUILD
pkgdesc
pkgdir
pkgname
pkgrel
pkgver
printf
PSQVCI
qsort
realloc
setopt
sizeof
smp
solaris
src
srcdir
sread
ssize
STACKDEPTH
stackpointer
stdarg
stderr
stdin
stdio
stdlib
stdout
strcmp
strdup
strerror
strlen
strncmp
strtod
strtol
sys
tlkupaj
tmp
tmppath
todo
typedef
typeof
uint
unescape
unistd
upee
url
usr
vsnprintf
YYYYMMDD
zsh
ZSHCOMP
ZSHSRC
15 changes: 15 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns

md5sums=\('[0-9a-f]+'\)

# flags
\s-[a-z]\([a-z ]{2,}\) (?:\w+ |)->

# Compiler flags
[\t "'`=(]-[Wl]

# tar arguments
\b(?:\\n|)tar(?:\s+-[a-zA-Z]+|\s[a-z]+)+

# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b
7 changes: 7 additions & 0 deletions .github/actions/spelling/reject.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
^attache$
benefitting
occurence
Sorce
^[Ss]pae
^untill
^wether
94 changes: 94 additions & 0 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Spell checking
on:
push:
branches: ["**"]
tags-ignore: ["**"]
pull_request_target:
issue_comment:
types: [created]

jobs:
spelling:
name: Spell checking
permissions:
contents: read
pull-requests: read
outputs:
internal_state_directory: ${{ steps.spelling.outputs.internal_state_directory }}
result_code: ${{ steps.spelling.outputs.result_code }}
runs-on: ubuntu-latest
if: "contains(github.event_name, 'pull_request') || github.event_name == 'push'"
concurrency:
group: spelling-${{ github.event.pull_request.number || github.ref }}
# note: If you use only_check_changed_files, you do not want cancel-in-progress
cancel-in-progress: true
steps:
- name: checkout
uses: actions/checkout@v2
- name: checkout-merge
if: "contains(github.event_name, 'pull_request')"
uses: check-spelling/[email protected]
- name: check-spelling
if: env.MERGE_FAILED != '1'
id: spelling
uses: check-spelling/check-spelling@prerelease
with:
experimental_apply_changes_via_bot: 1
suppress_push_for_open_pull_request: 1
post_comment: 0
- name: store-comment
if: (failure() || env.result_code) && steps.spelling.outputs.internal_state_directory
uses: actions/upload-artifact@v2
with:
retention-days: 1
name: "check-spelling-comment-${{ github.run_id }}"
path: |
${{ steps.spelling.outputs.internal_state_directory }}
comment:
name: Comment
runs-on: ubuntu-latest
needs: spelling
permissions:
contents: write
pull-requests: write
if: always() && needs.spelling.result == 'failure' && needs.spelling.outputs.internal_state_directory
steps:
- name: checkout
uses: actions/checkout@v2
- name: set up
run: |
mkdir /tmp/data
- name: retrieve-comment
uses: actions/download-artifact@v2
with:
name: "check-spelling-comment-${{ github.run_id }}"
path: /tmp/data
- name: comment
uses: check-spelling/check-spelling@prerelease
with:
experimental_apply_changes_via_bot: 1
custom_task: comment
internal_state_directory: /tmp/data

update:
name: Update PR
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: ${{
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@check-spelling-bot apply')
}}
concurrency:
group: spelling-update-${{ github.event.issue.number }}
cancel-in-progress: false
steps:
- name: checkout
uses: actions/checkout@v2
- name: check-spelling
uses: check-spelling/check-spelling@prerelease
with:
experimental_apply_changes_via_bot: 1

1 comment on commit 28ffb63

@github-actions
Copy link

@github-actions github-actions bot commented on 28ffb63 Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the action log for details.

Unrecognized words (2)

orginal
seperated

Available dictionaries could cover words not in the dictionary

This includes both unexpected words (2) and expected items (138) from .github/actions/spelling/expect.txt

cspell:cpp/cpp.txt (104293) covers 53 of them
cspell:scala/scala.txt (2752) covers 6 of them
cspell:golang/go.txt (7745) covers 6 of them
cspell:filetypes/filetypes.txt (337) covers 6 of them
cspell:django/django.txt (2342) covers 5 of them

Consider adding them using (in .github/workflows/spelling.yml):

      with:
        extra_dictionaries:
          cspell:cpp/cpp.txt
          cspell:scala/scala.txt
          cspell:golang/go.txt
          cspell:filetypes/filetypes.txt
          cspell:django/django.txt

To stop checking additional dictionaries, add:

      with:
        check_extra_dictionaries: ''
To accept these unrecognized words as correct, run the following commands

... in a clone of the [email protected]:jsoref/jshon.git repository
on the spell-check branch:

update_files() {
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
-H "Content-Type: application/json" \
"https://api.github.com/repos/jsoref/jshon/comments/66615154" > "$comment_json"
comment_body=$(mktemp)
jq -r ".body // empty" "$comment_json" > $comment_body
rm $comment_json

patch_add=$(perl -e '$/=undef; $_=<>; if (m{Unrecognized words[^<]*</summary>\n*```\n*([^<]*)```\n*</details>$}m) { print "$1" } elsif (m{Unrecognized words[^<]*\n\n((?:\w.*\n)+)\n}m) { print "$1" };' < "$comment_body")

update_files
rm $comment_body
git add -u
If the flagged items do not appear to be text

If items relate to a ...

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

  • binary file.

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

Please sign in to comment.