Skip to content
Snippets Groups Projects
Commit 11047d57 authored by Hans Fangohr's avatar Hans Fangohr
Browse files

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.
parent b2caebe8
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!9force `subprocess.run` to check return code is 0
Pipeline #367982 failed
This commit is part of merge request !9. Comments created here will be created in the context of that merge request.
...@@ -89,6 +89,7 @@ def setup_log_cmd( ...@@ -89,6 +89,7 @@ def setup_log_cmd(
subprocess.run( subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], ["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
check=True,
) )
.stdout.decode() .stdout.decode()
.strip() .strip()
...@@ -97,6 +98,7 @@ def setup_log_cmd( ...@@ -97,6 +98,7 @@ def setup_log_cmd(
subprocess.run( subprocess.run(
["git", "rev-parse", "--short", "HEAD"], ["git", "rev-parse", "--short", "HEAD"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
check=True,
) )
.stdout.decode() .stdout.decode()
.strip() .strip()
...@@ -142,19 +144,20 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None: ...@@ -142,19 +144,20 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None:
"git", "git",
"clone", "clone",
config_vars["spack_environments_repo"], config_vars["spack_environments_repo"],
] ],
check=True,
) )
with os_chdir("spack-environments"): with os_chdir("spack-environments"):
# Git fetch and checkout the release branch and git pull # Git fetch and checkout the release branch and git pull
# to be sure that the resulting repo is up to date # to be sure that the resulting repo is up to date
subprocess.run(["git", "fetch", "--all"]) subprocess.run(["git", "fetch", "--all"], check=True)
checkout_result = subprocess.run(["git", "checkout", mpsd_release]) checkout_result = subprocess.run(["git", "checkout", mpsd_release])
if checkout_result.returncode != 0: if checkout_result.returncode != 0:
raise Exception( raise Exception(
"Release branch does not exist in spack-environment repo \n." "Release branch does not exist in spack-environment repo \n."
"Check for typos." "Check for typos."
) )
subprocess.run(["git", "pull"]) subprocess.run(["git", "pull"], check=True)
def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, List[str]]: def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, List[str]]:
...@@ -186,13 +189,17 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis ...@@ -186,13 +189,17 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis
with os_chdir("spack-environments"): with os_chdir("spack-environments"):
# Get the branch and commit hash of the spack-environments repo # Get the branch and commit hash of the spack-environments repo
spe_commit_hash = ( spe_commit_hash = (
subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE) subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True
)
.stdout.decode() .stdout.decode()
.strip() .strip()
) )
spe_branch = ( spe_branch = (
subprocess.run( subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE ["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
check=True,
) )
.stdout.decode() .stdout.decode()
.strip() .strip()
...@@ -331,6 +338,7 @@ def install_environment( ...@@ -331,6 +338,7 @@ def install_environment(
f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 " f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 "
f"| tee -a {install_log_file} ", f"| tee -a {install_log_file} ",
shell=True, shell=True,
check=True,
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment