From 701922143a7998f997d91cf9a15dd56d2f7ab922 Mon Sep 17 00:00:00 2001 From: Vladyslav Shyrokyi Date: Tue, 27 Jan 2026 13:09:34 +0200 Subject: [PATCH 1/2] refactor(build): improve error handling in build and push commands Enhances the build process by adding error checks for subprocess calls to ensure that failures in building, pushing, or tagging are properly reported and handled, preventing silent failures. --- build_image.py | 8 ++++++-- build_image_pcg_listener.py | 12 +++++++++--- build_image_segment_update_worker.py | 14 ++++++++++---- build_image_web_gpu.py | 12 +++++++++--- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/build_image.py b/build_image.py index 8a6051edb..06ab70ae9 100755 --- a/build_image.py +++ b/build_image.py @@ -48,7 +48,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG_SUFFIX}", args.tag_suffix) @@ -57,7 +59,9 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_pcg_listener.py b/build_image_pcg_listener.py index f0d6c2ab3..a1d6e1956 100755 --- a/build_image_pcg_listener.py +++ b/build_image_pcg_listener.py @@ -22,7 +22,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +32,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag pcg_listener_{args.tag}.") - subprocess.call(f"git tag pcg_listener_{args.tag} && git push origin pcg_listener_{args.tag}", shell=True) + if subprocess.call(f"git tag pcg_listener_{args.tag} && git push origin pcg_listener_{args.tag}", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_segment_update_worker.py b/build_image_segment_update_worker.py index 089239ffb..56f1b8e17 100755 --- a/build_image_segment_update_worker.py +++ b/build_image_segment_update_worker.py @@ -35,7 +35,9 @@ def main(): .replace("{REPO}", args.repo) ) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = ( PUSH_COMMAND_TMPL.replace("{TAG}", args.tag) @@ -44,13 +46,17 @@ def main(): .replace("{REPO}", args.repo) ) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag segment_update_worker_{args.tag}.") - subprocess.call( + if subprocess.call( f"git tag segment_update_worker_{args.tag} && git push origin segment_update_worker_{args.tag}", shell=True, - ) + ) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_web_gpu.py b/build_image_web_gpu.py index d2ae4bea6..edd1db4d3 100755 --- a/build_image_web_gpu.py +++ b/build_image_web_gpu.py @@ -22,7 +22,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +32,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag {args.tag}_gpu.") - subprocess.call(f"git tag {args.tag}_gpu && git push origin {args.tag}_gpu", shell=True) + if subprocess.call(f"git tag {args.tag}_gpu && git push origin {args.tag}_gpu", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": From 319ecac38b7b33a15bea66f6b384c5dad26a57fb Mon Sep 17 00:00:00 2001 From: Vladyslav Shyrokyi Date: Tue, 27 Jan 2026 13:39:50 +0200 Subject: [PATCH 2/2] refactor(build): improve error handling in build and push commands Enhances the build process by adding error checks for subprocess calls to ensure that failures in building, pushing, or tagging are properly reported and handled, preventing silent failures. --- build_image_web.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/build_image_web.py b/build_image_web.py index 491bc9416..f1f06e2a1 100755 --- a/build_image_web.py +++ b/build_image_web.py @@ -22,7 +22,10 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + # Stop if build fails + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +33,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag {args.tag}.") - subprocess.call(f"git tag {args.tag} && git push origin {args.tag}", shell=True) + if subprocess.call(f"git tag {args.tag} && git push origin {args.tag}", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__":