1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-14 09:50:08 +00:00

ci: add check-spelling action (#10470)

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
This commit is contained in:
Josh Soref 2021-12-02 06:17:00 -05:00 committed by GitHub
parent 46e63340ee
commit 841f3cb0bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 4745 additions and 0 deletions

15
.github/actions/spelling/README.md vendored Normal file
View file

@ -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
.github/actions/spelling/advice.md vendored Normal file
View file

@ -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>

0
.github/actions/spelling/allow.txt vendored Normal file
View file

41
.github/actions/spelling/excludes.txt vendored Normal file
View file

@ -0,0 +1,41 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
(?:^|/)(?i)COPYRIGHT
(?:^|/)(?i)LICEN[CS]E
(?:^|/)package(?:-lock|)\.json$
(?:^|/)vendor/
ignore$
\.avi$
\.ico$
\.jpe?g$
\.lock$
\.map$
\.min\..
\.mod$
\.mp[34]$
\.png$
\.wav$
^\.github/
^\Qplugins/archlinux/archlinux.plugin.zsh\E$
^\Qplugins/cp/cp.plugin.zsh\E$
^\Qplugins/extract/_extract\E$
^\Qplugins/genpass/genpass.plugin.zsh\E$
^\Qplugins/gitignore/gitignore.plugin.zsh\E$
^\Qplugins/gnu-utils/gnu-utils.plugin.zsh\E$
^\Qplugins/hitchhiker/fortunes/hitchhiker\E$
^\Qplugins/jhbuild/jhbuild.plugin.zsh\E$
^\Qplugins/jhbuild/README.md\E$
^\Qplugins/jruby/jruby.plugin.zsh\E$
^\Qplugins/kubectl/kubectl.plugin.zsh\E$
^\Qplugins/lol/lol.plugin.zsh\E$
^\Qplugins/mosh/mosh.plugin.zsh\E$
^\Qplugins/npx/npx.plugin.zsh\E$
^\Qplugins/powder/_powder\E$
^\Qplugins/suse/suse.plugin.zsh\E$
^\Qplugins/thor/_thor\E$
^\Qplugins/universalarchive/_universalarchive\E$
^\Qplugins/vagrant/vagrant.plugin.zsh\E$
^\Qplugins/wp-cli/README.md\E$
^\Qplugins/wp-cli/wp-cli.plugin.zsh\E$
^\Qthemes/clean.zsh-theme\E$
^\Qthemes/philips.zsh-theme\E$
^\Qthemes/tonotdo.zsh-theme\E$

4489
.github/actions/spelling/expect.txt vendored Normal file

File diff suppressed because it is too large Load diff

73
.github/actions/spelling/patterns.txt vendored Normal file
View file

@ -0,0 +1,73 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
# YouTube
https?://(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_]*
<\s*youtube\s+id=['"][-a-zA-Z0-9?_]*['"]
\bimg\.youtube\.com/vi/[-a-zA-Z0-9?&=_]*
# Google Analytics
\bgoogle-analytics\.com/collect.[-0-9a-zA-Z?%=&_.~]*
# Google APIs
\bgoogleapis\.com/[a-z]+/v\d+/[a-z]+/[@./?=\w]+
\b[-a-zA-Z0-9.]*\bstorage\d*\.googleapis\.com(?:/\S*|)
# Google Calendar
\bcalendar\.google\.com/calendar(?:/u/\d+|)/embed\?src=[@./?=\w&%]+
\w+\@group\.calendar\.google\.com\b
# Google DataStudio
\bdatastudio\.google\.com/(?:(?:c/|)u/\d+/|)(?:embed/|)(?:open|reporting|datasources|s)/[-0-9a-zA-Z]+(?:/page/[-0-9a-zA-Z]+|)
# The leading `/` here is as opposed to the `\b` above
# ... a short way to match `https://` or `http://` since most urls have one of those prefixes
# Google Docs
/docs\.google\.com/[a-z]+/d/(?:e/|)[0-9a-zA-Z_-]+/?
# Google Drive
\bdrive\.google\.com/file/d/[0-9a-zA-Z_?=]*
# Google Groups
\bgroups\.google\.com/(?:forum/#!|d/)(?:msg|topic)/[^/]+/[a-zA-Z0-9]+(?:/[a-zA-Z0-9]+|)
# Google themes
themes\.googleusercontent\.com/static/fonts/[^/]+/v\d+/[^.]+.
# Google CDN
\bclients2\.google(?:usercontent|)\.com[-0-9a-zA-Z/.]*
# Goo.gl
/goo\.gl/[a-zA-Z0-9]+
# Google Chrome Store
\bchrome\.google\.com/webstore/detail/\w*(?:/\w*|)
# Google Books
\bbooks\.google\.(?:\w{2,4})/books\?[-\w\d=&#.]*
# Google Fonts
\bfonts\.(?:googleapis|gstatic)\.com/[-/?=:;+&0-9a-zA-Z]*
# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
(?:\[[0-9a-f]+\]\(https:/|)/(?:www\.|)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/[^/]+\)
# GHSA
GHSA(?:-[0-9a-z]{4}){3}
LS_COLORS=(["']).*?\g{-1}
(\\?)%[a-zA-Z]+\g{-1}(?!%)
# URL escaped characters
\%[0-9A-F]{2}
# 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
# https://www.gnu.org/software/groff/manual/groff.html
# man troff content
\\f[BCIPR]
# Compiler flags
[\t "'`=]-[LPWXY]
[\t "'`=]-D(?!ebian)
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b

7
.github/actions/spelling/reject.txt vendored Normal file
View file

@ -0,0 +1,7 @@
^attache$
benefitting
occurence
Sorce
^[Ss]pae
^untill
^wether

95
.github/workflows/spelling.yml vendored Normal file
View file

@ -0,0 +1,95 @@
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 }}
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-merge
if: "contains(github.event_name, 'pull_request')"
uses: actions/checkout@v2
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: checkout
if: github.event_name == 'push'
uses: actions/checkout@v2
- name: check-spelling
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()
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