From cd82223a816cd750b19bc93cb94a65ec35de0089 Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 5 Jan 2021 13:53:26 -0600 Subject: [PATCH 1/2] Provide checkConfig(), to support buildbot 2.9.x. Apparently, as of buildbot 2.9.x, [reporters need to provide their own checkConfig() implementation when a service has custom args not supplied to the superclass](https://github.com/buildbot/buildbot/pull/5571). If we don't do this, checkconfig will fail. --- buildbot_gitea/reporter.py | 5 ++++- setup.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/buildbot_gitea/reporter.py b/buildbot_gitea/reporter.py index f5b988a..5e32577 100644 --- a/buildbot_gitea/reporter.py +++ b/buildbot_gitea/reporter.py @@ -23,9 +23,12 @@ import re class GiteaStatusPush(http.HttpStatusPushBase): name = "GiteaStatusPush" - neededDetails = dict(wantProperties=True) ssh_url_match = re.compile(r"(ssh://)?[\w+\-\_]+@[\w\.\-\_]+:?(\d*/)?(?P[\w_\-\.]+)/(?P[\w_\-\.]+?)(\.git)?$") + def checkConfig(self, baseURL, token, startDescription=None, endDescription=None, + context=None, verbose=False, wantProperties=True, **kwargs): + super().checkConfig(wantProperties=wantProperties, **kwargs) + @defer.inlineCallbacks def reconfigService(self, baseURL, token, startDescription=None, endDescription=None, diff --git a/setup.py b/setup.py index dab68dc..6a43c7a 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ setup(name='buildbot-gitea', long_description_content_type="text/markdown", packages=['buildbot_gitea'], requires=[ - "buildbot (>=2.0.0)" + "buildbot (>=2.9.0)" ], entry_points={ "buildbot.webhooks": [ From a47f7a512b6612deb9b5d8326afdaebe676b4e83 Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Fri, 8 Jan 2021 15:49:39 -0600 Subject: [PATCH 2/2] Conform to code in GitLabStatusPush v2.9.4. I don't fully understand the impact of these API changes, but without them the status from buildbot upon a successful build was causing gitea to mark commits with a yellow circle instead of a green checkmark. Since GiteaStatusPush was based on GitLabStatusPush in the first place, I tried making it look more like its ancestor -- and now the commit status in gitea is working correctly. --- buildbot_gitea/reporter.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/buildbot_gitea/reporter.py b/buildbot_gitea/reporter.py index 5e32577..ae85d28 100644 --- a/buildbot_gitea/reporter.py +++ b/buildbot_gitea/reporter.py @@ -17,6 +17,7 @@ from buildbot.process.results import SUCCESS from buildbot.process.results import WARNINGS from buildbot.reporters import http from buildbot.util import httpclientservice +from buildbot.warnings import warn_deprecated import re @@ -27,16 +28,20 @@ class GiteaStatusPush(http.HttpStatusPushBase): def checkConfig(self, baseURL, token, startDescription=None, endDescription=None, context=None, verbose=False, wantProperties=True, **kwargs): - super().checkConfig(wantProperties=wantProperties, **kwargs) + super().checkConfig(wantProperties=wantProperties, + _has_old_arg_names={ + 'builders': False, + 'wantProperties': wantProperties is not True + }, **kwargs) @defer.inlineCallbacks def reconfigService(self, baseURL, token, startDescription=None, endDescription=None, - context=None, context_pr=None, verbose=False, + context=None, context_pr=None, verbose=False, wantProperties=True, warningAsSuccess=False, **kwargs): token = yield self.renderSecrets(token) - yield http.HttpStatusPushBase.reconfigService(self, **kwargs) + yield super().reconfigService(wantProperties=wantProperties, **kwargs) self.context = context or Interpolate('buildbot/%(prop:buildername)s') self.context_pr = context_pr or \ @@ -90,6 +95,21 @@ class GiteaStatusPush(http.HttpStatusPushBase): @defer.inlineCallbacks def send(self, build): + # the only case when this function is called is when the user derives this class, overrides + # send() and calls super().send(build) from there. + yield self._send_impl(build) + + @defer.inlineCallbacks + def sendMessage(self, reports): + build = reports[0]['builds'][0] + if self.send.__func__ is not GiteaStatusPush.send: + warn_deprecated('2.9.0', 'send() in reporters has been deprecated. Use sendMessage()') + yield self.send(build) + else: + yield self._send_impl(build) + + @defer.inlineCallbacks + def _send_impl(self, build): props = Properties.fromDict(build['properties']) props.master = self.master