abi-checker: recognize staging

This commit is contained in:
Ludwig Nussel 2019-12-18 17:46:06 +01:00
parent 12b2bce785
commit 60e5fd94a2
2 changed files with 64 additions and 17 deletions

View File

@ -135,6 +135,18 @@ class ReviewBot(object):
else:
self.config = self._load_config()
def has_staging(self, project):
try:
url = osc.core.makeurl(self.apiurl, ('staging', project, 'staging_projects'))
osc.core.http_GET(url)
return True
except HTTPError as e:
if e.code != 404:
self.logger.error('ERROR in URL %s [%s]' % (url, e))
raise
pass
return False
def staging_api(self, project):
# Allow for the Staging subproject to be passed directly from config
# which should be stripped before initializing StagingAPI. This allows
@ -184,6 +196,17 @@ class ReviewBot(object):
with sentry_sdk.configure_scope() as scope:
scope.set_extra('request.id', self.request.reqid)
# XXX: this is a hack. Annotating the request with staging_project.
# OBS itself should provide an API for that but that's currently not the case
# https://github.com/openSUSE/openSUSE-release-tools/pull/2377
if not hasattr(req, 'staging_project'):
staging_project = None
for r in req.reviews:
if r.state == 'new' and r.by_project and ":Staging:" in r.by_project:
staging_project = r.by_project
break
setattr(req, 'staging_project', staging_project)
try:
good = self.check_one_request(req)
except Exception as e:

View File

@ -184,6 +184,8 @@ class ABIChecker(ReviewBot.ReviewBot):
self.commentapi = CommentAPI(self.apiurl)
self.current_request = None
def check_source_submission(self, src_project, src_package, src_rev, dst_project, dst_package):
# happens for maintenance incidents
@ -199,6 +201,17 @@ class ABIChecker(ReviewBot.ReviewBot):
# there were problems.
ret = True
if self.has_staging(dst_project):
# if staged we don't look at the request source but what
# is in staging
if self.current_request.staging_project:
src_project = self.current_request.staging_project
src_package = dst_package
src_rev = None
else:
self.logger.debug("request not staged yet")
return None
ReviewBot.ReviewBot.check_source_submission(self, src_project, src_package, src_rev, dst_project, dst_package)
report = Report(src_project, src_package, src_rev, dst_project, dst_package, [], None)
@ -514,6 +527,8 @@ class ABIChecker(ReviewBot.ReviewBot):
self.dblogger.request_id = req.reqid
self.current_request = req
self.reports = []
self.text_summary = ''
try:
@ -553,6 +568,8 @@ class ABIChecker(ReviewBot.ReviewBot):
self.dblogger.request_id = None
self.current_request = None
return ret
def check_request_already_done(self, reqid):
@ -901,24 +918,31 @@ class ABIChecker(ReviewBot.ReviewBot):
# set of source repo name, target repo name, arch
matchrepos = set()
for repo in root.findall('repository'):
name = repo.attrib['name']
path = repo.findall('path')
if path is None or len(path) != 1:
self.logger.error("repo %s has more than one path"%name)
continue
prj = path[0].attrib['project']
if prj == 'openSUSE:Tumbleweed':
prj = 'openSUSE:Factory' # XXX: hack
if prj != dst_project:
continue
for node in repo.findall('arch'):
# XXX: another staging hack
if self.current_request.staging_project:
for node in root.findall("repository[@name='standard']/arch"):
arch = node.text
dstname = path[0].attrib['repository']
if prj == 'openSUSE:Factory' and dstname == 'snapshot':
dstname = 'standard' # XXX: hack
if (dstname, arch) in dstrepos:
matchrepos.add(MR(name, dstname, arch))
self.logger.debug('arch %s', arch)
matchrepos.add(MR('standard', 'standard', arch))
else:
for repo in root.findall('repository'):
name = repo.attrib['name']
path = repo.findall('path')
if path is None or len(path) != 1:
self.logger.error("repo %s has more than one path"%name)
continue
prj = path[0].attrib['project']
if prj == 'openSUSE:Tumbleweed':
prj = 'openSUSE:Factory' # XXX: hack
if prj != dst_project:
continue
for node in repo.findall('arch'):
arch = node.text
dstname = path[0].attrib['repository']
if prj == 'openSUSE:Factory' and dstname == 'snapshot':
dstname = 'standard' # XXX: hack
if (dstname, arch) in dstrepos:
matchrepos.add(MR(name, dstname, arch))
if not matchrepos:
return None