#!/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" # 本脚本只验证仓库协议;OSS/AI 有独立测试,避免本机其他服务配置阻止启动。 environment["AI_ENABLED"] = "false" environment["OSS_ENABLED"] = "false" raise SystemExit(subprocess.call([ "mvn", "-q", "-Dtest=GiteaLiveTest", "-Dsurefire.failIfNoSpecifiedTests=false", "test" ], cwd=root, env=environment))