Skip to content

Commit 5a9209f

Browse files
authored
Update docs-quality.yml
1 parent afb553e commit 5a9209f

1 file changed

Lines changed: 73 additions & 42 deletions

File tree

.github/workflows/docs-quality.yml

Lines changed: 73 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,98 @@
11
name: Docs Quality
2-
32
on:
43
pull_request:
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-
4+
workflow_dispatch:
175
jobs:
186
typos:
197
name: Spelling (typos-cli)
208
runs-on: ubuntu-latest
219
steps:
22-
- uses: actions/checkout@v4
10+
- name: Checkout
11+
uses: actions/checkout@v6
2312
- uses: crate-ci/typos@master
2413

2514
harper:
26-
name: Grammar & headings (Harper)
15+
name: Grammar and Style Check
2716
runs-on: ubuntu-latest
28-
continue-on-error: true
2917
steps:
30-
- uses: actions/checkout@v4
31-
32-
- name: Cache harper-cli binary
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
- name: Cache Harper CLI
3321
id: cache-harper
3422
uses: actions/cache@v4
3523
with:
36-
path: ~/.cargo/bin/harper-cli
37-
key: harper-cli-${{ runner.os }}-v1
24+
path: |
25+
~/.cargo/bin/harper-cli
26+
~/.cargo/registry
27+
~/.cargo/git
28+
key: ${{ runner.os }}-harper-cli
3829
restore-keys: |
39-
harper-cli-${{ runner.os }}-
30+
${{ runner.os }}-harper-cli
4031
- name: Report cache status
4132
run: |
4233
echo "cache-hit output: '${{ steps.cache-harper.outputs.cache-hit }}'"
43-
if [ -f ~/.cargo/bin/harper-cli ]; then
44-
echo "harper-cli binary present at ~/.cargo/bin/harper-cli"
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
4538
else
46-
echo "harper-cli binary NOT present -- will build from source"
39+
echo "RESULT: harper-cli binary NOT present -- full reinstall will run"
4740
fi
48-
- name: Install harper-cli
41+
- name: Install Harper CLI
4942
if: steps.cache-harper.outputs.cache-hit != 'true'
5043
run: cargo install --locked --git https://github.com/Automattic/harper.git harper-cli
51-
5244
- name: Lint docs with Harper
5345
run: |
5446
set -uo pipefail
55-
IGNORED_RULES=(
56-
SpellCheck
57-
OrthographicConsistency
58-
ProperNouns
59-
CompaniesProductsAndTrademarks
60-
GoogleNames MicrosoftNames AmazonNames AzureNames MetaNames
61-
LongSentences Hedging FillerWords
62-
ExpandStandardInputAndOutput ExpandTimeShorthands ExpandMemoryShorthands
63-
ExpandDirectory ExpandArgument ExpandParameter ExpandPointer
64-
ExpandDependencies ExpandControl ExpandAlgorithm ExpandAlloc
65-
ExpandDecl ExpandVulnerability
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
6691
)
6792
IGNORE_ARGS=()
68-
for r in "${IGNORED_RULES[@]}"; do IGNORE_ARGS+=(--ignore "$r"); done
93+
for rule in "${IGNORED_RULES[@]}"; do
94+
IGNORE_ARGS+=(--ignore "$rule")
95+
done
6996
out="$(mktemp)"
7097
total=0
7198
bad=0
@@ -78,17 +105,21 @@ jobs:
78105
bad=$((bad+1))
79106
fi
80107
echo "::endgroup::"
81-
done < <(find docs \( -name '*.md' -o -name '*.mdx' \) -print0)
108+
done < <(
109+
find docs src/pages \
110+
-type f \( -name "*.md" -o -name "*.mdx" \) \
111+
-print0 2>/dev/null
112+
)
82113
titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true)
83114
{
84115
echo "### Harper summary"
85116
echo "- Files scanned: $total"
86117
echo "- Files with issues: $bad"
87-
echo "- Heading (UseTitleCase) violations: $titlecase"
118+
echo "- Heading title case violations: $titlecase"
88119
echo ""
89120
echo "### Violations by rule"
90121
echo '```'
91-
grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn
122+
grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn || true
92123
echo '```'
93124
} >> "$GITHUB_STEP_SUMMARY"
94125
echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations =="

0 commit comments

Comments
 (0)