Skip to content

Commit

Permalink
feat(shared): Implement GitHub Spellcheck and grammar linting for Pul…
Browse files Browse the repository at this point in the history
…l request.

This pull request implements the GitHub Spellcheck feature to automatically check the spelling and grammar in commit messages for all Pull Requests (PRs).

Changes Made:
- modified the code to check the grammar errors at exact line numbers.
-In docs/README.md file corrected the grammar errors.

Fixes: #2327

Signed-off-by: sailajakommineni <[email protected]>
  • Loading branch information
sailajakommineni authored and suvajit-sarkar committed Dec 1, 2023
1 parent 2c1f343 commit 6e65419
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 107 deletions.
128 changes: 128 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,131 @@ py
md
pre
html
http
www
rst
toctree
reStructuredText
DCO
UI
Blockchain
DigitalOcean
GCP
repo
APIs
readme
https
EKS
yaml
microservices
Modularity
Scalability
readthedocs
roadmap
Jira
CLI
ansible
kubectl
gitops
CRD
CustomResourceDefinition
fluxcd
github
TBD
trainings
HashiCorp
upto
HelmRelease
hackathon
Hashicorp
Authenticator
JSON
ajv
cli
npm
NPM
MacOS
jq
openshift
Homebrew
validator
blockchain
GitOps
VM
backend
DNS
HAProxy
POC
dev
url
cryptographically
BaaS
OpenShift
BYOI
architected
TCP
scalable
MSP
SDK
MSPs
kubeconfig
TLS
PV
RPC
CorDapps
JVM
CA’s
PKI
KUBECONFIG
DDO
DIDs
NYM
rpc
MTA
memcached
auditable
config
IAM
IOT
IoT
kubelet
Kubeconfig
PersistentVolume
lifecycle
cryptographic
decrypting
SCM
SHA
Brandl
Georg
LDAP
Chaincode
chaincode
subnet
Orderer
permissioned
Zkkafka
zkkafka
servlet
CA’s
NetworkMap
Networkmap
interoperable
merkle
Verinym
Sovrin
Prover
Anonym
DKMS
Enode
privateFor
Ethereum
geth
pluggable
Hostnames
crypto
parallelization
kube
PV's
CorDapp
storageclass
73 changes: 73 additions & 0 deletions .github/workflows/grammarcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: grammer check
on:
workflow_dispatch:
inputs:
grammar_check_disabled:
description: 'Disable grammar check'
default: 'false'
required: false
push:
branches:
- "**"
pull_request:
paths:
- 'docs/*.md'
types: [opened, edited, updated]

env:
GRAMMAR_CHECK_DISABLED: ${{ github.event.inputs.grammar_check_disabled || 'false' }}

jobs:
check-grammar:
runs-on: ubuntu-latest
steps:
- 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
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install --user --upgrade language_tool_python
# To check the grammatical mistakes of the given files and folders.
- name: Run grammar check
if: ${{ env.GRAMMAR_CHECK_DISABLED == 'false' }}
run: |
python - <<EOF
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/*.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 relevant grammar errors with line numbers
relevant_errors = []
if matches:
for match in matches:
if match.ruleId == 'MORFOLOGIK_RULE_EN_US':
line_number = text.count('\n', 0, match.offset) + 1
relevant_errors.append((line_number, match.message))
if relevant_errors:
for error in relevant_errors:
line_number, message = error
print(f"Grammar error at line {line_number}: {message}")
exit(1)
else:
print("No grammar errors found.")
exit(0)
EOF
51 changes: 8 additions & 43 deletions .github/workflows/spellcheck.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,38 @@
---
name: spell and grammer check
name: spell check
on:
push:
branches:
- "**"
pull_request_target:
branches:
- "**"
pull_request:
paths:
- 'docs/*.md'
types: [opened, edited, updated]

env:
SPELL_CHECK_DISABLED: false
GRAMMAR_CHECK_DISABLED: false

jobs:
check-spelling-and-grammar:
check-spelling:
runs-on: ubuntu-latest
steps:
- 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.
# Install the dependencies for 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
source_files: 'docs/*.md' # name of the file to check the 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
35 changes: 16 additions & 19 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
# Docs
## About
This directory contains the files required to create open source documentation.
Tools used: [Sphinx](http://www.sphinx-doc.org/)
### Configuration files
* **Index.rst** - This is the main document. Main function of this document is to serve as a welcome page, and to contain the root of the “table of contents tree” (or toctree).This is one of the main things that Sphinx adds to reStructuredText, a way to connect multiple files to a single hierarchy of documents
* **conf.py** - The configuration directory must contain a file named conf.py. This file (containing Python code) is called the “build configuration file” and contains (almost) all configuration needed to customize Sphinx input and output behavior.
* **.md files** - Create all the markdown file which are referenced in the document tree with the appropriate content.
This directory contains the files required to create open-source documentation.
Tools used: [Sphinx] (http://www.sphinx-doc.org/).
## Configuration files
* **index.rst** - This is the main document. This is one of the main things that Sphinx adds to restructured text: a way to connect multiple files to a single hierarchy of documents, including the 'table of contents tree'(or toctree).
* **conf.py**: The configuration directory must contain a file named conf.py. This file (containing Python code) is called the “build configuration file” and contains (almost) all the configuration needed to customize Sphinx input and output behavior.
* **.md files**: Create all the markdown files that are referenced in the document tree with the appropriate content.

```
./
├── docs
│   ├── source
── index.rst
├── conf.py
├── *.md
| | |── index.rst
  │   ├── conf.py
  │   ├── *.md
│   ├── Makefile
| ├── pip-requirements.txt
|   ├── pip-requirements.txt
│   └── README.md
├── CONTRIBUTING.md
```

### Building the docs
1. Install latest sphinx
1. Install the latest Sphinx.
```
pip install -U Sphinx
```
2. Install the pre-requisites
2. Install the prerequisites.
```
pip install -r pip-requirements.txt
```
3. Build the documents
3. Build the documents.
```
make html
make HTML
or
make.bat html
make.bat HTML
```
4. Access the documents from **build/html/** folder.



4. Access the documents from the **build/html** folder.
2 changes: 1 addition & 1 deletion docs/source/compatibilitytable.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Compatibility Table
Bevel current tools/platforms support version and historic details
## Colour Legends
## Color Legends
![](./_static/legends.png)
## Compatibility Table
![](./_static/compatibility_table.png)
8 changes: 4 additions & 4 deletions docs/source/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ there's always plenty to do!

First things first, please review the [Hyperledger Code of Conduct](https://wiki.hyperledger.org/display/HYP/Hyperledger+Code+of+Conduct) before participating and please follow it in all your interactions with the project.

You can contibute to Bevel, as a user or/and as a developer.
You can contribute to Bevel, as a user or/and as a developer.

##### As a user:

Expand All @@ -23,7 +23,7 @@ You can contibute to Bevel, as a user or/and as a developer.

Consider picking up a [“help-wanted”](https://github.com/hyperledger/bevel/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or ["good-first-issue"](https://github.com/hyperledger/bevel/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) task

If you can commit to full-time/part-time development, then please contact us on our [Rocketchat channel](https://chat.hyperledger.org/channel/bevel ) to work through logistics!
If you can commit to full-time/part-time development, then please contact us on our [Rocket chat channel](https://chat.hyperledger.org/channel/bevel ) to work through logistics!

Please visit the
[Developer Guide](developerguide.md) in the docs to learn how to make contributions to this exciting project.
Expand All @@ -41,11 +41,11 @@ For source code integrity , Hyperledger Bevel GitHub pull requests are accepted
5. Push your changes to your feature branch
6. Initiate a pull request from your fork to the base repository ( develop branch , unless it is a critical bug, in that case initiate to the main branch)
7. Await DCO & linting quality checks ( CI to come soon ), as well as any feedback from reviewers.
8. Work on the feedbacks to revise the PR if there are any comments
8. Work on the feedback to revise the PR if there are any comments
9. If not, the PR gets approved , delete feature branch post the merge

---
**NOTE:** If you are a regular contributor , please make sure to take the latest pull from the develop branch everytime before making any pull request , main branch in case of a critical defect / bug .
**NOTE:** If you are a regular contributor , please make sure to take the latest pull from the develop branch every time before making any pull request , main branch in case of a critical defect / bug .

---

Expand Down
Loading

0 comments on commit 6e65419

Please sign in to comment.