From: Daan De Meyer Date: Tue, 7 May 2024 10:24:51 +0000 (+0200) Subject: ci: Print a helpful link to download and view a failed test's journal X-Git-Tag: v256-rc2~81^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a77f65d0c9590761dd08ed78ea0ebfdd845ba84f;p=thirdparty%2Fsystemd.git ci: Print a helpful link to download and view a failed test's journal --- diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 25b903c4e6a..fcdc9b6352f 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -9,6 +9,7 @@ with the expectation that as part of formally defining the API it will be tidy. ''' import argparse +import json import os import shlex import subprocess @@ -154,16 +155,34 @@ def main(): exit(0 if result.returncode == 123 else 77) if journal_file: - cmd = [ - 'journalctl', - '--no-hostname', - '-o', 'short-monotonic', - '--file', journal_file, - '-u', test_unit, - '-p', 'info', - ] + ops = [] + + if os.getenv("GITHUB_ACTIONS"): + id = os.environ["GITHUB_RUN_ID"] + iteration = os.environ["GITHUB_RUN_ATTEMPT"] + j = json.loads( + subprocess.run( + [ + "mkosi", + "--directory", os.fspath(args.meson_source_dir), + "--json", + "summary", + ], + stdout=subprocess.PIPE, + text=True, + ).stdout + ) + images = {image["Image"]: image for image in j["Images"]} + distribution = images["system"]["Distribution"] + release = images["system"]["Release"] + artifact = f"ci-mkosi-{id}-{iteration}-{distribution}-{release}-failed-test-journals" + ops += [f"gh run download {id} --name {artifact} -D ci/{artifact}"] + journal_file = Path(f"ci/{artifact}/test/journal/{name}.journal") + + ops += [f"journalctl --file {journal_file} --no-hostname -o short-monotonic -u {test_unit} -p info"] + print("Test failed, relevant logs can be viewed with: \n\n" - f"{shlex.join(str(a) for a in cmd)}\n", file=sys.stderr) + f"{(' && '.join(ops))}\n", file=sys.stderr) # 0 also means we failed so translate that to a non-zero exit code to mark the test as failed. exit(result.returncode or 1)