📄 docs: Ethereum's dev plan #637
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🥢 Spell check | |
on: | |
pull_request_target: | |
branches: | |
- main | |
jobs: | |
typo_check: | |
name: 🥢 Spell check | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
# ⚠️ [Security Warning] Usage of `pull_request_target` along with fork ref checkout is a SECURITY RISK. ⚠️ | |
# > Generally speaking, when the PR contents are treated as passive data, | |
# > i.e. not in a position of influence over the build/testing process, it is safe. | |
# > But the repository owners must be extra careful not to trigger any script that may operate | |
# > on PR controlled contents like in the case of npm install. | |
# for more information, see: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 2 | |
- name: Install aspell | |
run: sudo apt-get update && sudo apt-get install -y aspell | |
- name: Find and check typos in Markdown files | |
id: find_typos | |
run: | | |
echo "Checking for typos..." | |
IFS=$'\n' | |
set -f | |
for file in $(find . -name "*.md" ); do | |
if [ ! -s "$file" ]; then | |
continue | |
fi | |
echo "Checking $file..." | |
# Get typos with line numbers using grep | |
output="$(aspell --lang=en_US --mode=markdown --home-dir=. --personal=wordlist.txt --ignore-case=true --camel-case --add-sgml-skip name list <"$file")" | |
if [ $? -eq 0 ]; then | |
if [[ -n "$output" ]]; then | |
while IFS= read -r word; do | |
# Find line numbers for each typo | |
line_nums=$(grep -n "$word" "$file" | cut -d: -f1 | tr '\n' ',' | sed 's/,$//') | |
TYPOS+="- 📄 $file (line(s) $line_nums):" | |
TYPOS+=$'\n' | |
TYPOS+=" 1. ❌ $word" | |
TYPOS+=$'\n' | |
done <<< "$output" | |
fi | |
else | |
echo "::error::aspell failed on $file" | |
exit 1 | |
fi | |
done | |
{ | |
echo 'TYPOS<<EOF' | |
echo "$TYPOS" | |
echo EOF | |
} >> "$GITHUB_ENV" | |
- name: Comment on pull request | |
if: env.TYPOS != '' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const author = '${{github.event.pull_request.user.login}}'; | |
const typos = `${{ env.TYPOS }}`; | |
const body = ` | |
Hi @${author}, | |
⚠️ Potential typos found in your pull request: | |
${typos} | |
## ℹ️ How to fix this error: | |
1. **If these are actual typos:** | |
- Open the files at the specified line numbers and fix them | |
2. **If these are names or one-off nouns:** | |
- Wrap them in \`<name>\` tags | |
- Example: \`<name>Alex Pereira</name>\` | |
- Use this for people's names or unique terms that appear rarely | |
3. **If these are valid terms:** | |
- Add them to \`wordlist.txt\` (one word per line) | |
- Terms must be plain text without spaces/special chars | |
- The list is case-insensitive | |
4. **If these are code terms:** | |
- Wrap them in backticks (\`) in your markdown | |
## ℹ️ Checking for typos locally | |
1. Install [aspell](https://www.gnu.org/software/aspell/) for your platform | |
2. Navigate to project root and run: | |
\`\`\`bash | |
for f in **/*.md ; do echo $f ; aspell --lang=en_US --mode=markdown --home-dir=. --personal=wordlist.txt --ignore-case=true --camel-case --add-sgml-skip nospellcheck list < $f | sort | uniq -c ; done | |
\`\`\` | |
[Learn more about wordlist format](http://aspell.net/man-html/Format-of-the-Personal-and-Replacement-Dictionaries.html) | |
`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}); | |
core.setFailed('🥢 Spell check found potential typos. See PR comment for details.'); |