Files
community/scripts/test-gitea.py
T
2026-10-14 10:26:20 +08:00

25 lines
887 B
Python

#!/usr/bin/env python3
"""在临时 H2 数据库运行真实 Gitea 测试,清理本次创建的临时仓库。"""
import os
from pathlib import Path
import shlex
import subprocess
root = Path(__file__).resolve().parent.parent
environment = os.environ.copy()
config = root / ".env"
if config.exists():
for line in config.read_text().splitlines():
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
parsed = shlex.split(value)
if parsed:
environment[key] = parsed[0]
if not environment.get("GITEA_TOKEN"):
raise SystemExit("请先配置 GITEA_TOKEN 和 GITEA_ORGANIZATION")
environment["COMMUNITY_LIVE_GITEA"] = "true"
raise SystemExit(subprocess.call([
"mvn", "-q", "-Dtest=GiteaLiveTest", "-Dsurefire.failIfNoSpecifiedTests=false", "test"
], cwd=root, env=environment))