Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shared): Implement GitHub Spellcheck and grammar linting for Pull request. #2418

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/.spellcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
matrix:
- name: Markdown
expect_match: false
apsell:
mode: en
dictionary:
wordlists:
- .github/.wordlist.txt
output: wordlist.dic
encoding: utf-8
pipeline:
- pyspelling.filters.markdown:
markdown_extensions:
- markdown.extensions.extra:
- pyspelling.filters.html:
comments: false
attributes:
- alt
ignores:
- ':matches(code, pre, .photoAuthor)'
- 'code'
- 'pre'
- 'blockquote'
43 changes: 43 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Hyperledger
Corda
Ansible
DLT
DevOps
reStructuredText
Kubernetes
Github
TSC
mwagner
redhat
zyz
Alagbe
Cepeda
Deepak
Gómez
Jagpreet
Kumar
Picazo
Sarkar
Sasan
Suvajit
sownak
Opensource
Besu
ReadTheDocs
boolean
Codecov
tkuhrt
hamilton
jonathan
DCI
runtime
Tessera
IBFT
CII
rst
toctree
conf
py
md
pre
html
73 changes: 73 additions & 0 deletions .github/workflows/spellcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: spell and grammer check
on:
push:
branches:
- "**"
pull_request_target:
branches:
- "**"
types: [opened, edited, updated]

env:
SPELL_CHECK_DISABLED: false
GRAMMAR_CHECK_DISABLED: false

jobs:
check-spelling-and-grammar:
runs-on: ubuntu-latest
steps:
sailajakommineni marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
# Install the dependencies for grammer check and spell check.
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install pyspelling
sudo apt-get install hunspell hunspell-en-us aspell aspell-en
pip install --user --upgrade language_tool_python

- uses: actions/checkout@v2
- name: Spellcheck
if: ${{ env.SPELL_CHECK_DISABLED == 'false' }}
uses: rojopolis/[email protected]
with:
config_path: .github/.spellcheck.yaml
source_files: "docs/README.md" # name of the file to check spell
task_name: Markdown
# To check the grammatical mistakes of the given files and folders.
- name: Run grammar check
if: ${{ env.GRAMMAR_CHECK_DISABLED == 'false' }}
run: |
cat <<EOF | python -
import language_tool_python

# Initialize LanguageTool
tool = language_tool_python.LanguageTool('en-US') # You can specify the language you want to check.

# Specify the directory path
directory_path = 'docs'

# Read the text from your file
file_path = 'docs/README.md' # Update the path accordingly
with open(file_path, 'r', encoding='utf-8') as file:
text = file.read()

# Check for grammar errors
matches = tool.check(text)

# Print grammar errors with line numbers
if matches:
for match in matches:
print(f"Grammar error at line {match.offset} - {match.message}")
# Exit with a non-zero code to indicate failure
exit(1)
else:
# No grammar errors found, print a success message
print("No grammar errors found.")

exit(0)
EOF
Loading