-
Notifications
You must be signed in to change notification settings - Fork 5
45 lines (33 loc) · 1.59 KB
/
spellcheck_action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Spellcheck Markdown
on: [push, pull_request]
jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install codespell
run: pip install codespell
- name: Filter files and run codespell
run: |
# Create a temporary file to store words to ignore
TEMP_IGNORE_FILE=$(mktemp)
# Ignore Acronyms (all caps), with and without trailing punctuation
grep --no-filename -oE '\b[A-Z]+\b' $(git ls-files '*.md') | sort -u >> $TEMP_IGNORE_FILE
# Ignore Proper nouns (capitalized first letter), with and without trailing punctuation
grep --no-filename -oE '\b[A-Z][a-z]+\b' $(git ls-files '*.md') | sort -u >> $TEMP_IGNORE_FILE
# Ignore words that start and end with . because they are likely to be in http links
# but only add their version without the . to the list
grep --no-filename -oE '\b\.[a-z]+\b' $(git ls-files '*.md') | sed 's/^.//' | sort -u >> $TEMP_IGNORE_FILE
# Remove duplicate entries
sort -u $TEMP_IGNORE_FILE -o $TEMP_IGNORE_FILE
# Cat ignore file for debugging
echo "Ignore list: $(tr '\n' ',' < $TEMP_IGNORE_FILE)"
# Run codespell on Markdown files with dynamically generated ignore list
codespell --ignore-words-list="$(tr '\n' ',' < $TEMP_IGNORE_FILE)" $(git ls-files '*.md')
# Clean up
rm $TEMP_IGNORE_FILE