fix: адаптировать Makefile и resilience.py для Windows

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
Evgeny Bushkov
2026-11-06 13:53:19 +03:00
co-authored by aider
parent e5dde9ea29
commit 034796cefe
2 changed files with 45 additions and 5 deletions
+22 -2
View File
@@ -2,6 +2,7 @@
"""Explicit operator-authored hook; tokens remain in memory, volumes are never removed by this test."""
import json
import os
import shutil
from pathlib import Path
import subprocess
import time
@@ -10,6 +11,25 @@ from urllib.parse import quote
from client import Client, Failure, LAB, arguments, check, run
def _script_command(full: Path) -> list[str]:
"""Windows не умеет запускать .sh напрямую — вызываем через sh (Git Bash/WSL)."""
if os.name == "nt":
sh = shutil.which("sh") or shutil.which("bash")
if not sh:
raise Failure(
"sh/bash not found in PATH; install Git for Windows or run under WSL"
)
return [sh, str(full)]
return [str(full)]
def _is_executable(full: Path) -> bool:
"""На Windows .sh не имеет executable bit — проверяем через sh."""
if os.name == "nt":
return full.is_file() and (shutil.which("sh") or shutil.which("bash")) is not None
return full.is_file() and os.access(full, os.X_OK)
def history(c, actor, chat):
path = '/api/v1/chats/'+chat['id']+'/messages?limit=100'
result = []
@@ -34,7 +54,7 @@ def main():
check(LAB>=2,'persistence requires lab2+')
check(args.mode!='failover' or LAB>=3,'failover requires lab3+')
script = Path(args.action_script).expanduser().resolve()
check(script.is_file() and os.access(script,os.X_OK),'action script must exist and be executable (chmod +x)')
check(_is_executable(script),'action script must exist and be executable (chmod +x)')
check('.example.' not in script.name,'copy and implement the example hook first')
c = Client(args.base_url,args.ca_file,timeout=2)
alice,bob,eve,chat = c.bootstrap()
@@ -55,7 +75,7 @@ def main():
check(len(observed)>=2,'less than two API instances observed before failure; verify LB/session affinity')
print('Executing explicit '+args.mode+' hook; hook output suppressed to avoid leaking secrets.')
# No shell interpolation and no Docker commands in this test.
proc = subprocess.Popen([str(script)],env=env,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
proc = subprocess.Popen(_script_command(script),env=env,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
started = time.monotonic()
successes,failures,after_instances = [],0,[]
try: