fix: drop PyYAML dep so verify job pytest passes
CI & Release / Verify documentation (push) Skipped
CI & Release / Verify simulator (push) Skipped
CI & Release / Trivy scan (push) Skipped
CI & Release / Semantic Release (push) Skipped
CI & Release / Verify documentation (pull_request) Successful in 4s
CI & Release / Verify simulator (pull_request) Successful in 11s
CI & Release / Trivy scan (pull_request) Successful in 8s
CI & Release / Semantic Release (pull_request) Skipped

Store doc rules in bin/docs_rules.json (stdlib json). test_check_docs no
longer fails in the simulator job that only installs simulator/requirements.txt.
This commit is contained in:
2026-07-10 11:02:55 +01:00
parent df04736336
commit 826cef0c3e
7 changed files with 61 additions and 72 deletions
-3
View File
@@ -33,9 +33,6 @@ jobs:
- name: Fetch base branch for ADR immutability
run: git fetch --depth=1 origin main
- name: Install checker dependencies
run: pip install --quiet pyyaml
- name: ADR immutability (no edits to accepted records)
run: python bin/check_adrs.py --base origin/main
+3 -10
View File
@@ -4,17 +4,13 @@
from __future__ import annotations
import argparse
import json
import re
import sys
from pathlib import Path
try:
import yaml
except ImportError: # pragma: no cover - stdlib fallback for minimal envs
yaml = None # type: ignore[assignment]
ROOT = Path(__file__).resolve().parents[1]
RULES_PATH = Path(__file__).with_name("docs_rules.yaml")
RULES_PATH = Path(__file__).with_name("docs_rules.json")
LINK_RE = re.compile(r"!?\[[^\]]*\]\(([^)]+)\)")
BARE_SEE_RE = re.compile(r"(?<![\[(/])see\s+(\d{2})(?![\w-])", re.IGNORECASE)
@@ -22,10 +18,7 @@ SKIP_SCHEMES = ("http://", "https://", "mailto:", "tel:", "#")
def load_rules(path: Path = RULES_PATH) -> dict:
text = path.read_text(encoding="utf-8")
if yaml is not None:
return yaml.safe_load(text)
raise RuntimeError("PyYAML is required to load docs_rules.yaml")
return json.loads(path.read_text(encoding="utf-8"))
def slug_heading(text: str) -> str:
+42
View File
@@ -0,0 +1,42 @@
{
"markdown_paths": [
"docs/**/*.md",
"README.md",
"CONTRIBUTING.md",
"AGENTS.md",
"simulator/README.md",
"prototype/README.md",
"infra/**/README.md"
],
"glossary": {
"file": "docs/00-glossary.md"
},
"banned_link_targets": [
"03-storage-design.md"
],
"glossary_section_anchors": [
"data--storage",
"swarm--robotics",
"infrastructure--delivery"
],
"preferred_term_anchors": [
"t0--hot",
"t1--warm",
"t2--shared",
"t3--warehouse",
"t4--dev",
"source-of-truth",
"architecture-layer-1--ingestion",
"architecture-layer-2--storage-and-transform",
"architecture-layer-3--serving-and-sync",
"pipeline-stage",
"bulk-sync",
"offload",
"rclone",
"adr",
"asr"
],
"readability": {
"forbid_bare_see_refs": true
}
}
-47
View File
@@ -1,47 +0,0 @@
# Documentation rules enforced by CI (bin/check_docs.py).
# See docs/improvement/ci-rules.md for rationale and PR workflow.
markdown_paths:
- docs/**/*.md
- README.md
- CONTRIBUTING.md
- AGENTS.md
- simulator/README.md
- prototype/README.md
- infra/**/README.md
glossary:
file: docs/00-glossary.md
# Relative link targets that must never reappear (known regressions).
banned_link_targets:
- 03-storage-design.md
# Glossary links to these section headers are allowed but reported as warnings
# when a term-specific ### anchor exists (see preferred_term_anchors).
glossary_section_anchors:
- data--storage
- swarm--robotics
- infrastructure--delivery
# First-use vocabulary should link to these ### anchors, not section headers.
preferred_term_anchors:
- t0--hot
- t1--warm
- t2--shared
- t3--warehouse
- t4--dev
- source-of-truth
- architecture-layer-1--ingestion
- architecture-layer-2--storage-and-transform
- architecture-layer-3--serving-and-sync
- pipeline-stage
- bulk-sync
- offload
- rclone
- adr
- asr
readability:
# Fail when prose uses bare "see 05" instead of a markdown link.
forbid_bare_see_refs: true
+1 -1
View File
@@ -15,7 +15,7 @@ Issues, PRs, and reviews default to **caveman-full** ([`CONTRIBUTING.md`](../../
## CI automation
Enforced in Gitea Actions (`docs-verify` job). Rules live in [`bin/docs_rules.yaml`](../../bin/docs_rules.yaml); see [ci-rules.md](ci-rules.md).
Enforced in Gitea Actions (`docs-verify` job). Rules live in [`bin/docs_rules.json`](../../bin/docs_rules.json); see [ci-rules.md](ci-rules.md).
Originally tracked in [issue #1](https://git.produktor.io/eSlider/swarm-house/issues/1).
+2 -2
View File
@@ -2,7 +2,7 @@
Automated checks for markdown in this repository. Enforced on every **pull request** and on **push to `main`** (including docs-only pushes that skip the simulator gate).
Implementation: [`bin/check_docs.py`](../../bin/check_docs.py) reads [`bin/docs_rules.yaml`](../../bin/docs_rules.yaml).
Implementation: [`bin/check_docs.py`](../../bin/check_docs.py) reads [`bin/docs_rules.json`](../../bin/docs_rules.json).
Workflow: [`.github/workflows/release.yaml`](../../.github/workflows/release.yaml) job **`Verify documentation`**.
@@ -53,6 +53,6 @@ python bin/check_docs.py --warnings-as-errors # treat section-link warnings as
## Changing rules
1. Edit `bin/docs_rules.yaml` (paths, banned targets, preferred anchors).
1. Edit `bin/docs_rules.json` (paths, banned targets, preferred anchors).
2. Adjust `bin/check_docs.py` only when adding a new rule *type*.
3. Add a row to the table above and mention it in the audit/improvement record if the change is significant.
+13 -9
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import json
import sys
from pathlib import Path
@@ -59,15 +60,18 @@ def test_broken_link_detected(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -
(docs / "bad.md").write_text("See [missing](missing.md).\n")
rules = tmp_path / "bin"
rules.mkdir()
(rules / "docs_rules.yaml").write_text(
"markdown_paths:\n - docs/**/*.md\n"
"glossary:\n file: docs/00-glossary.md\n"
"banned_link_targets: []\n"
"glossary_section_anchors: []\n"
"preferred_term_anchors: []\n"
"readability:\n forbid_bare_see_refs: false\n"
(rules / "docs_rules.json").write_text(
json.dumps(
{
"markdown_paths": ["docs/**/*.md"],
"glossary": {"file": "docs/00-glossary.md"},
"banned_link_targets": [],
"glossary_section_anchors": [],
"preferred_term_anchors": [],
"readability": {"forbid_bare_see_refs": False},
}
)
)
checker = SCRIPTS / "check_docs.py"
monkeypatch.setattr("check_docs.ROOT", tmp_path)
monkeypatch.setattr("check_docs.RULES_PATH", rules / "docs_rules.yaml")
monkeypatch.setattr("check_docs.RULES_PATH", rules / "docs_rules.json")
assert run_checks() == 1