11name : Docs Quality
2+
23on :
34 pull_request :
4- workflow_dispatch :
5+ paths :
6+ - " docs/**/*.md"
7+ - " docs/**/*.mdx"
8+ - " _typos.toml"
9+ - " .github/workflows/docs-quality.yml"
10+ push :
11+ branches : [main]
12+ workflow_dispatch : {}
13+
14+ permissions :
15+ contents : read
16+
517jobs :
618 typos :
719 name : Spelling (typos-cli)
820 runs-on : ubuntu-latest
921 steps :
10- - name : Checkout
11- uses : actions/checkout@v6
22+ - uses : actions/checkout@v4
1223 - uses : crate-ci/typos@master
1324
1425 harper :
15- name : Grammar and Style Check
26+ name : Grammar & headings (Harper)
1627 runs-on : ubuntu-latest
28+ continue-on-error : true
1729 steps :
18- - name : Checkout
19- uses : actions/checkout@v6
20- - name : Cache Harper CLI
30+ - uses : actions/checkout@v4
31+
32+ - name : Cache harper-cli binary
2133 id : cache-harper
2234 uses : actions/cache@v4
2335 with :
24- path : |
25- ~/.cargo/bin/harper-cli
26- ~/.cargo/registry
27- ~/.cargo/git
28- key : ${{ runner.os }}-harper-cli
36+ path : ~/.cargo/bin/harper-cli
37+ key : harper-cli-${{ runner.os }}-v1
2938 restore-keys : |
30- ${{ runner.os }}-harper-cli
39+ harper-cli-${{ runner.os }}-
40+
3141 - name : Report cache status
3242 run : |
3343 echo "cache-hit output: '${{ steps.cache-harper.outputs.cache-hit }}'"
34- ls -la ~/.cargo/bin/ 2>&1 || echo "~/.cargo/bin does not exist"
35- if [ -x ~/.cargo/bin/harper-cli ]; then
36- echo "RESULT: harper-cli binary present and executable"
37- ~/.cargo/bin/harper-cli --version || true
44+ if [ -f ~/.cargo/bin/harper-cli ]; then
45+ echo "harper-cli binary present at ~/.cargo/bin/harper-cli"
3846 else
39- echo "RESULT: harper-cli binary NOT present -- full reinstall will run "
47+ echo "harper-cli binary NOT present -- will build from source "
4048 fi
41- - name : Install Harper CLI
49+
50+ - name : Install harper-cli
4251 if : steps.cache-harper.outputs.cache-hit != 'true'
4352 run : cargo install --locked --git https://github.com/Automattic/harper.git harper-cli
53+
4454 - name : Lint docs with Harper
4555 run : |
4656 set -uo pipefail
47- ONLY_RULES=(
48- UseTitleCase
49- RepeatedWords
50- MergeWords
51- ItsContraction
52- )
53- ONLY_ARG="--only $(IFS=,; echo "${ONLY_RULES[*]}")"
54- out="$(mktemp)"
55- total=0
56- bad=0
57- while IFS= read -r -d '' file; do
58- total=$((total+1))
59- echo "::group::$file"
60- if harper-cli lint $ONLY_ARG "$file" 2>&1 | tee -a "$out"; then
61- :
62- else
63- bad=$((bad+1))
64- fi
65- echo "::endgroup::"
66- done < <(
67- find docs src/pages \
68- -type f \( -name "*.md" -o -name "*.mdx" \) \
69- -print0 2>/dev/null
70- )
71- titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true)
72- {
73- echo "### Harper summary"
74- echo "- Files scanned: $total"
75- echo "- Files with issues: $bad"
76- echo "- Heading title case violations: $titlecase"
77- echo ""
78- echo "### Violations by rule"
79- echo '```'
80- grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn || true
81- echo '```'
82- } >> "$GITHUB_STEP_SUMMARY"
83- echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations =="
84- [ "$bad" -eq 0 ] ExpandMemoryShorthands
85- ExpandDirectory
86- AnA
87- NoFrenchSpaces
88- InflectedVerbAfterTo
89- CapitalizePersonalPronouns
90- Dashes
57+
58+ IGNORED_RULES=(
59+ SpellCheck
60+ OrthographicConsistency
61+ ProperNouns
62+ CompaniesProductsAndTrademarks
63+ GoogleNames MicrosoftNames AmazonNames AzureNames MetaNames
64+ LongSentences Hedging FillerWords
65+ ExpandStandardInputAndOutput ExpandTimeShorthands ExpandMemoryShorthands
66+ ExpandDirectory ExpandArgument ExpandParameter ExpandPointer
67+ ExpandDependencies ExpandControl ExpandAlgorithm ExpandAlloc
68+ ExpandDecl ExpandVulnerability
9169 )
9270 IGNORE_ARGS=()
93- for rule in "${IGNORED_RULES[@]}"; do
94- IGNORE_ARGS+=(--ignore "$rule")
95- done
71+ for r in "${IGNORED_RULES[@]}"; do IGNORE_ARGS+=(--ignore "$r"); done
72+
9673 out="$(mktemp)"
9774 total=0
9875 bad=0
@@ -105,21 +82,18 @@ jobs:
10582 bad=$((bad+1))
10683 fi
10784 echo "::endgroup::"
108- done < <(
109- find docs src/pages \
110- -type f \( -name "*.md" -o -name "*.mdx" \) \
111- -print0 2>/dev/null
112- )
85+ done < <(find docs \( -name '*.md' -o -name '*.mdx' \) -print0)
86+
11387 titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true)
11488 {
11589 echo "### Harper summary"
11690 echo "- Files scanned: $total"
11791 echo "- Files with issues: $bad"
118- echo "- Heading title case violations: $titlecase"
92+ echo "- Heading (UseTitleCase) violations: $titlecase"
11993 echo ""
12094 echo "### Violations by rule"
12195 echo '```'
122- grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn || true
96+ grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn
12397 echo '```'
12498 } >> "$GITHUB_STEP_SUMMARY"
12599 echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations =="
0 commit comments