33from __future__ import annotations
44
55import json
6+ import os
67from pathlib import Path
78import re
89import shlex
@@ -49,24 +50,27 @@ def validate_payload_install(payload_root: Path) -> tuple[Path, ...]:
4950 )
5051
5152
52- def run_bundle_smoke_check (bundle_root : Path ) -> str :
53+ def run_bundle_smoke_check (bundle_root : Path , * , payload_manifest_path : Path | None = None ) -> str :
5354 """Run the vendored bundle smoke check and return its stdout."""
5455 smoke_script = bundle_root / "scripts" / "check-runtime-smoke.sh"
5556 if not smoke_script .is_file ():
5657 raise InstallError (f"Missing bundle smoke script: { smoke_script } " )
5758
5859 command = ["bash" , str (smoke_script )]
60+ env = _build_bundle_smoke_env (payload_manifest_path = payload_manifest_path )
5961 completed = subprocess .run (
6062 command ,
6163 capture_output = True ,
6264 text = True ,
6365 check = False ,
66+ env = env ,
6467 )
6568 if completed .returncode != 0 :
6669 details = _format_smoke_failure_details (
6770 completed = completed ,
6871 command = command ,
6972 smoke_script = smoke_script ,
73+ env = env ,
7074 )
7175 raise InstallError (f"Bundle smoke check failed: { details } " )
7276 return completed .stdout .strip ()
@@ -77,6 +81,7 @@ def _format_smoke_failure_details(
7781 completed : subprocess .CompletedProcess [str ],
7882 command : list [str ],
7983 smoke_script : Path ,
84+ env : dict [str , str ],
8085) -> str :
8186 details = [
8287 f"exit_status={ completed .returncode } " ,
@@ -99,6 +104,7 @@ def _format_smoke_failure_details(
99104 capture_output = True ,
100105 text = True ,
101106 check = False ,
107+ env = env ,
102108 )
103109 details .append (f"debug_exit_status={ debug_completed .returncode } " )
104110 details .append (f"debug_command={ _render_command (debug_command )} " )
@@ -117,6 +123,13 @@ def _format_smoke_failure_details(
117123 return "; " .join (details )
118124
119125
126+ def _build_bundle_smoke_env (* , payload_manifest_path : Path | None ) -> dict [str , str ]:
127+ env = dict (os .environ )
128+ if payload_manifest_path is not None :
129+ env ["SOPIFY_PAYLOAD_MANIFEST" ] = str (payload_manifest_path )
130+ return env
131+
132+
120133def _render_command (command : list [str ]) -> str :
121134 return " " .join (shlex .quote (part ) for part in command )
122135
0 commit comments