Skip to content

Harper

Harper #17

Workflow file for this run

name: Docs Quality
on:
pull_request:
workflow_dispatch:
jobs:
typos:
name: Spelling (typos-cli)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: crate-ci/typos@master
harper:
name: Grammar and Style Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache Harper CLI
id: cache-harper
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/harper-cli
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-harper-cli
restore-keys: |
${{ runner.os }}-harper-cli
- name: Report cache status
run: |
echo "cache-hit output: '${{ steps.cache-harper.outputs.cache-hit }}'"
ls -la ~/.cargo/bin/ 2>&1 || echo "~/.cargo/bin does not exist"
if [ -x ~/.cargo/bin/harper-cli ]; then
echo "RESULT: harper-cli binary present and executable"
~/.cargo/bin/harper-cli --version || true
else
echo "RESULT: harper-cli binary NOT present -- full reinstall will run"
fi
- name: Install Harper CLI
if: steps.cache-harper.outputs.cache-hit != 'true'
run: cargo install --locked --git https://github.com/Automattic/harper.git harper-cli
- name: Lint docs with Harper
run: |
set -uo pipefail
IGNORED_RULES=(
SpellCheck
OrthographicConsistency
ProperNouns
CompaniesProductsAndTrademarks
OkToOkay
DisjointPrefixes
LongSentences
Hedging
FillerWords
EllipsisLength
SentenceCapitalization
Spaces
SplitWords
MassNouns
ExpandMemoryShorthands
ExpandDirectory
AnA
NoFrenchSpaces
InflectedVerbAfterTo
CapitalizePersonalPronouns
Dashes
)
IGNORE_ARGS=()
for rule in "${IGNORED_RULES[@]}"; do
IGNORE_ARGS+=(--ignore "$rule")
done
out="$(mktemp)"
total=0
bad=0
while IFS= read -r -d '' file; do
total=$((total+1))
echo "::group::$file"
if harper-cli lint "${IGNORE_ARGS[@]}" "$file" 2>&1 | tee -a "$out"; then
:
else
bad=$((bad+1))
fi
echo "::endgroup::"
done < <(
find docs src/pages \
-type f \( -name "*.md" -o -name "*.mdx" \) \
-print0 2>/dev/null
)
titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true)
{
echo "### Harper summary"
echo "- Files scanned: $total"
echo "- Files with issues: $bad"
echo "- Heading title case violations: $titlecase"
echo ""
echo "### Violations by rule"
echo '```'
grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn || true
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations =="
[ "$bad" -eq 0 ]