phase 5 part 4: java-spring awareness, k8s basics with validated manifests, run_examples supports single-file Java

This commit is contained in:
Shikui Wang committed 2026-10-23 16:42:04 +08:00
1 parent 075872e31e
commit f695bbd7cc
18 files changed
+1192 -23

No files matched your search

+8 -1
View File
@@ -4,6 +4,7 @@
- Go:含 go.mod 的目录执行 `go vet ./... && go test ./...`
- Python:*.py 直接运行(文件开头可写 `# requires: 包1, 包2`,缺包时跳过);test_*.py 用 pytest 运行
- TypeScript:*.ts 用 Node.js 直接运行(需要 Node 23.6+ 的类型剥离,推荐 Node 24 LTS)
- Java:*.java 用 `java 文件名.java` 单文件运行(需要 JDK 21+;可用环境变量 JAVA 指定 java 可执行文件)
- 文件开头写 `# 不自动运行` / `// 不自动运行` 的跳过(需要外部服务的示例)
- 运行时设置环境变量 `RUN_EXAMPLES=1`:会长期运行的服务(如 MCP stdio 服务)据此只做导入检查、不启动
@@ -56,7 +57,7 @@ def main() -> int:
targets = [ex] if ex.is_file() else sorted(ex.rglob("*"))
for f in targets:
frel = f.relative_to(ROOT).as_posix()
if f.suffix not in (".py", ".ts") or "node_modules" in f.parts:
if f.suffix not in (".py", ".ts", ".java") or "node_modules" in f.parts:
continue
head = f.read_text(encoding="utf-8")[:400]
if "不自动运行" in head:
@@ -72,6 +73,12 @@ def main() -> int:
cmd = [sys.executable, "-m", "pytest", "-q", f.name] if f.name.startswith("test_") \
else [sys.executable, f.name]
ok, out = run(cmd, f.parent)
elif f.suffix == ".java":
java = os.environ.get("JAVA") or shutil.which("java")
if not java:
results.append(("SKIP", frel, "没有安装 JDK"))
continue
ok, out = run([java, f.name], f.parent)
else:
if not has_node:
results.append(("SKIP", frel, "需要 Node 23.6+"))