From c895cb042df5005143e3ed5091577706382249cc Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Fri, 26 Aug 2022 02:26:20 -0400 Subject: [PATCH] feat(ci): add check-spelling (#1189) --- .github/actions/spelling/README.md | 16 + .github/actions/spelling/advice.md | 25 ++ .github/actions/spelling/allow.txt | 4 + .github/actions/spelling/candidate.patterns | 4 + .github/actions/spelling/excludes.txt | 54 +++ .github/actions/spelling/expect.txt | 378 ++++++++++++++++++ .../actions/spelling/line_forbidden.patterns | 48 +++ .github/actions/spelling/patterns.txt | 92 +++++ .github/actions/spelling/reject.txt | 10 + .github/workflows/spelling.yml | 104 +++++ 10 files changed, 735 insertions(+) create mode 100644 .github/actions/spelling/README.md create mode 100644 .github/actions/spelling/advice.md create mode 100644 .github/actions/spelling/allow.txt create mode 100644 .github/actions/spelling/candidate.patterns create mode 100644 .github/actions/spelling/excludes.txt create mode 100644 .github/actions/spelling/expect.txt create mode 100644 .github/actions/spelling/line_forbidden.patterns create mode 100644 .github/actions/spelling/patterns.txt create mode 100644 .github/actions/spelling/reject.txt create mode 100644 .github/workflows/spelling.yml diff --git a/.github/actions/spelling/README.md b/.github/actions/spelling/README.md new file mode 100644 index 00000000..d82bed75 --- /dev/null +++ b/.github/actions/spelling/README.md @@ -0,0 +1,16 @@ +# 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) +[line_forbidden.patterns](line_forbidden.patterns) | Patterns to flag in 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. diff --git a/.github/actions/spelling/advice.md b/.github/actions/spelling/advice.md new file mode 100644 index 00000000..54f0c9b5 --- /dev/null +++ b/.github/actions/spelling/advice.md @@ -0,0 +1,25 @@ + +
If the flagged items are false positives + +If items relate to a ... +* binary file (or some other file you wouldn't want to check at all). + + 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). + +* 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. + +
diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt new file mode 100644 index 00000000..494d4de9 --- /dev/null +++ b/.github/actions/spelling/allow.txt @@ -0,0 +1,4 @@ +github +https +ssh +ubuntu diff --git a/.github/actions/spelling/candidate.patterns b/.github/actions/spelling/candidate.patterns new file mode 100644 index 00000000..b1963070 --- /dev/null +++ b/.github/actions/spelling/candidate.patterns @@ -0,0 +1,4 @@ +# Apple music +\bembed\.music\.apple\.com/fr/playlist/usr-share/[-\w.]+ +# Spotify +\bopen\.spotify\.com/embed/playlist/\w+ diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt new file mode 100644 index 00000000..20fa4123 --- /dev/null +++ b/.github/actions/spelling/excludes.txt @@ -0,0 +1,54 @@ +# 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$ +\.a$ +\.ai$ +\.avi$ +\.bmp$ +\.bz2$ +\.crt$ +\.dll$ +\.DS_Store$ +\.eot$ +\.exe$ +\.gif$ +\.gitattributes$ +\.graffle$ +\.gz$ +\.icns$ +\.ico$ +\.jar$ +\.jpe?g$ +\.key$ +\.lib$ +\.lock$ +\.map$ +\.min\.. +\.mod$ +\.mp[34]$ +\.o$ +\.ocf$ +\.otf$ +\.pdf$ +\.pem$ +\.png$ +\.psd$ +\.s$ +\.svg$ +\.tiff?$ +\.ttf$ +\.wav$ +\.woff2?$ +\.zip$ +^\.github/actions/spelling/ +^\Q.github/readme/partials/documentation/inspirations.md\E$ +^\Q.github/workflows/spelling.yml\E$ +^\Qsource/plugins/sponsors/index.mjs\E$ +^\Qsource/plugins/stargazers/worldmap/atlas/50m_countries.geojson\E$ +^\Qsource/templates/terminal/fonts.css\E$ +^\Qsource/templates/terminal/partials/screenshot.ejs\E$ +^\Qtests/mocks/api/github/rest/emojis/get.mjs\E$ diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt new file mode 100644 index 00000000..56ef12c8 --- /dev/null +++ b/.github/actions/spelling/expect.txt @@ -0,0 +1,378 @@ +ABCDEFGHIJKLMNOPQRSTUVWXY +activeline +allowtransparency +alse +amd +anilist +apidojo +apostrophecms +argv +arobase +asi +audioscrobbler +Autoloaded +automator +backreference +Bizau +blankslate +blog +brackethighlighter +btn +cacheable +cakeday +captcha +charsets +chmod +chown +chrisbottin +cloudinary +cmake +codelines +codemirror +codeql +colorsets +Consolas +coord +csso +CVE +cwd +datapoints +dded +dependabot +deployer +deps +dessant +destructuring +Dexcom +dflag +diffs +diffstat +dirname +domcontentloaded +DOUBLEDOWN +DOUBLEUP +downvotes +dprint +dryrun +dto +ecma +Edg +eleased +eleted +emails +emoji +emojipedia +endgroup +endyear +ENOENT +entrypoint +eopened +eqeqeq +erged +esm +eugeneware +eviewed +expr +expressjs +extracter +extralarge +facebook +favicon +favourites +FEmusic +filesize +filesloop +Firefox +firstname +Fnc +foliojs +forkee +FORTYFIVEDOWN +FORTYFIVEUP +freefont +fss +FTg +fullyear +gemoji +geocodes +geopath +getrecenttracks +gettopartists +gettoptracks +ghactions +ghcr +ghfilter +ghquery +gifencoder +gionkunz +Gister +gitattributes +githubs +githubusercontent +gitted +globals +Gmap +gnupg +gnuplot +Gollum +google +googlechrome +gpg +grep +guttermarker +hackernews +hardcode +hashnode +hashtag +herokuapp +highalert +highlighter +homepage +honzaap +htmlescape +htmlsanitize +htmlunescape +hubot +hyperlinks +identicon +ies +iframes +imagga +imgb +indepth +infographics +infographile +installable +instanceof +instantier +Intelli +invertocat +Ionica +ipafont +ipsum +isaacs +isocalendar +itemprop +itunes +jellyfin +jshemas +kacst +keyup +Kotlin +largeable +lastfm +lastname +leaderboard +lecoq +legoandmars +libgconf +libssl +libx +libxml +libxmljs +libxss +libxtst +linux +lng +localhost +localstorage +logline +losed +lovell +lowalert +lowercased +lowlighter +lsb +lstat +mangas +markedjs +marudor +matchingbracket +matievisthekat +maxage +maxusers +mbid +mde +mergeability +mergeable +middlewares +mkdir +mockresize +mozilla +MSFT +myplugin +myquery +ncal +networkidle +newplugin +newyear +nfriedly +nightscout +Nixinova +NOASSERTION +nocase +nodeca +nodechartist +nodejs +notoken +octicon +OCTO +octocat +octokit +octonaut +octoraw +oid +ommented +opengraph +optimizable +orked +pageerror +pagespeed +pagespeedonline +panosoft +params +patchnote +pdated +pened +PGP +playcount +playlists +plugin +poopmap +practicaldev +prettylights +previewable +prismjs +producthunt +ptarjan +puppeteergif +purgecss +pwa +qmake +rankeds +rapidapi +ratelimit +ratelimiter +rbmok +rbren +rcopy +readdir +readme +readonly +reated +recenttracks +regexp +rlreset +rssi +runsh +SAPISID +SAPISIDHASH +scorecalc +screenshots +SDKs +Segoe +selfhosted +seo +Serializer +sgit +sgv +shipit +shm +SIGKILL +SINGLEDOWN +SINGLEUP +sourced +spamming +spams +spdx +sponsorable +spotify +stackexchange +stackoverflow +stagazers +standalone +starlist +stderr +stdin +stdio +stdout +steveukx +streamable +stripemojis +stroustrup +sublimelinter +substr +sudo +sysadmin +systemctl +systemd +tempdir +templating +testapp +testcase +Thu +timeline +tlwg +tmpdir +todo +topartists +toptracks +tracklist +transfonter +trollface +TSLA +twemoji +uapi +uconf +uid +uncache +Unconfigured +undef +underlinenav +Unescape +upcase +upvote +urgenthighalert +urgentlowalert +uri +urlencoded +URLTo +usermod +usernames +ushed +usr +utf +utm +vercel +vnd +vuejs +waifus +wakapi +wakatime +wasm +webserver +websites +wget +whitelisted +whoami +wiki +wikipedia +wontfix +workaround +WORKDIR +worldmap +wqy +wsl +xcb +Xcode +xkcd +xmlformat +ycombinator +ymd +yoda +youtube +ytd +ytmusic +Zabcdefghijklmnopqrstuvwxyz +zenhei +zenorocha diff --git a/.github/actions/spelling/line_forbidden.patterns b/.github/actions/spelling/line_forbidden.patterns new file mode 100644 index 00000000..25423054 --- /dev/null +++ b/.github/actions/spelling/line_forbidden.patterns @@ -0,0 +1,48 @@ +# reject `m_data` as there's a certain OS which has evil defines that break things if it's used elsewhere +# \bm_data\b + +# s.b. GitHub +\bGithub\b + +# s.b. GitLab +\bGitlab\b + +# s.b. JavaScript +\bJavascript\b + +# s.b. Microsoft +\bMicroSoft\b + +# s.b. another +\ban[- ]other\b + +# s.b. greater than +\bgreater then\b + +# s.b. less than +\bless then\b + +# s.b. otherwise +\bother[- ]wise\b + +# s.b. nonexistent +\bnon existing\b +\b[Nn]o[nt][- ]existent\b + +# s.b. preexisting +[Pp]re-existing + +# s.b. preempt +[Pp]re-empt\b + +# s.b. preemptively +[Pp]re-emptively + +# s.b. reentrancy +[Rr]e-entrancy + +# s.b. reentrant +[Rr]e-entrant + +# Reject duplicate words +\s([A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})\s\g{-1}\s diff --git a/.github/actions/spelling/patterns.txt b/.github/actions/spelling/patterns.txt new file mode 100644 index 00000000..036d73e9 --- /dev/null +++ b/.github/actions/spelling/patterns.txt @@ -0,0 +1,92 @@ +# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns + +# hit-count: 506 file-count: 66 +# w3 +\bw3\.org/[-0-9a-zA-Z/#.]+ + +# hit-count: 414 file-count: 136 +# GitHub SHAs (markdown) +(?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/ ]+){2,}(?:/[^/ )]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|) + +# hit-count: 69 file-count: 26 +\.replace\(/[^/]*/[gim]*\s*, + +# hit-count: 66 file-count: 31 +# JavaScript regular expressions +/[^/]*/[gim]*\.test\( + +# hit-count: 41 file-count: 14 +# URL escaped characters +\%[0-9A-F]{2} + +# hit-count: 29 file-count: 19 +# githubusercontent +/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]* + +# hit-count: 18 file-count: 6 +# data url in quotes +([`'"])data:.*?(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,}).*\g{-1} + +# hit-count: 12 file-count: 4 +# Contributor +\[[^\]]+\]\(https://github\.com/[^/ ]+\) + +# hit-count: 1 file-count: 1 +# YouTube music +\bmusic\.youtube\.com/youtubei/v1/browse(?:[?&]\w+=[-a-zA-Z0-9?&=_]*) + +# hit-count: 6 file-count: 5 +# While you could try to match `http://` and `https://` by using `s?` in `https?://`, sometimes there +# YouTube url +\b(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_]* + +# hit-count: 1 file-count: 1 +# AWS S3 +\b\w*\.s3[^.]*\.amazonaws\.com/[-\w/&#%_?:=]* + +# hit-count: 1 file-count: 1 +# GitHub SHAs +\bgithub\.com(?:/[^/ ]+){2}[@#][0-9a-f]+\b + +# hit-count: 1 file-count: 1 +# hex runs +\b[0-9a-fA-F]{16,}\b + +# hit-count: 1 file-count: 1 +# hex in url queries +=[0-9a-fA-F]*?(?:[A-F]{3,}|[a-f]{3,})[0-9a-fA-F]*?& + +# Automatically suggested patterns +# hit-count: 970 file-count: 25 +# hex digits including css/html color classes: +(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9a-fA-FgGrR_]{2,}(?:[uUlL]{0,3}|u\d+)\b + +# Automatically suggested patterns +# hit-count: 4 file-count: 4 +# Apple music +\bembed\.music\.apple\.com/fr/playlist/usr-share/[-\w.]+ + +# hit-count: 4 file-count: 4 +# Spotify +\bopen\.spotify\.com/embed/playlist/\w+ + +computed\.avatar = await avatar \|\| ".*" +place_id: ".*" +(?:answer|question|user): "[^"]*" + +# acceptable duplicates +# ls directory listings +[-bcdlpsw](?:[-r][-w][-sx]){3}\s+\d+\s+(\S+)\s+\g{-1}\s+\d+\s+ +# C types +\s(long|LONG) \g{-1}\s +# javadoc / .net +(?:[\\@](?:groupname|param)|(?:public|private)(?:\s+static|\s+readonly)*)\s+(\w+)\s+\g{-1}\s + +# Commit message -- Signed-off-by and friends +^\s*(?:(?:Based-on-patch|Co-authored|Helped|Mentored|Reported|Reviewed|Signed-off)-by|Thanks-to): (?:[^<]*<[^>]*>|[^<]*)\s*$ + +# Autogenerated revert commit message +^This reverts commit [0-9a-f]{40}\.$ + +# ignore long runs of a single character: +\b([A-Za-z])\g{-1}{3,}\b diff --git a/.github/actions/spelling/reject.txt b/.github/actions/spelling/reject.txt new file mode 100644 index 00000000..b5a6d368 --- /dev/null +++ b/.github/actions/spelling/reject.txt @@ -0,0 +1,10 @@ +^attache$ +benefitting +occurences? +^dependan.* +^oer$ +Sorce +^[Ss]pae.* +^untill$ +^untilling$ +^wether.* diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 00000000..b587d178 --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,104 @@ +name: Check Spelling + +# Updating pull request branches is managed via comment handling. +# For details, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-expect-list +# +# These elements work together to make it happen: +# +# `on.issue_comment` +# This event listens to comments by users asking to update the metadata. +# +# `jobs.update` +# This job runs in response to an issue_comment and will push a new commit +# to update the spelling metadata. +# +# `with.experimental_apply_changes_via_bot` +# Tells the action to support and generate messages that enable it +# to make a commit to update the spelling metadata. +# +# `with.ssh_key` +# In order to trigger workflows when the commit is made, you can provide a +# secret (typically, a write-enabled github deploy key). +# +# For background, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-with-deploy-key + +on: + push: + branches: ["**"] + tags-ignore: ["**"] + pull_request_target: + issue_comment: + types: [created] + +jobs: + spelling: + name: Check Spelling + permissions: + contents: read + pull-requests: read + actions: read + outputs: + followup: ${{ steps.spelling.outputs.followup }} + 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: check-spelling + id: spelling + uses: check-spelling/check-spelling@v0.0.20 + with: + experimental_apply_changes_via_bot: ${{ github.repository_owner != 'lowlighter' && 1 || 0 }} + suppress_push_for_open_pull_request: 1 + checkout: true + post_comment: 0 + extra_dictionaries: + cspell:html/html.txt + cspell:filetypes/filetypes.txt + cspell:css/css.txt + cspell:fullstack/fullstack.txt + cspell:django/django.txt + cspell:npm/npm.txt + cspell:aws/aws.txt + check_extra_dictionaries: '' + + comment: + name: Report + runs-on: ubuntu-latest + needs: spelling + permissions: + contents: write + pull-requests: write + if: (success() || failure()) && needs.spelling.outputs.followup + steps: + - name: comment + uses: check-spelling/check-spelling@v0.0.20 + with: + checkout: true + task: ${{ needs.spelling.outputs.followup }} + experimental_apply_changes_via_bot: ${{ github.repository_owner != 'lowlighter' && 1 || 0 }} + + update: + name: Update PR + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + if: ${{ + github.repository_owner != 'lowlighter' && + 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: apply spelling updates + uses: check-spelling/check-spelling@v0.0.20 + with: + experimental_apply_changes_via_bot: ${{ github.repository_owner != 'lowlighter' && 1 || 0 }} + checkout: true + ssh_key: "${{ secrets.CHECK_SPELLING }}"