Skip to content
Snippets Groups Projects
Commit 399a6f14 authored by Axel Naumann's avatar Axel Naumann
Browse files

[ci] Print docker invocation; whitespace:

dedent does not work because {log} is not indented.
parent a99fdf29
No related branches found
No related tags found
No related merge requests found
...@@ -127,7 +127,7 @@ def main(): ...@@ -127,7 +127,7 @@ def main():
if testing: if testing:
extra_ctest_flags = "" extra_ctest_flags = ""
if WINDOWS: if WINDOWS:
extra_ctest_flags += "--repeat until-pass:3 " extra_ctest_flags += "--repeat until-pass:3 "
extra_ctest_flags += "--build-config " + args.buildtype extra_ctest_flags += "--build-config " + args.buildtype
...@@ -165,7 +165,7 @@ def cleanup_previous_build(shell_log): ...@@ -165,7 +165,7 @@ def cleanup_previous_build(shell_log):
if result != 0: if result != 0:
die(result, "Failed to clean up previous artifacts", shell_log) die(result, "Failed to clean up previous artifacts", shell_log)
return shell_log return shell_log
...@@ -191,7 +191,7 @@ def git_pull(repository:str, branch: str, shell_log: str): ...@@ -191,7 +191,7 @@ def git_pull(repository:str, branch: str, shell_log: str):
if returncode != 0: if returncode != 0:
die(returncode, f"Failed to pull {branch}", shell_log) die(returncode, f"Failed to pull {branch}", shell_log)
return shell_log return shell_log
...@@ -212,7 +212,7 @@ def download_artifacts(obj_prefix: str, shell_log: str): ...@@ -212,7 +212,7 @@ def download_artifacts(obj_prefix: str, shell_log: str):
shutil.rmtree(f'{WORKDIR}/src', ignore_errors=True) shutil.rmtree(f'{WORKDIR}/src', ignore_errors=True)
shutil.rmtree(f'{WORKDIR}/build', ignore_errors=True) shutil.rmtree(f'{WORKDIR}/build', ignore_errors=True)
raise err raise err
return shell_log return shell_log
...@@ -222,10 +222,10 @@ def run_ctest(shell_log: str, extra_ctest_flags: str) -> str: ...@@ -222,10 +222,10 @@ def run_ctest(shell_log: str, extra_ctest_flags: str) -> str:
cd '{WORKDIR}/build' cd '{WORKDIR}/build'
ctest --parallel {os.cpu_count()} --output-junit TestResults.xml {extra_ctest_flags} ctest --parallel {os.cpu_count()} --output-junit TestResults.xml {extra_ctest_flags}
""", shell_log) """, shell_log)
if result != 0: if result != 0:
print_warning("Some tests failed") print_warning("Some tests failed")
return shell_log return shell_log
...@@ -271,25 +271,25 @@ def build(options, buildtype, shell_log): ...@@ -271,25 +271,25 @@ def build(options, buildtype, shell_log):
if result != 0: if result != 0:
die(result, "Failed to build", shell_log) die(result, "Failed to build", shell_log)
return shell_log return shell_log
@github_log_group("Rebase") @github_log_group("Rebase")
def rebase(base_ref, head_ref, shell_log) -> str: def rebase(base_ref, head_ref, shell_log) -> str:
# This mental gymnastics is neccessary because the the CMake build fetches # This mental gymnastics is neccessary because the the CMake build fetches
# roottest based on the current branch name of ROOT # roottest based on the current branch name of ROOT
# #
# rebase fails unless user.email and user.name is set # rebase fails unless user.email and user.name is set
result, shell_log = subprocess_with_log(f""" result, shell_log = subprocess_with_log(f"""
cd '{WORKDIR}/src' cd '{WORKDIR}/src'
git config user.email "rootci@root.cern" git config user.email "rootci@root.cern"
git config user.name 'ROOT Continous Integration' git config user.name 'ROOT Continous Integration'
git fetch origin {head_ref}:__tmp git fetch origin {head_ref}:__tmp
git checkout __tmp git checkout __tmp
git rebase {base_ref} git rebase {base_ref}
git checkout {base_ref} git checkout {base_ref}
git reset --hard __tmp git reset --hard __tmp
......
...@@ -26,7 +26,7 @@ def github_log_group(title: str): ...@@ -26,7 +26,7 @@ def github_log_group(title: str):
except Exception as e: except Exception as e:
print("::endgroup::") print("::endgroup::")
raise e raise e
print("::endgroup::") print("::endgroup::")
return result return result
...@@ -82,13 +82,17 @@ def die(code: int = 1, msg: str = "", log: str = "") -> None: ...@@ -82,13 +82,17 @@ def die(code: int = 1, msg: str = "", log: str = "") -> None:
def print_shell_log(log: str) -> None: def print_shell_log(log: str) -> None:
if log != "": if log != "":
shell_log = textwrap.dedent(f"""\ shell_log = f"""\
###################################### ######################################
# To replicate build locally # # To replicate build locally #
###################################### ######################################
{log} For Linux, grab the image:
""") $ docker run --rm -it registry.cern.ch/root-ci/<image>:buildready
Then:
{log}
"""
print(shell_log) print(shell_log)
...@@ -183,7 +187,7 @@ def download_latest(url: str, prefix: str, destination: str, shell_log: str) -> ...@@ -183,7 +187,7 @@ def download_latest(url: str, prefix: str, destination: str, shell_log: str) ->
with get(f"{url}/?prefix={prefix}&format=json", timeout=20) as r: with get(f"{url}/?prefix={prefix}&format=json", timeout=20) as r:
if r.status_code == HTTPStatus.NO_CONTENT or r.content == b'[]': if r.status_code == HTTPStatus.NO_CONTENT or r.content == b'[]':
raise Exception(f"No object found with prefix: {prefix}") raise Exception(f"No object found with prefix: {prefix}")
result = json.loads(r.content) result = json.loads(r.content)
artifacts = [x['name'] for x in result if 'content_type' in x] artifacts = [x['name'] for x in result if 'content_type' in x]
......
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