build: add reproducible markdown link gate
This commit is contained in:
5
Makefile
5
Makefile
@@ -1,6 +1,6 @@
|
||||
GO ?= go
|
||||
|
||||
.PHONY: fmt test vet build integration mysql-replication mysql-compatibility sdk-check protocol-check schedule-backlog
|
||||
.PHONY: fmt test vet build integration mysql-replication mysql-compatibility sdk-check protocol-check docs-check schedule-backlog
|
||||
fmt:
|
||||
$(GO) fmt ./...
|
||||
cd sdk/go && $(GO) fmt ./...
|
||||
@@ -41,6 +41,9 @@ sdk-check:
|
||||
protocol-check:
|
||||
./scripts/test-protocol-compatibility.sh
|
||||
|
||||
docs-check:
|
||||
./scripts/check-doc-links.sh
|
||||
|
||||
# Runs the bounded, intentionally incomplete persistent backlog rehearsal in an isolated MySQL.
|
||||
schedule-backlog:
|
||||
./scripts/test-schedule-backlog.sh
|
||||
|
||||
@@ -74,6 +74,7 @@ make vet
|
||||
make build
|
||||
make integration
|
||||
make protocol-check
|
||||
make docs-check
|
||||
```
|
||||
|
||||
首版发布前按[交付核对清单](docs/release-checklist.md)逐项留存命令输出和目标环境证据;当前阶段回归不替代生产拓扑、容量、复制切换或 RPO/RTO 验收。
|
||||
|
||||
34
scripts/check-doc-links.sh
Executable file
34
scripts/check-doc-links.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# Verify that local Markdown links resolve inside the repository.
|
||||
set -eu
|
||||
|
||||
TASK_ROOT=${ORBIT_ROOT_DIR:-.}
|
||||
python3 - "$TASK_ROOT" <<'PY'
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(sys.argv[1]).resolve()
|
||||
missing = []
|
||||
files = 0
|
||||
for path in root.rglob("*.md"):
|
||||
if ".git" in path.parts or "bin" in path.parts:
|
||||
continue
|
||||
files += 1
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for raw in re.findall(r"\]\(([^)]+)\)", text):
|
||||
target = raw.strip()
|
||||
if target.startswith("<") and target.endswith(">"):
|
||||
target = target[1:-1]
|
||||
target = target.split("#", 1)[0].split("?", 1)[0]
|
||||
if not target or "://" in target or target.startswith(("mailto:", "/")):
|
||||
continue
|
||||
if not (path.parent / target).exists():
|
||||
missing.append(f"{path.relative_to(root)}: {raw}")
|
||||
|
||||
if missing:
|
||||
print("unresolved local Markdown links:", file=sys.stderr)
|
||||
print("\n".join(missing), file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
print(f'{{"markdown_files":{files},"local_links":"resolved"}}')
|
||||
PY
|
||||
Reference in New Issue
Block a user