修正 P4 report 直接執行路徑
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-02 15:08:46 +08:00
parent ffbcdc0793
commit c452ebd1c1
2 changed files with 56 additions and 2 deletions

View File

@@ -1,4 +1,7 @@
import json
import subprocess
import sys
import urllib.parse
from pathlib import Path
from scripts.ops import report_source_deploy_runtime_truth as report
@@ -220,3 +223,50 @@ def test_source_override_still_requires_committed_file_confirmation(tmp_path):
assert payload["result"] == "BLOCKED"
assert payload["summary"]["tracked_files_committed"] is False
assert any("uncommitted source-control changes" in error for error in payload["errors"])
def test_script_runs_by_path_when_called_from_outside_repo(tmp_path):
source_root = _write_source_root(tmp_path)
health_payload = urllib.parse.quote(
json.dumps({"status": "healthy", "database": "postgresql", "version": "V10.725"})
)
result = subprocess.run(
[
sys.executable,
str(Path(report.__file__).resolve()),
"--source-root",
str(source_root),
"--health-url",
f"data:application/json,{health_payload}",
"--tracked-file",
"config.py",
"--tracked-file",
"proof.txt",
"--source-head",
LOCAL_HEAD,
"--source-branch",
"main",
"--origin-main",
LOCAL_HEAD,
"--origin-dev",
LOCAL_HEAD,
"--gitea-main",
LOCAL_HEAD,
"--gitea-dev",
LOCAL_HEAD,
"--head-config-version",
"V10.725",
"--tracked-files-committed",
"--json",
],
cwd="/tmp",
check=True,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
payload = json.loads(result.stdout)
assert payload["result"] == "PASS"
assert payload["summary"]["truth_layers_separated"] is True