1
0
Fork 0

don't flatten the list of all jobs

to not spam if e.g. whole suite got cancelled

#445
This commit is contained in:
Mikhail Goncharov 2023-05-05 10:49:57 +02:00
parent 7618688949
commit 0c9c705503

View file

@ -110,18 +110,13 @@ def print_jobs(jobs: list[jobResult], pad: str):
print(f"{pad} {j.name} {j.success}") print(f"{pad} {j.name} {j.success}")
print_jobs(j.sub, pad + ' ') print_jobs(j.sub, pad + ' ')
# Returns a flat list of job results. Sub jobs get a prefix of a parent one. # Returns a flat list of job tests, appends prefix of job names to test names.
def flatten_jobs(jobs: list[jobResult], prefix: str) -> Tuple[list[jobResult], list[Any]]: def flatten_tests(jobs: list[jobResult], prefix: str) -> list[Any]:
r = []
t = [] t = []
for j in jobs: for j in jobs:
j.name = prefix + j.name
t.extend(xunit_utils.add_context_prefix(j.tests, prefix)) t.extend(xunit_utils.add_context_prefix(j.tests, prefix))
r.append(j) t.extend(flatten_tests(j.sub, f"{prefix}{j.name} - "))
sr, st = flatten_jobs(j.sub, f"{j.name} - ") return t
r.extend(sr)
t.extend(st)
return [r, t]
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -149,14 +144,14 @@ if __name__ == '__main__':
# Build type is https://buildkite.com/docs/apis/rest-api/builds#get-a-build. # Build type is https://buildkite.com/docs/apis/rest-api/builds#get-a-build.
build = bk.get_build(bk_pipeline_slug, bk_build_number) build = bk.get_build(bk_pipeline_slug, bk_build_number)
jobs, success = process_build(bk, build) jobs, success = process_build(bk, build)
jobs, failed_tests = flatten_jobs(jobs, '') failed_tests = flatten_tests(jobs, '')
if args.debug: if args.debug:
print_jobs(jobs, '') print_jobs(jobs, '')
for t in failed_tests: for t in failed_tests:
t['details'] = '' t['details'] = ''
for j in jobs: for j in jobs:
if not j.success: if not j.success:
phabtalk.maybe_add_url_artifact(ph_target_phid, j.url, j.name) phabtalk.maybe_add_url_artifact(ph_target_phid, j.url, j.name + " FAILED")
report_success = success report_success = success
finally: finally:
build_url = f'https://reviews.llvm.org/harbormaster/build/{os.getenv("ph_build_id")}' build_url = f'https://reviews.llvm.org/harbormaster/build/{os.getenv("ph_build_id")}'