From 5b16c03c930959c34fe1cabb25f4465a3b175b62 Mon Sep 17 00:00:00 2001 From: ANSHIKATYAGI30 Date: Thu, 11 Jun 2026 15:14:11 +0530 Subject: [PATCH 1/2] fix-IO-robustness --- scripts/select_tests.py | 42 +++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/select_tests.py b/scripts/select_tests.py index aeaf20052..3ff625e7d 100755 --- a/scripts/select_tests.py +++ b/scripts/select_tests.py @@ -6,25 +6,40 @@ def get_changed_files(): - """ - Attempts to detect changed files using git diff. - """ base_ref = os.environ.get("GITHUB_BASE_REF", "main") - # Commands to try in order of preference + commands = [ ["git", "diff", "--name-only", f"origin/{base_ref}...HEAD"], ["git", "diff", "--name-only", f"{base_ref}...HEAD"], ["git", "diff", "--name-only", "HEAD~1"], ["git", "diff", "--name-only"], ] + + had_error = False + for cmd in commands: try: - res = subprocess.run(cmd, capture_output=True, text=True, check=True) - files = [line.strip() for line in res.stdout.splitlines() if line.strip()] - if files: - return files - except Exception: - continue + res = subprocess.run( + cmd, + capture_output=True, + text=True, + check=True, + ) + + files = [ + line.strip() + for line in res.stdout.splitlines() + if line.strip() + ] + + return files + + except subprocess.CalledProcessError: + had_error = True + + if had_error: + print("Warning: Unable to determine changed files.") + return [] @@ -108,7 +123,10 @@ def select_tests(files, event_name="push"): - Still run full suite for shared config changes """ if not files: - # Empty file list: fall back to running full suite to be safe + print( + "Warning: No changed files detected. " + "Running full test suite as a safety fallback." + ) return True, True # CRITICAL: For pull requests, always run full suite @@ -151,7 +169,7 @@ def write_outputs(run_backend, run_frontend): frontend_str = "true" if run_frontend else "false" if output_file: - with open(output_file, "a") as f: + with open(output_file, "a", encoding="utf-8") as f: f.write(f"run_backend={backend_str}\n") f.write(f"run_frontend={frontend_str}\n") print( From 514d2a1f87021489234069a23cb0325d7b23d1b7 Mon Sep 17 00:00:00 2001 From: ANSHIKATYAGI30 Date: Thu, 11 Jun 2026 15:20:51 +0530 Subject: [PATCH 2/2] fix-IO-robustness --- scripts/select_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/select_tests.py b/scripts/select_tests.py index 3ff625e7d..9a042db26 100755 --- a/scripts/select_tests.py +++ b/scripts/select_tests.py @@ -4,7 +4,6 @@ import argparse import subprocess - def get_changed_files(): base_ref = os.environ.get("GITHUB_BASE_REF", "main") @@ -122,6 +121,7 @@ def select_tests(files, event_name="push"): - Skip tests for docs-only changes - Still run full suite for shared config changes """ + #Added a warning message when no changed files are detected before falling back to the full test suite. if not files: print( "Warning: No changed files detected. "