Skip to content

Commit

Permalink
Add actions/spelling config
Browse files Browse the repository at this point in the history
.github/actions/spelling configuration was added for the
@check-spelling/check-spelling action.

Changelist:
- .github/actions/spelling
  - Add allow.txt with new allowed words
  - Add excludes.txt to exclude files based on common glob patterns
  - Add patterns.txt to ignore URLs, paths, configs, etc.

Additional Notes:
Spelling (minor):
An additional expect.txt file will have to be added in order to
accommodate incorrect words found in files or comments will have to be
added to those lines.
  • Loading branch information
quantum9Innovation committed Jul 20, 2021
1 parent bf8cb61 commit f079b38
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ codebase
codecov
codefactor
codeowner
CODEOWNERS
codeql
conda
config
Expand All @@ -25,6 +26,7 @@ deepsource
dirname
Django
docstring
docstrings
doi
epidemiologists
epispot
Expand All @@ -41,6 +43,7 @@ google
homepage
html
http
https
ICU
img
infecteds
Expand Down Expand Up @@ -99,6 +102,7 @@ sys
timerange
timespans
timestep
timesteps
toml
towardsdatascience
ubuntu
Expand All @@ -112,6 +116,7 @@ versionadded
vscode
Website
workflow
workflows
www
xml
yml
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore directories named `third_party`
(?:^|/)third_party/
# Ignore npm files
(?:^|/)package(?:-lock|)\.json$
# Ignore files named (yarn for Node.js) `yarn.lock`
(?:^|/)yarn\.lock$
# Ignore files or directories that case-insensitively have `LICENSE` somewhere in their path
(?:(?i)LICENSE)
# Ignore files ending in...
\.pdf$
\.png$
# Ignore Excel files (`.xsl` and `.xslx`)
\.xslx?$
# Ignore locales that aren't en / en_GB (roughly: keep en_US and drop everything else)
locales/(?!en)
locales/en_GB
# Ignore the action's configuration data
^\.github/action/spelling/
96 changes: 96 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This file contains various spellcheck patterns for @check-spelling/check-spelling
# and is used in the spellcheck workflow. See ../../workflows/spellcheck.yml for more information.

# marker to ignore all code on line
^.*/\* #no-spell-check-line \*/.*$
# marker for ignoring a comment to the end of the line
// #no-spell-check.*$

# git index header
index [0-9a-z]{7,40}\.\.[0-9a-z]{7,40}

# data urls
(['"])data:.*?\g{-1}
data:[-a-zA-Z=;:/0-9+]*,\S*

# Any `http://` or `https://` URL
https?://*

# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
(?:\[[0-9a-f]+\]\(https:/|)/github\.com/[^/]+/[^/]+(?:/[^/]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
\bgithub\.com/[^/]+/[^/]+[@#][0-9a-f]+\b
# githubusercontent
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
# gist github
/gist\.github\.com/[^/]+/[0-9a-f]+
# git.io
\bgit\.io/[0-9a-zA-Z]+
# GitHub JSON
"node_id": "[-a-zA-Z=;:/0-9+]*"
# Contributor
\[[^\]]+]\(?:https://github\.com/[^/]+\)

# bit.ly
\bbit\.ly/\w+

# gravatar
\bgravatar\.com/avatar/[0-9a-f]+

# medium
link\.medium\.com/[a-zA-Z0-9]+

# Slack
slack://[a-zA-Z0-9?&=]+
\bslack\.com/[-0-9a-zA-Z/_]*

# stackexchange -- https://stackexchange.com/feeds/sites
\b(?:askubuntu|serverfault|stack(?:exchange|overflow)|superuser).com/questions/\d+/[a-z-]+

# URL escaped characters
\%[0-9A-F]{2}
# c99 hex digits (not the full format, just one I've seen)
0x[0-9a-fA-F](?:\.[0-9a-fA-F]*|)[pP]
# sha256
sha256:[0-9a-f]+
# sha-... -- uses a fancy capture
(['"]|")[0-9a-f]{40,}\g{-1}
# hex in url queries
=[0-9a-fA-F]+&
# PGP
\b(?:[0-9A-F]{4} ){9}[0-9A-F]{4}\b
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9a-fA-FgGrR_]{2,}(?:[uU]?[lL]{0,2}|u\d+)\b
# uuid:
[<({"'>][0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[<'"})>]

# Input to GitHub JSON
content: "[-a-zA-Z=;:/0-9+]*="

# python f-string https://www.python.org/dev/peps/pep-0498/
\bf'

# Regular expressions for (P|p)assword
\([A-Z]\|[a-z]\)[a-z]+

# JavaScript regular expressions
/.*/[gim]*\.test\(
\.replace\(/[^/]*/[gim]*\s*,

# the negative lookahead here is to allow catching 'templatesz' as a misspelling
# but to otherwise recognize a Windows path with \templates\foo.template or similar:
\\templates(?![a-z])
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b

# Compiler flags
[\t >"`](?:-J|)-[DPWXY]
[\t "`]-[DPWXYLl]
# curl arguments
\b(?:\\n|)curl(?:\s+-[a-zA-Z]+)+
# set arguments
\bset\s+-[abefiuox]+\b
# tar arguments
\b(?:\\n|)tar(?:\s+-[a-zA-Z]+|\s[a-z]+)+
# macOS temp folders
/var/folders/\w\w/\w+/T/

1 comment on commit f079b38

@github-actions
Copy link

@github-actions github-actions bot commented on f079b38 Jul 20, 2021

Choose a reason for hiding this comment

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

@check-spelling-bot Report

Unrecognized words, please review:

  • abefiuox
  • abspath
  • accomodating
  • askubuntu
  • bak
  • bapi
  • bbit
  • bbox
  • bcolors
  • bdist
  • bgit
  • bgithub
  • bgravatar
  • borderaxespad
  • bset
  • bslack
  • celerybeat
  • CEND
  • CGREEN
  • Cov
  • Covsir
  • cri
  • currentframe
  • dmypy
  • DPWXY
  • DPWXYLl
  • dvipng
  • elif
  • extesibility
  • fdfc
  • garrettj
  • getfile
  • githubusercontent
  • GPLv
  • hos
  • htmlcov
  • ibb
  • idmod
  • iml
  • latestdoi
  • len
  • ncol
  • newcountconfirmed
  • newcountdeaths
  • opensource
  • pathlib
  • pdf
  • Phy
  • pid
  • pyflow
  • pypackages
  • requeset
  • RFY
  • ropeproject
  • rsd
  • sdist
  • serverfault
  • setuptools
  • SIHCR
  • SIHRD
  • SIRD
  • spyderproject
  • spyproject
  • susceptiblity
  • texlive
  • totalcountconfirmed
  • totalcountdeaths
  • urls
  • washingtonpost
  • webassets
  • WGIM
  • Worflow
  • XMjr
  • xslx
Some files were were automatically ignored

These sample patterns would exclude them:

^bin/bcolors\.py$

You should consider adding them to:

.github/actions/spelling/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To accept these unrecognized words as correct, run the following commands

... in a clone of the git@github.com:epispot/epispot.git repository
on the check-spelling 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);
'
(cat '.github/actions/spelling/excludes.txt' - <<EOF
$should_exclude_patterns
EOF
) |grep .|
sort -f |
uniq > '.github/actions/spelling/excludes.txt.temp' &&
mv '.github/actions/spelling/excludes.txt.temp' '.github/actions/spelling/excludes.txt'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/epispot/epispot/comments/53710515" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  

should_exclude_patterns=$(perl -e '$/=undef;
$_=<>;
exit unless s{(?:You should consider excluding directory paths|You should consider adding them to).*}{}s;
s{.*These sample patterns would exclude them:}{}s;
s{.*\`\`\`([^`]*)\`\`\`.*}{$1}m;
print' < "$comment_body" | grep . || true)

update_files
rm $comment_body
git add -u

Please sign in to comment.