From ea608ba6ed93d6eedd6bf2f35fa8ec0c9760f663 Mon Sep 17 00:00:00 2001
From: Hans Fangohr <hans.fangohr@mpsd.mpg.de>
Date: Fri, 26 May 2023 15:36:37 +0200
Subject: [PATCH] force `subprocess.run` to check return code is 0

In general, this should help to capture unintentional errors

Tests fail now, not clear why yet.
---
 mpsd-software-environment.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py
index 02982e8..ac3019f 100755
--- a/mpsd-software-environment.py
+++ b/mpsd-software-environment.py
@@ -193,6 +193,7 @@ def setup_log_cmd(
                         run(
                             ["git", "rev-parse", "--abbrev-ref", "HEAD"],
                             stdout=subprocess.PIPE,
+                            check=True,
                         )
                         .stdout.decode()
                         .strip()
@@ -201,6 +202,7 @@ def setup_log_cmd(
                         run(
                             ["git", "rev-parse", "--short", "HEAD"],
                             stdout=subprocess.PIPE,
+                            check=True,
                         )
                         .stdout.decode()
                         .strip()
@@ -250,7 +252,8 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None:
                     "git",
                     "clone",
                     config_vars["spack_environments_repo"],
-                ]
+                ],
+                check=True,
             )
         with os_chdir("spack-environments"):
             # Git fetch and checkout the release branch and git pull
@@ -460,6 +463,7 @@ def install_environment(
                 f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 "
                 f"| tee -a {install_log_file} ",
                 shell=True,
+                check=True,
             )
 
 
-- 
GitLab