@@ -832,6 +832,8 @@ def run_on_distro(
832832
833833 # Line-ending defense & Windows-safe path preparation
834834 own_temp_file : tempfile .NamedTemporaryFile | None = None
835+ container = None
836+ start_time = time .perf_counter ()
835837 if prepared_script_path is not None :
836838 mount_src = prepared_script_path
837839 else :
@@ -847,35 +849,31 @@ def run_on_distro(
847849 error_message = f"Failed to read/prepare script: { exc } " ,
848850 )
849851
850- safe_mount_src = normalize_host_path_for_docker (mount_src )
851852 try :
852- container_command = _wrap_with_package_setup (command , package_list )
853- except (TypeError , ValueError ) as exc :
854- return SingleResult (
855- distro = distro ,
856- status = DistroStatus .ERROR ,
857- exit_code = None ,
858- duration = 0.0 ,
859- output_snippet = "" ,
860- error_message = str (exc ),
861- )
853+ safe_mount_src = normalize_host_path_for_docker (mount_src )
854+ try :
855+ container_command = _wrap_with_package_setup (command , package_list )
856+ except (TypeError , ValueError ) as exc :
857+ return SingleResult (
858+ distro = distro ,
859+ status = DistroStatus .ERROR ,
860+ exit_code = None ,
861+ duration = 0.0 ,
862+ output_snippet = "" ,
863+ error_message = str (exc ),
864+ )
862865
863- # Security: Strict unprivileged options and read-only mount
864- volumes = {
865- safe_mount_src : {
866- "bind" : "/tmp/target_script.sh" ,
867- "mode" : "ro" ,
866+ # Security: Strict unprivileged options and read-only mount
867+ volumes = {
868+ safe_mount_src : {
869+ "bind" : "/tmp/target_script.sh" ,
870+ "mode" : "ro" ,
871+ }
872+ }
873+ environment = {
874+ "DEBIAN_FRONTEND" : "noninteractive" ,
875+ "CI" : "true" ,
868876 }
869- }
870- environment = {
871- "DEBIAN_FRONTEND" : "noninteractive" ,
872- "CI" : "true" ,
873- }
874-
875- container = None
876- start_time = time .perf_counter ()
877-
878- try :
879877 create_kwargs = {
880878 "image" : distro ,
881879 "command" : container_command ,
@@ -1076,13 +1074,46 @@ def run_matrix(
10761074 except ValueError :
10771075 mode = None
10781076
1077+ distro_list = _normalize_matrix (matrix )
1078+
10791079 abs_script = os .path .abspath (script_path )
1080+ if not os .path .exists (abs_script ):
1081+ return RunReport (
1082+ results = [
1083+ SingleResult (
1084+ distro = d ,
1085+ status = DistroStatus .ERROR ,
1086+ exit_code = None ,
1087+ duration = 0.0 ,
1088+ output_snippet = "" ,
1089+ error_message = f"Target script does not exist: { abs_script } " ,
1090+ )
1091+ for d in distro_list
1092+ ],
1093+ total_duration = 0.0 ,
1094+ all_passed = False ,
1095+ )
1096+ if not os .path .isfile (abs_script ):
1097+ return RunReport (
1098+ results = [
1099+ SingleResult (
1100+ distro = d ,
1101+ status = DistroStatus .ERROR ,
1102+ exit_code = None ,
1103+ duration = 0.0 ,
1104+ output_snippet = "" ,
1105+ error_message = f"Target script path is not a regular file: { abs_script } " ,
1106+ )
1107+ for d in distro_list
1108+ ],
1109+ total_duration = 0.0 ,
1110+ all_passed = False ,
1111+ )
1112+
10801113 parsed_shebang : ShebangParseResult | None = None
10811114 if mode is not None and mode != ShellMode .POSIX :
1082- if os .path .isfile (abs_script ):
1083- parsed_shebang = inspect_shebang (abs_script )
1115+ parsed_shebang = inspect_shebang (abs_script )
10841116
1085- distro_list = _normalize_matrix (matrix )
10861117 if isinstance (packages , (str , bytes )):
10871118 raise ValueError ("packages must be a list of package names" )
10881119 package_list = list (packages or [])
@@ -1102,26 +1133,23 @@ def run_matrix(
11021133
11031134 # Prepare script once for all parallel matrix workers
11041135 shared_temp_file : tempfile .NamedTemporaryFile | None = None
1105- prepared_script : str = abs_script
1106- if os .path .isfile (abs_script ):
1107- try :
1108- prepared_script , shared_temp_file = prepare_script (abs_script )
1109- except Exception as exc :
1110- return RunReport (
1111- results = [
1112- SingleResult (
1113- distro = d ,
1114- status = DistroStatus .ERROR ,
1115- exit_code = None ,
1116- duration = 0.0 ,
1117- output_snippet = "" ,
1118- error_message = f"Failed to read/prepare script: { exc } " ,
1119- )
1120- for d in distro_list
1121- ],
1122- total_duration = 0.0 ,
1123- all_passed = False ,
1124- )
1136+ try :
1137+ prepared_script , shared_temp_file = prepare_script (abs_script )
1138+ except Exception as exc :
1139+ return RunReport (
1140+ results = [
1141+ SingleResult (
1142+ distro = d ,
1143+ status = DistroStatus .ERROR ,
1144+ exit_code = None ,
1145+ duration = 0.0 ,
1146+ output_snippet = "" ,
1147+ error_message = f"Failed to read/prepare script: { exc } " ,
1148+ )
1149+ for d in distro_list
1150+ ],
1151+ total_duration = 0.0 ,
1152+ )
11251153
11261154 start_total = time .perf_counter ()
11271155 results : list [SingleResult ] = [None ] * len (distro_list ) # type: ignore
0 commit comments