From c487ada514b867b43b2b74a48620d550204f6ba9 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Thu, 7 Mar 2024 04:40:58 +0000 Subject: [PATCH] review callback: Set labels, render list of failed checks in reporter --- buildbot_nix/__init__.py | 60 ++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/buildbot_nix/__init__.py b/buildbot_nix/__init__.py index f172073..4d864ce 100644 --- a/buildbot_nix/__init__.py +++ b/buildbot_nix/__init__.py @@ -608,20 +608,64 @@ def gerritReviewCB(builderName, build, result, master, arg): if builderName != 'lix/nix-eval': return dict() - message = "Buildbot finished compiling your patchset\n" - message += "on configuration: %s\n" % builderName + all_checks = {} + for step in build['steps']: + if step['name'] != 'build flake': + continue + + for url in step['urls']: + if url['name'].startswith('success: checks.'): + path = url['name'].split(' ')[1] + all_checks[path] = (True, url['url']) + elif url['name'].startswith('failure: checks.'): + path = url['name'].split(' ')[1] + all_checks[path] = (False, url['url']) + + collected_oses = {} + for check in all_checks: + arch = check.split('.')[1] + os = arch.split('-')[1] + (success, failure) = collected_oses.get(os, (0, 0)) + if all_checks[check][0]: + success += 1 + else: + failure += 1 + + collected_oses[os] = (success, failure) + labels = {} + + if 'linux' in collected_oses: + (success, failure) = collected_oses['linux'] + if success > 0 and failure == 0: + labels['Verified-On-Linux'] = 1 + elif failure > 0: + labels['Verified-On-Linux'] = -1 + + if 'darwin' in collected_oses: + (success, failure) = collected_oses['darwin'] + if success > 0 and failure == 0: + labels['Verified-On-Darwin'] = 1 + elif failure > 0: + labels['Verified-On-Darwin'] = -1 + + message = "Buildbot finished compiling your patchset!\n" message += "The result is: %s\n" % util.Results[result].upper() + if result != util.SUCCESS: + successful_checks = [] + failed_checks = [] + for check in all_checks: + if not all_checks[check][0]: + failed_checks.append(f" - {check} (see {all_checks[check][1]})") + + if len(failed_checks) > 0: + message += "Failed checks:\n" + "\n".join(failed_checks) + "\n" + if arg: message += "\nFor more details visit:\n" message += build['url'] + "\n" - if result == util.SUCCESS: - verified = 1 - else: - verified = -1 - - return dict(message=message, labels={'Verified': verified}) + return dict(message=message, labels=labels) def gerritStartCB(builderName, build, arg): message = "Buildbot started compiling your patchset\n"