Merge sync-rebuild into staging accept command

This commit is contained in:
Dominique Leuenberger 2015-02-02 15:02:57 +01:00
parent 0968ffc6ff
commit 87c8916620
3 changed files with 63 additions and 0 deletions

View File

@ -121,6 +121,7 @@ def do_staging(self, subcmd, opts, *args):
return
cmd.accept_other_new()
cmd.update_factory_version()
cmd.sync_buildfailures()
elif cmd == 'unselect':
UnselectCommand(api).perform(args[1:])
elif cmd == 'select':

View File

@ -138,3 +138,22 @@ class AcceptCommand(object):
if product != new_product:
http_PUT(url + '?comment=Update+version', data=new_product)
def sync_buildfailures(self):
"""Trigger rebuild of packages that failed build in either
openSUSE:Factory or openSUSE:Factory:Rebuild, but not the other
Helps over the fact that openSUSE:Factory uses rebuild=local,
thus sometimes 'hiding' build failures."""
for arch in ["x86_64","i586"]:
fact_result = self.api.get_prj_results('openSUSE:Factory', arch)
fact_result = self.api.check_pkgs(fact_result)
rebuild_result = self.api.get_prj_results('openSUSE:Factory:Rebuild', arch)
rebuild_result = self.api.check_pkgs(rebuild_result)
result = set(rebuild_result) ^ set(fact_result)
print sorted(result)
for package in result:
self.api.rebuild_pkg(package, 'openSUSE:Factory', arch, None)
self.api.rebuild_pkg(package, 'openSUSE:Factory:Rebuild', arch, None)

View File

@ -1031,3 +1031,46 @@ class StagingAPI(object):
additionals.update(packages)
meta['add_to_repo'] = sorted(additionals)
self.set_prj_pseudometa(project, meta)
def get_prj_results(self, prj, arch):
url = self.makeurl(['build', prj, 'standard', arch, "_jobhistory?code=lastfailures"])
results = []
root = ET.parse(http_GET(url)).getroot()
xmllines = root.findall("./jobhist")
for pkg in xmllines:
if pkg.attrib['code'] == 'failed':
results.append(pkg.attrib['package'])
return results
def check_pkgs(self, rebuild_list):
url = self.makeurl(['source', 'openSUSE:Factory'])
pkglist = []
root = ET.parse(http_GET(url)).getroot()
xmllines = root.findall("./entry")
for pkg in xmllines:
if pkg.attrib['name'] in rebuild_list:
pkglist.append(pkg.attrib['name'])
return pkglist
def rebuild_pkg(self, package, prj, arch, code=None):
query = { 'cmd': 'rebuild', 'arch': arch }
if package:
query['package'] = package
pkg = query['package']
u = self.makeurl(['build', prj], query=query)
try:
print "tried to trigger rebuild for project '%s' package '%s'" % (prj, pkg)
f = http_POST(u)
except:
print "could not trigger rebuild for project '%s' package '%s'" % (prj, pkg)