mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 01:39:51 +08:00
* docs: document deployment and add maintenance checks Add Cloudflare build, deployment, and rollback steps, check locale pairs and Markdown before commits, and report unused public asset candidates. Refs #2942. * docs: add a Wrangler configuration example 部署手册说明如何从现有 Worker 补齐样板,并核对域名、路由和绑定。 验证:TOML 解析、文档源检查、6 项文档测试和变更文件的 pre-commit 检查通过。 * ci: check the live docs surface on public docs PRs 按路径筛选目标为 feat/public-docs 的 PR,程序或快照变更时校验真实 CLI/API,纯文案跳过运行时依赖。 验证:实测 CLI 与文案分流、命令改名时旧快照失败、重新导出后通过。6 项文档测试和变更文件的 pre-commit 检查通过。 * ci: add a local docs preflight and reuse the surface filters 新增本地检查入口和中文流程说明。允许主动刷新命令清单或构建站点,本地和 CI 共用路径规则,构建后单独校验产物链接。 验证:模拟 CLI 改名和纯文案改动,验证旧示例失败、修复后 6 项测试通过。正常构建通过,坏链接返回 1 并报告具体路径。变更文件的 pre-commit 检查通过。 * docs: keep the preflight instructions in the existing README * docs: explain how to trigger the first fork preview
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
"""Check the working tree before pushing a docs or CLI/API change."""
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def surface_inputs_changed(base: str) -> bool:
|
|
patterns = json.loads((ROOT / ".github/docs-surface-paths.json").read_text())["surface"]
|
|
# Compare the working tree with the fork point, including committed branch edits.
|
|
ancestor = subprocess.check_output(
|
|
["git", "merge-base", base, "HEAD"], cwd=ROOT, text=True
|
|
).strip()
|
|
diff = ["git", "diff", "--no-renames", "--name-only", "-z", ancestor, "--", *patterns]
|
|
untracked = ["git", "ls-files", "--others", "--exclude-standard", "-z", "--", *patterns]
|
|
return bool(
|
|
subprocess.check_output(diff, cwd=ROOT) or subprocess.check_output(untracked, cwd=ROOT)
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument(
|
|
"--base", default="HEAD", help="include commits since this ref (default: HEAD)"
|
|
)
|
|
parser.add_argument(
|
|
"--update-surface",
|
|
action="store_true",
|
|
help="regenerate the CLI/API snapshot before checking pages",
|
|
)
|
|
parser.add_argument(
|
|
"--build", action="store_true", help="also build the site and check its links"
|
|
)
|
|
args = parser.parse_args()
|
|
python = sys.executable
|
|
if args.update_surface or surface_inputs_changed(args.base):
|
|
export = [python, "scripts/export_docs_surface.py"]
|
|
if not args.update_surface:
|
|
export.append("--check")
|
|
subprocess.run(export, cwd=ROOT, check=True)
|
|
else:
|
|
print(
|
|
f"No CLI/API inputs changed relative to {args.base}. Skipping live export.", flush=True
|
|
)
|
|
|
|
subprocess.run([python, "docs/scripts/check_docs.py"], cwd=ROOT, check=True)
|
|
subprocess.run([python, "-m", "pytest", "-q", "docs/tests"], cwd=ROOT, check=True)
|
|
if args.build:
|
|
subprocess.run(
|
|
["npm.cmd" if sys.platform == "win32" else "npm", "run", "build"],
|
|
cwd=ROOT / "docs",
|
|
check=True,
|
|
)
|
|
subprocess.run([python, "docs/scripts/check_docs.py", "links"], cwd=ROOT, check=True)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
sys.exit(main())
|
|
except subprocess.CalledProcessError as error:
|
|
sys.exit(error.returncode)
|