# Current and irrelevant steps. continue if job_state == 'passed' and i == 0: # Skip successful first step as we assume it to be a pipeline setup continue name = job.get('name') if job.get('type') == 'trigger': job_web_url = job.get('triggered_build.web_url', job_web_url) triggered_url = job.get('triggered_build.url') if triggered_url != '': sub_build = benedict(bk.get(triggered_url).json()) name = name or sub_build.get('pipeline.name') failed_steps = get_failed_jobs(sub_build) failed_tests.extend( process_unit_test_reports(bk, sub_build, name)) if job_state == 'failed' and failed_steps: name = f"{name} ({', '.join(failed_steps[:2])}{', ...' if len(failed_steps) > 2 else ''})" name = strip_emojis(name) or 'unknown' phabtalk.maybe_add_url_artifact(ph_target_phid, job_web_url, f"{name} {job_state}") if job_state == 'failed': success = False report_success = success # Must be last before finally: block to report errors in this script. finally: build_url = f'https://reviews.llvm.org/harbormaster/build/{os.getenv("ph_build_id")}' print( f'Reporting results to Phabricator build {format_url(build_url)}', flush=True) phabtalk.update_build_status(ph_target_phid, False, report_success, {}, failed_tests)
for s in report.steps: if len(s.reproduce_commands) == 0: continue print('\n'.join(s.reproduce_commands), flush=True) print('', flush=True) if not report.success: print('^^^ +++', flush=True) ph_target_phid = os.getenv('ph_target_phid') if ph_target_phid is not None: phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN')) for u in report.unit: u['engine'] = step_key phabtalk.update_build_status(ph_target_phid, True, report.success, report.lint, report.unit) for a in report.artifacts: url = upload_file(a['dir'], a['file']) if url is not None: phabtalk.maybe_add_url_artifact(ph_target_phid, url, f'{a["name"]} ({step_key})') else: logging.warning( 'ph_target_phid is not specified. Will not update the build status in Phabricator' ) with open(report_path, 'w') as f: json.dump(report.__dict__, f, default=as_dict) if not report.success: print('Build completed with failures', flush=True) exit(1)