@@ -59,11 +59,26 @@ def __init__(self):
5959 self .docker_client = docker .from_env ()
6060 self .server_process = None
6161 self .containers_started = []
62+ self .is_github_actions = self ._detect_github_actions ()
63+
64+ def _detect_github_actions (self ) -> bool :
65+ """Detect if running in GitHub Actions environment"""
66+ return (
67+ os .getenv ("GITHUB_ACTIONS" ) == "true" or
68+ os .getenv ("CI" ) == "true" or
69+ os .getenv ("RUNNER_OS" ) is not None
70+ )
6271
6372 def start_dependencies (self ):
6473 """Start PostgreSQL and Redis using Docker"""
6574 print ("Starting test dependencies..." )
6675
76+ # Skip Docker container creation in GitHub Actions since services are provided
77+ if self .is_github_actions :
78+ print ("Detected GitHub Actions environment - using provided services" )
79+ self ._wait_for_dependencies ()
80+ return
81+
6782 # Start PostgreSQL
6883 try :
6984 postgres_container = self .docker_client .containers .run (
@@ -198,12 +213,16 @@ def stop_server(self):
198213 self .server_process .wait ()
199214 print ("Server stopped" )
200215
201- for container in self .containers_started :
202- try :
203- container .stop ()
204- print (f"Stopped container: { container .id [:12 ]} " )
205- except docker .errors .NotFound :
206- pass
216+ # Only stop containers if we started them (not in GitHub Actions)
217+ if not self .is_github_actions :
218+ for container in self .containers_started :
219+ try :
220+ container .stop ()
221+ print (f"Stopped container: { container .id [:12 ]} " )
222+ except docker .errors .NotFound :
223+ pass
224+ else :
225+ print ("Skipping container cleanup in GitHub Actions environment" )
207226
208227 def is_server_running (self ) -> bool :
209228 """Check if the server is running"""
0 commit comments