1
0
Fork 0

Flush stdout to fix log update

for #201
This commit is contained in:
Mikhail Goncharov 2020-06-17 15:07:19 +02:00
parent dd4e6210bb
commit 24da609a10
4 changed files with 13 additions and 13 deletions

View file

@ -35,11 +35,11 @@ if __name__ == '__main__':
logging.basicConfig(level=args.log_level, format='%(levelname)-7s %(message)s')
phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN'), 'https://reviews.llvm.org/api/', False)
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)}')
print(f'Reporting results to Phabricator build {format_url(build_url)}', flush=True)
ph_buildable_diff = os.getenv('ph_buildable_diff')
ph_target_phid = os.getenv('ph_target_phid')
phabtalk.update_build_status(ph_buildable_diff, ph_target_phid, False, args.success)
bug_url = f'https://github.com/google/llvm-premerge-checks/issues/new?assignees=&labels=bug' \
f'&template=bug_report.md&title=buildkite build {os.getenv("BUILDKITE_PIPELINE_SLUG")} ' \
f'{os.getenv("BUILDKITE_BUILD_NUMBER")}'
print(f'{format_url(bug_url, "report issue")}')
print(f'{format_url(bug_url, "report issue")}', flush=True)

View file

@ -41,16 +41,16 @@ if __name__ == '__main__':
args = parser.parse_args()
logging.basicConfig(level=args.log_level, format='%(levelname)-7s %(message)s')
print(f'Branch {os.getenv("BUILDKITE_BRANCH")} at {os.getenv("BUILDKITE_REPO")}')
print(f'Branch {os.getenv("BUILDKITE_BRANCH")} at {os.getenv("BUILDKITE_REPO")}', flush=True)
ph_buildable_diff = os.getenv('ph_buildable_diff')
if ph_buildable_diff is not None:
url = f'https://reviews.llvm.org/D{os.getenv("ph_buildable_revision")}?id={ph_buildable_diff}'
print(f'Review: {format_url(url)}')
print(f'Review: {format_url(url)}', flush=True)
if os.getenv('BUILDKITE_TRIGGERED_FROM_BUILD_NUMBER') is not None:
url = f'https://buildkite.com/llvm-project/' \
f'{os.getenv("BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG")}/' \
f'builds/{os.getenv("BUILDKITE_TRIGGERED_FROM_BUILD_NUMBER")}'
print(f'Triggered from build {format_url(url)}')
print(f'Triggered from build {format_url(url)}', flush=True)
success = True
for path in glob.glob("*_result.json"):
@ -61,11 +61,11 @@ if __name__ == '__main__':
success = success and report['success']
phabtalk = PhabTalk(os.getenv('CONDUIT_TOKEN'), 'https://reviews.llvm.org/api/', False)
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)}')
print(f'Reporting results to Phabricator build {format_url(build_url)}', flush=True)
ph_buildable_diff = os.getenv('ph_buildable_diff')
ph_target_phid = os.getenv('ph_target_phid')
phabtalk.update_build_status(ph_buildable_diff, ph_target_phid, False, success)
bug_url = f'https://github.com/google/llvm-premerge-checks/issues/new?assignees=&labels=bug' \
f'&template=bug_report.md&title=buildkite build {os.getenv("BUILDKITE_PIPELINE_SLUG")} ' \
f'{os.getenv("BUILDKITE_BUILD_NUMBER")}'
print(f'{format_url(bug_url, "report issue")}')
print(f'{format_url(bug_url, "report issue")}', flush=True)

View file

@ -34,7 +34,7 @@ from phabtalk.phabtalk import Report, PhabTalk, Step
def ninja_all_report(step: Step, _: Report):
print('Full will be available in Artifacts "ninja-all.log"')
print('Full will be available in Artifacts "ninja-all.log"', flush=True)
r = subprocess.run(f'ninja all | '
f'tee {artifacts_dir}/ninja-all.log | '
f'grep -vE "\\[.*] (Building|Linking|Copying|Generating|Creating)"',
@ -44,7 +44,7 @@ def ninja_all_report(step: Step, _: Report):
def ninja_check_all_report(step: Step, _: Report):
print('Full will be available in Artifacts "ninja-check-all.log"')
print('Full will be available in Artifacts "ninja-check-all.log"', flush=True)
r = subprocess.run(f'ninja check-all | tee {artifacts_dir}/ninja-check-all.log | '
f'grep -vE "^\\[.*] (Building|Linking)" | '
f'grep -vE "^(PASS|XFAIL|UNSUPPORTED):"', shell=True, cwd=build_dir)
@ -55,14 +55,14 @@ def ninja_check_all_report(step: Step, _: Report):
def run_step(name: str, report: Report, thunk: Callable[[Step, Report], None]) -> Step:
start = time.time()
print(f'--- {name}') # New section in Buildkite log.
print(f'--- {name}', flush=True) # New section in Buildkite log.
step = Step()
step.name = name
thunk(step, report)
step.duration = time.time() - start
# Expand section if it failed.
if not step.success:
print('^^^ +++')
print('^^^ +++', flush=True)
report.steps.append(step)
return step
@ -146,5 +146,5 @@ if __name__ == '__main__':
with open(report_path, 'w') as f:
json.dump(report.__dict__, f, default=as_dict)
if not report.success:
print('Build completed with failures')
print('Build completed with failures', flush=True)
exit(1)

View file

@ -150,7 +150,7 @@ def run(projects: str, repo_path: str, config_file_path: str = None, *, dry_run:
env = _create_env(config)
llvm_enable_projects = _select_projects(config, projects, repo_path)
print('Enabled projects: {}'.format(llvm_enable_projects))
print('Enabled projects: {}'.format(llvm_enable_projects), flush=True)
arguments = _create_args(config, llvm_enable_projects)
cmd = 'cmake ' + ' '.join(arguments)