From d4e96c87d40939c8d8a56e1e9dfe9a1f8655d9ea Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Thu, 26 Mar 2026 09:03:05 +0100 Subject: [PATCH] feat: add linting Signed-off-by: Eike Waldt On-behalf-of: SAP --- .custom_wordlist.txt | 0 .github/workflows/linkcheck.yml | 32 +++++++++++++++++++++++++++ .github/workflows/spelling.yml | 39 +++++++++++++++++++++++++++++++++ .github/workflows/woke.yml | 35 +++++++++++++++++++++++++++++ Makefile | 24 +++++++++++++++++++- lychee.toml | 34 ++++++++++++++++++++++++++++ package.json | 7 +++++- pnpm-lock.yaml | 10 +++++++++ requirements.txt | 1 + 9 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 .custom_wordlist.txt create mode 100644 .github/workflows/linkcheck.yml create mode 100644 .github/workflows/spelling.yml create mode 100644 .github/workflows/woke.yml create mode 100644 lychee.toml create mode 100644 requirements.txt diff --git a/.custom_wordlist.txt b/.custom_wordlist.txt new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml new file mode 100644 index 0000000..a577dbf --- /dev/null +++ b/.github/workflows/linkcheck.yml @@ -0,0 +1,32 @@ +name: Link Check + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + linkcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: "22" + cache: "pnpm" + + - name: Install dependencies + run: | + pnpm install + + - name: Run aggregate + run: | + make aggregate + + - name: Run link check + uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0 diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 0000000..7dc023b --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,39 @@ +name: Spelling Check + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + spelling: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: "22" + cache: "pnpm" + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # pin@v6.2.0 + with: + python-version: "3.13" + + - name: Install dependencies + run: | + pnpm install + pip install -r requirements.txt + + - name: Run aggregate + run: | + make aggregate + + - name: Run spelling check + run: | + make spelling diff --git a/.github/workflows/woke.yml b/.github/workflows/woke.yml new file mode 100644 index 0000000..e57805e --- /dev/null +++ b/.github/workflows/woke.yml @@ -0,0 +1,35 @@ +name: Inclusive Language Check + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + woke: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: "22" + cache: "pnpm" + + - name: Install dependencies + run: | + go install github.com/get-woke/woke@latest + pnpm install + + - name: Run aggregate + run: | + make aggregate + + - name: Run inclusive language check + run: | + export PATH=$PATH:$HOME/go/bin + make woke diff --git a/Makefile b/Makefile index 20f5f98..9fdd526 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help run dev build preview aggregate aggregate-dry aggregate-repo test-aggregate-local clean clean-projects clean-aggregated-git test test-unit test-integration +.PHONY: help run dev build preview aggregate aggregate-dry aggregate-repo test-aggregate-local clean clean-projects clean-aggregated-git test test-unit test-integration check spelling linkcheck woke help: @echo "Garden Linux Documentation Hub - Available targets:" @@ -12,6 +12,12 @@ help: @echo " test - Run full test suite" @echo " test-unit - Run unit tests only" @echo "" + @echo " Quality Checks:" + @echo " check - Run all quality checks (spelling, links, inclusive language)" + @echo " spelling - Check spelling with codespell" + @echo " linkcheck - Check links with lychee" + @echo " woke - Check inclusive language with woke" + @echo "" @echo " Documentation Aggregation:" @echo " test-aggregate-local - Test aggregation with local repos (recommended first)" @echo " aggregate - Fetch and aggregate docs from all source repos" @@ -44,6 +50,22 @@ test-unit: install @echo "Running unit tests..." @cd scripts/tests && python3 run_tests.py +# Quality Checks +check: spelling linkcheck woke + @echo "All quality checks passed!" + +spelling: + @echo "Running spelling checks..." + @pnpm run docs:spelling + +linkcheck: install + @echo "Running link checks..." + @pnpm run docs:linkcheck + +woke: install + @echo "Running inclusive language checks..." + @pnpm run docs:woke + # Documentation Aggregation test-aggregate-local: install @echo "Testing aggregation with local repositories..." diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 0000000..84ea75d --- /dev/null +++ b/lychee.toml @@ -0,0 +1,34 @@ +# lychee link checker configuration +# https://lychee.cli.rs/ + +# Exclude patterns +exclude = [ + "^https://github\\.com/.*/edit/", + "^https://github\\.com/.*/new/", + "^mailto:", + "^tel:", + "^javascript:", +] + +# Accept these status codes as valid +accept = [200, 204, 301, 302, 429] + +# Timeout per request (seconds) +timeout = 30 + +# Maximum number of concurrent requests +max_concurrency = 16 + +# Maximum number of retries per request +max_retries = 3 + +# Exclude private/local IPs +exclude_private = true +exclude_loopback = true + +# Skip these file patterns +exclude_path = [ + "node_modules", + "docs/.vitepress/dist", + "docs/.vitepress/cache", +] diff --git a/package.json b/package.json index 966110e..3320c85 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,16 @@ { + "packageManager": "pnpm@10.28.0", "scripts": { "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", - "docs:preview": "vitepress preview docs" + "docs:preview": "vitepress preview docs", + "docs:linkcheck": "lychee \"docs/**/*.md\" --config lychee.toml", + "docs:spelling": "codespell --ignore-words .custom_wordlist.txt docs", + "docs:woke": "woke docs/" }, "dependencies": { "autoprefixer": "10.4.0", + "corepack": "^0.34.6", "gray-matter": "4.0.3", "js-yaml": "4.1.1", "lodash-es": "4.17.23", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3050b90..4639d43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: autoprefixer: specifier: 10.4.0 version: 10.4.0(postcss@8.5.8) + corepack: + specifier: ^0.34.6 + version: 0.34.6 gray-matter: specifier: 4.0.3 version: 4.0.3 @@ -683,6 +686,11 @@ packages: resolution: {integrity: sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA==} engines: {node: '>=18'} + corepack@0.34.6: + resolution: {integrity: sha512-gvylq9kzJB09mSsiOnKOnhg0YdCWNy2aGaeGbYF4HlyGd/v4moxEonQjJPYI45/K4zP7q1hW9qCVvaYYKK5nkA==} + engines: {node: ^20.10.0 || ^22.11.0 || >=24.0.0} + hasBin: true + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -1667,6 +1675,8 @@ snapshots: dependencies: is-what: 5.5.0 + corepack@0.34.6: {} + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7c541de --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +codespell==2.4.2