Harper #31
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs Quality | |
| on: | |
| pull_request: | |
| paths: | |
| - "docs/**/*.md" | |
| - "docs/**/*.mdx" | |
| - "_typos.toml" | |
| - ".github/workflows/docs-quality.yml" | |
| push: | |
| branches: [main] | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| jobs: | |
| typos: | |
| name: Spelling (typos-cli) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: crate-ci/typos@master | |
| harper: | |
| name: Grammar & headings (Harper) | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache harper-cli binary | |
| id: cache-harper | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/bin/harper-cli | |
| key: harper-cli-${{ runner.os }}-v1 | |
| restore-keys: | | |
| harper-cli-${{ runner.os }}- | |
| - name: Report cache status | |
| run: | | |
| echo "cache-hit output: '${{ steps.cache-harper.outputs.cache-hit }}'" | |
| if [ -f ~/.cargo/bin/harper-cli ]; then | |
| echo "harper-cli binary present at ~/.cargo/bin/harper-cli" | |
| else | |
| echo "harper-cli binary NOT present -- will build from source" | |
| 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 | |
| GoogleNames MicrosoftNames AmazonNames AzureNames MetaNames | |
| LongSentences Hedging FillerWords | |
| ExpandStandardInputAndOutput ExpandTimeShorthands ExpandMemoryShorthands | |
| ExpandDirectory ExpandArgument ExpandParameter ExpandPointer | |
| ExpandDependencies ExpandControl ExpandAlgorithm ExpandAlloc | |
| ExpandDecl ExpandVulnerability | |
| ) | |
| IGNORE_ARGS=() | |
| for r in "${IGNORED_RULES[@]}"; do IGNORE_ARGS+=(--ignore "$r"); 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 \( -name '*.md' -o -name '*.mdx' \) -print0) | |
| titlecase=$(grep -c 'Capitalization::UseTitleCase' "$out" || true) | |
| { | |
| echo "### Harper summary" | |
| echo "- Files scanned: $total" | |
| echo "- Files with issues: $bad" | |
| echo "- Heading (UseTitleCase) violations: $titlecase" | |
| echo "" | |
| echo "### Violations by rule" | |
| echo '```' | |
| grep -oE '\[[A-Za-z]+::[A-Za-z]+\]' "$out" | sort | uniq -c | sort -rn | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| echo "== Harper: $bad/$total files with issues; $titlecase UseTitleCase violations ==" | |
| [ "$bad" -eq 0 ] |