diff --git a/scripts/run_performance_job.py b/scripts/run_performance_job.py index e8b955bcac4..7b192cdd904 100644 --- a/scripts/run_performance_job.py +++ b/scripts/run_performance_job.py @@ -157,8 +157,10 @@ def get_pre_commands( ] # Clear the PYTHONPATH first so that modules installed elsewhere are not used + # Note: On Windows, 'set PYTHONPATH=' must be a separate command, not chained with &&, + # otherwise Python fails with "OSError: failed to make path absolute" if os_group == "windows": - install_prerequisites += ["set PYTHONPATH="] + helix_pre_commands += ["set PYTHONPATH="] else: install_prerequisites += ["export PYTHONPATH="] @@ -207,8 +209,15 @@ def get_pre_commands( # Add the install_prerequisites to the pre_commands if os_group == "windows": - # TODO: Should we also give Windows the same treatment as linux and ensure that each command succeeds? - helix_pre_commands += install_prerequisites + # Chain Windows commands with error checking using && to ensure each command succeeds + # If any command fails, set PERF_PREREQS_INSTALL_FAILED and report the error + if install_prerequisites: + combined_prerequisites = " && ".join(install_prerequisites) + helix_pre_commands += [ + 'echo ** Installing prerequisites **', + f'{combined_prerequisites} || set PERF_PREREQS_INSTALL_FAILED=1', + 'if defined PERF_PREREQS_INSTALL_FAILED (echo ** Error: Failed to install prerequisites ** && exit /b 1)' + ] else: if install_prerequisites: combined_prequisites = " && ".join(install_prerequisites) @@ -272,7 +281,13 @@ def get_post_commands(os_group: str, internal: bool, runtime_type: str): helix_post_commands = ["export PYTHONPATH=$ORIGPYPATH"] if internal: - helix_post_commands += ["deactivate"] # deactivate venv + if os_group == "windows": + # Must use 'call' to invoke deactivate.bat, otherwise the batch file + # transfers control to deactivate.bat and never returns, causing the + # EXIT /b %_commandExitCode% at the end of the Helix work item to never run + helix_post_commands += ["call deactivate"] + else: + helix_post_commands += ["deactivate"] # deactivate venv if runtime_type == "wasm" and os_group != "windows": helix_post_commands += [