Skip to content

Update and rename harper.yml to docs-quality.yml #1

Update and rename harper.yml to docs-quality.yml

Update and rename harper.yml to docs-quality.yml #1

Workflow file for this run

name: Docs Quality

Check failure on line 1 in .github/workflows/docs-quality.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docs-quality.yml

Invalid workflow file

(Line: 124, Col: 3): 'heading-case' is already defined
on:
pull_request:
workflow_dispatch:
inputs:
allow_failure:
type: boolean
default: false
env:
ALLOW_FAILURE: ${{ github.event_name == 'workflow_dispatch' && inputs.allow_failure }}
jobs:
spelling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cspell
restore-keys: ${{ runner.os }}-npm-cspell-
- run: |
npx --yes cspell@9 lint \
"docs/**/*.{md,mdx}" \
"src/pages/**/*.{md,mdx}" \
--config cspell.json \
--no-progress \
--reporter json \
> cspell-report.json || true
- run: |
python - <<'PY'
import json
import os
import sys
try:
with open("cspell-report.json", encoding="utf-8") as f:
content = f.read().strip()
except FileNotFoundError:
content = ""
if not content:
print("::error::cspell-report.json is empty. Check the previous step's log for the actual cspell error (e.g. missing cspell.json or project-words.txt).")
sys.exit(1)
try:
data = json.loads(content)
except json.JSONDecodeError:
print("::error::cspell-report.json is not valid JSON. Raw output was:")
print(content[:2000])
sys.exit(1)
issues = data.get("issues", [])
for issue in issues:
file = issue.get("uri")
line = issue.get("row")
message = issue.get("message") or f"Unknown word: {issue.get('text')!r}"
print(f"::error file={file},line={line}::{message}")
print(f"{len(issues)} spelling issue(s) found.")
allow_failure = os.environ.get("ALLOW_FAILURE") == "true"
sys.exit(1 if issues and not allow_failure else 0)
PY
heading-case:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: |
python check_heading_case.py docs src/pages || {
if [ "$ALLOW_FAILURE" = "true" ]; then
exit 0
fi
exit 1
} with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-harper
restore-keys: ${{ runner.os }}-cargo-harper
- run: |
command -v harper-cli >/dev/null 2>&1 || \
cargo install --git https://github.com/Automattic/harper \
--tag v2.1.0 \
harper-cli --locked
- run: |
find docs src/pages -type f \( -name "*.md" -o -name "*.mdx" \) -print0 | \
xargs -0 harper-cli lint --format json > harper-report.json || true
- run: |
python - <<'PY'
import json
import os
import sys
with open("harper-report.json", encoding="utf-8") as f:
reports = json.load(f)
ALLOWED_KINDS = {"Grammar", "Repetition"}
issues = []
for report in reports:
file = report.get("file")
for lint in report.get("lints", []):
if lint.get("kind") not in ALLOWED_KINDS:
continue
line = lint.get("line")
message = lint.get("message")
print(f"::error file={file},line={line}::{message}")
issues.append(lint)
print(f"{len(issues)} grammar/repetition issue(s) found.")
allow_failure = os.environ.get("ALLOW_FAILURE") == "true"
sys.exit(1 if issues and not allow_failure else 0)
PY
heading-case:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: |
python check_heading_case.py docs src/pages || {
if [ "$ALLOW_FAILURE" = "true" ]; then
exit 0
fi
exit 1
}