Skip to content

Commit afb553e

Browse files
authored
Update docs-quality.yml
1 parent 28d8a7e commit afb553e

1 file changed

Lines changed: 47 additions & 46 deletions

File tree

.github/workflows/docs-quality.yml

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,95 @@
11
name: Docs Quality
2+
23
on:
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+
517
jobs:
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
1728
continue-on-error: true
1829
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v6
21-
- name: Restore Harper CLI cache
30+
- uses: actions/checkout@v4
31+
32+
- name: Cache harper-cli binary
2233
id: cache-harper
23-
uses: actions/cache/restore@v4
34+
uses: actions/cache@v4
2435
with:
25-
path: |
26-
~/.cargo/bin/harper-cli
27-
~/.cargo/registry
28-
~/.cargo/git
29-
key: ${{ runner.os }}-harper-cli
36+
path: ~/.cargo/bin/harper-cli
37+
key: harper-cli-${{ runner.os }}-v1
3038
restore-keys: |
31-
${{ runner.os }}-harper-cli
39+
harper-cli-${{ runner.os }}-
3240
- name: Report cache status
3341
run: |
3442
echo "cache-hit output: '${{ steps.cache-harper.outputs.cache-hit }}'"
35-
ls -la ~/.cargo/bin/ 2>&1 || echo "~/.cargo/bin does not exist"
36-
if [ -x ~/.cargo/bin/harper-cli ]; then
37-
echo "RESULT: harper-cli binary present and executable"
38-
~/.cargo/bin/harper-cli --version || true
43+
if [ -f ~/.cargo/bin/harper-cli ]; then
44+
echo "harper-cli binary present at ~/.cargo/bin/harper-cli"
3945
else
40-
echo "RESULT: harper-cli binary NOT present -- full reinstall will run"
46+
echo "harper-cli binary NOT present -- will build from source"
4147
fi
42-
- name: Install Harper CLI
48+
- name: Install harper-cli
4349
if: steps.cache-harper.outputs.cache-hit != 'true'
4450
run: cargo install --locked --git https://github.com/Automattic/harper.git harper-cli
51+
4552
- name: Lint docs with Harper
4653
run: |
4754
set -uo pipefail
48-
ONLY_RULES=(
49-
UseTitleCase
50-
RepeatedWords
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
5166
)
52-
ONLY_ARG="--only $(IFS=,; echo "${ONLY_RULES[*]}")"
67+
IGNORE_ARGS=()
68+
for r in "${IGNORED_RULES[@]}"; do IGNORE_ARGS+=(--ignore "$r"); done
5369
out="$(mktemp)"
5470
total=0
5571
bad=0
5672
while IFS= read -r -d '' file; do
5773
total=$((total+1))
5874
echo "::group::$file"
59-
if harper_out="$(harper-cli lint $ONLY_ARG "$file" 2>&1)"; then
60-
echo "no issues"
75+
if harper-cli lint "${IGNORE_ARGS[@]}" "$file" 2>&1 | tee -a "$out"; then
76+
:
6177
else
6278
bad=$((bad+1))
63-
echo "$harper_out"
64-
echo "$harper_out" >> "$out"
6579
fi
6680
echo "::endgroup::"
67-
done < <(
68-
find docs src/pages \
69-
-type f \( -name "*.md" -o -name "*.mdx" \) \
70-
-print0 2>/dev/null
71-
)
81+
done < <(find docs \( -name '*.md' -o -name '*.mdx' \) -print0)
82+
titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true)
7283
{
7384
echo "### Harper summary"
7485
echo "- Files scanned: $total"
7586
echo "- Files with issues: $bad"
87+
echo "- Heading (UseTitleCase) violations: $titlecase"
7688
echo ""
7789
echo "### Violations by rule"
7890
echo '```'
79-
grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn || true
91+
grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn
8092
echo '```'
8193
} >> "$GITHUB_STEP_SUMMARY"
82-
83-
echo "== Harper: $bad/$total files with issues =="
94+
echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations =="
8495
[ "$bad" -eq 0 ]
85-
86-
- name: Save Harper CLI cache
87-
if: always() && steps.cache-harper.outputs.cache-hit != 'true'
88-
uses: actions/cache/save@v4
89-
with:
90-
path: |
91-
~/.cargo/bin/harper-cli
92-
~/.cargo/registry
93-
~/.cargo/git
94-
key: ${{ runner.os }}-harper-cli

0 commit comments

Comments
 (0)