Skip to content

Commit fad1e11

Browse files
authored
Merge pull request #941 from mlcommons/feature/spellchecker
Spellchecker action
2 parents 60adf5d + 1cdb3ae commit fad1e11

File tree

14 files changed

+942
-20
lines changed

14 files changed

+942
-20
lines changed

.github/workflows/spellchecker.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Check Spelling
2+
3+
# Comment management is handled through a secondary job, for details see:
4+
# https://github.com/check-spelling/check-spelling/wiki/Feature%3A-Restricted-Permissions
5+
#
6+
# `jobs.comment-push` runs when a push is made to a repository and the `jobs.spelling` job needs to make a comment
7+
# (in odd cases, it might actually run just to collapse a comment, but that's fairly rare)
8+
# it needs `contents: write` in order to add a comment.
9+
#
10+
# `jobs.comment-pr` runs when a pull_request is made to a repository and the `jobs.spelling` job needs to make a comment
11+
# or collapse a comment (in the case where it had previously made a comment and now no longer needs to show a comment)
12+
# it needs `pull-requests: write` in order to manipulate those comments.
13+
14+
# Updating pull request branches is managed via comment handling.
15+
# For details, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-expect-list
16+
#
17+
# These elements work together to make it happen:
18+
#
19+
# `on.issue_comment`
20+
# This event listens to comments by users asking to update the metadata.
21+
#
22+
# `jobs.update`
23+
# This job runs in response to an issue_comment and will push a new commit
24+
# to update the spelling metadata.
25+
#
26+
# `with.experimental_apply_changes_via_bot`
27+
# Tells the action to support and generate messages that enable it
28+
# to make a commit to update the spelling metadata.
29+
#
30+
# `with.ssh_key`
31+
# In order to trigger workflows when the commit is made, you can provide a
32+
# secret (typically, a write-enabled github deploy key).
33+
#
34+
# For background, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-with-deploy-key
35+
36+
# Sarif reporting
37+
#
38+
# Access to Sarif reports is generally restricted (by GitHub) to members of the repository.
39+
#
40+
# Requires enabling `security-events: write`
41+
# and configuring the action with `use_sarif: 1`
42+
#
43+
# For information on the feature, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Sarif-output
44+
45+
# Minimal workflow structure:
46+
#
47+
# on:
48+
# push:
49+
# ...
50+
# pull_request_target:
51+
# ...
52+
# jobs:
53+
# # you only want the spelling job, all others should be omitted
54+
# spelling:
55+
# # remove `security-events: write` and `use_sarif: 1`
56+
# # remove `experimental_apply_changes_via_bot: 1`
57+
# ... otherwise adjust the `with:` as you wish
58+
59+
on:
60+
push:
61+
branches:
62+
- "**"
63+
tags-ignore:
64+
- "**"
65+
pull_request_target:
66+
branches:
67+
- "**"
68+
types:
69+
- 'opened'
70+
- 'reopened'
71+
- 'synchronize'
72+
issue_comment:
73+
types:
74+
- 'created'
75+
76+
jobs:
77+
spelling:
78+
name: Check Spelling
79+
permissions:
80+
contents: read
81+
pull-requests: read
82+
actions: read
83+
security-events: write
84+
outputs:
85+
followup: ${{ steps.spelling.outputs.followup }}
86+
runs-on: ubuntu-latest
87+
if: ${{ contains(github.event_name, 'pull_request') || github.event_name == 'push' }}
88+
concurrency:
89+
group: spelling-${{ github.event.pull_request.number || github.ref }}
90+
# note: If you use only_check_changed_files, you do not want cancel-in-progress
91+
cancel-in-progress: true
92+
steps:
93+
- name: check-spelling
94+
id: spelling
95+
uses: check-spelling/check-spelling@main
96+
with:
97+
config: .spelling
98+
checkout: true
99+
check_file_names: 1
100+
spell_check_this: check-spelling/spell-check-this@prerelease
101+
post_comment: 0
102+
use_magic_file: 1
103+
report-timing: 1
104+
warnings: bad-regex,binary-file,deprecated-feature,large-file,limited-references,no-newline-at-eof,noisy-file,non-alpha-in-dictionary,token-is-substring,unexpected-line-ending,whitespace-in-dictionary,minified-file,unsupported-configuration,no-files-to-check
105+
experimental_apply_changes_via_bot: 1
106+
use_sarif: ${{ (!github.event.pull_request || (github.event.pull_request.head.repo.full_name == github.repository)) && 1 }}
107+
extra_dictionary_limit: 20
108+
extra_dictionaries:
109+
cspell:software-terms/dict/softwareTerms.txt
110+
cspell:python/src/python/python-lib.txt
111+
cspell:python/src/python/python.txt
112+
cspell:python/src/common/extra.txt
113+
cspell:php/dict/php.txt
114+
cspell:r/src/r.txt
115+
cspell:aws/aws.txt
116+
cspell:django/dict/django.txt
117+
cspell:filetypes/filetypes.txt
118+
cspell:node/dict/node.txt
119+
cspell:golang/dict/go.txt
120+
cspell:fullstack/dict/fullstack.txt
121+
cspell:java/src/java.txt
122+
cspell:k8s/dict/k8s.txt
123+
cspell:css/dict/css.txt
124+
cspell:npm/dict/npm.txt
125+
cspell:latex/dict/latex.txt
126+
cspell:latex/samples/sample-words.txt
127+
cspell:html-symbol-entities/entities.txt
128+
cspell:html/dict/html.txt
129+
cspell:cpp/src/ecosystem.txt
130+
cspell:mnemonics/src/mnemonics.txt
131+
132+
comment-push:
133+
name: Report (Push)
134+
# If your workflow isn't running on push, you can remove this job
135+
runs-on: ubuntu-latest
136+
needs: spelling
137+
permissions:
138+
contents: write
139+
if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push'
140+
steps:
141+
- name: comment
142+
uses: check-spelling/check-spelling@main
143+
with:
144+
checkout: true
145+
spell_check_this: check-spelling/spell-check-this@prerelease
146+
task: ${{ needs.spelling.outputs.followup }}
147+
148+
comment-pr:
149+
name: Report (PR)
150+
# If you workflow isn't running on pull_request*, you can remove this job
151+
runs-on: ubuntu-latest
152+
needs: spelling
153+
permissions:
154+
contents: read
155+
pull-requests: write
156+
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
157+
steps:
158+
- name: comment
159+
uses: check-spelling/check-spelling@main
160+
with:
161+
checkout: true
162+
spell_check_this: check-spelling/spell-check-this@prerelease
163+
task: ${{ needs.spelling.outputs.followup }}
164+
experimental_apply_changes_via_bot: 1
165+
166+
update:
167+
name: Update PR
168+
permissions:
169+
contents: write
170+
pull-requests: write
171+
actions: read
172+
runs-on: ubuntu-latest
173+
if: ${{
174+
github.event_name == 'issue_comment' &&
175+
github.event.issue.pull_request &&
176+
contains(github.event.comment.body, '@check-spelling-bot apply')}}
177+
concurrency:
178+
group: spelling-update-${{ github.event.issue.number }}
179+
cancel-in-progress: false
180+
steps:
181+
- name: apply spelling updates
182+
uses: check-spelling/check-spelling@main
183+
with:
184+
experimental_apply_changes_via_bot: 1
185+
checkout: true
186+
ssh_key: "${{ secrets.CHECK_SPELLING }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ testing/config_segmentation_temp.yaml
2525
testing/failures.log
2626
coverage.xml
2727
mlcube/workspace/*
28+
!.spelling/.spelling/expect.txt
2829
!mlcube/workspace/config.yml
2930
!mlcube/workspace/channelIDs.yml
3031
tutorials/classification_medmnist_notebook/dataset/pathmnist

0 commit comments

Comments
 (0)