Merge pull request #88 from scarabeusiv/master
Implement non-ring project verification to not wait on obs/openQA
This commit is contained in:
commit
e8c3dcaf81
@ -127,6 +127,8 @@ def _staging_submit_devel(self, project, opts):
|
||||
return
|
||||
|
||||
|
||||
@cmdln.option('-c', '--commit', action='store_true',
|
||||
help='accept the request completely and commit the changes to the openSUSE:Factory')
|
||||
@cmdln.option('-e', '--everything', action='store_true',
|
||||
help='during check do not stop on first first issue and show them all')
|
||||
@cmdln.option('-p', '--parent', metavar='TARGETPROJECT',
|
||||
@ -171,7 +173,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
osc staging list
|
||||
osc staging select [--move [-from PROJECT]] LETTER REQUEST...
|
||||
osc staging unselect LETTER REQUEST...
|
||||
osc staging accept LETTER
|
||||
osc staging accept [--commit] LETTER
|
||||
osc staging cleanup_rings
|
||||
"""
|
||||
if opts.version:
|
||||
@ -254,7 +256,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
for prj in args[1:]:
|
||||
osclib.freeze_command.FreezeCommand(api).perform(api. prj_from_letter(prj))
|
||||
elif cmd == 'accept':
|
||||
return AcceptCommand(api).perform(api. prj_from_letter(args[1]))
|
||||
return AcceptCommand(api).perform(api. prj_from_letter(args[1]), opts.commit)
|
||||
elif cmd == 'unselect':
|
||||
tprj = api.prj_from_letter(args[1]) # see issue 1784
|
||||
for rq, rq_prj in RequestFinder.find_sr(args[2:], opts.apiurl).items():
|
||||
|
@ -5,11 +5,12 @@ class AcceptCommand:
|
||||
def __init__(self, api):
|
||||
self.api = api
|
||||
|
||||
def perform(self, project):
|
||||
def perform(self, project, commit):
|
||||
"""
|
||||
Accept the staging LETTER for review and submit to factory
|
||||
Then disable the build to disabled
|
||||
:param project: staging project we are working with
|
||||
:param commit: switch wether to commit the pkgs to factory right away or not
|
||||
"""
|
||||
status = self.api.check_project_status(project)
|
||||
|
||||
@ -25,6 +26,10 @@ class AcceptCommand:
|
||||
requests.append(req['id'])
|
||||
|
||||
for req in requests:
|
||||
change_request_state(self.api.apiurl, str(req), 'accepted', message='Accept to factory')
|
||||
# If we are not doing direct commit print out commands needed to accept it
|
||||
if commit:
|
||||
change_request_state(self.api.apiurl, str(req), 'accepted', message='Accept to factory')
|
||||
else:
|
||||
print('osc rq accept -m "Accept to factory" {}'.format(req))
|
||||
|
||||
self.api.build_switch_prj(project, 'disable')
|
||||
|
@ -221,7 +221,6 @@ class StagingAPI(object):
|
||||
# check if we can reduce it down by accepting some
|
||||
for rq in requests:
|
||||
self.accept_non_ring_request(rq)
|
||||
# FIXME: dispatch to various staging projects automatically
|
||||
|
||||
def get_prj_pseudometa(self, project):
|
||||
"""
|
||||
@ -291,7 +290,6 @@ class StagingAPI(object):
|
||||
if append:
|
||||
data['requests'].append({'id': request_id, 'package': package})
|
||||
self.set_prj_pseudometa(project, data)
|
||||
# FIXME Add sr to group request as well
|
||||
|
||||
def get_request_id_for_package(self, project, package):
|
||||
"""
|
||||
@ -327,7 +325,6 @@ class StagingAPI(object):
|
||||
data = self.get_prj_pseudometa(project)
|
||||
data['requests'] = filter(lambda x: x['package'] != package, data['requests'])
|
||||
self.set_prj_pseudometa(project, data)
|
||||
# FIXME Add sr to group request as well
|
||||
|
||||
def rm_from_prj(self, project, package=None, request_id=None,
|
||||
msg=None, review='accepted'):
|
||||
@ -412,6 +409,22 @@ class StagingAPI(object):
|
||||
state = 'missing reviews: ' + ', '.join(failing_groups)
|
||||
return '{}: {}'.format(package, state)
|
||||
|
||||
def check_ring_packages(self, project, requests):
|
||||
"""
|
||||
Checks if packages from requests are in some ring or not
|
||||
:param project: project to check
|
||||
:param requests: list of requests to verify
|
||||
:return True (has ring packages) / False (has no ring packages)
|
||||
"""
|
||||
|
||||
for request in requests:
|
||||
pkg = self.get_package_for_request_id(project, request)
|
||||
if pkg in self.ring_packages:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def check_project_status(self, project, verbose=False):
|
||||
"""
|
||||
Checks a staging project for acceptance. Checks all open
|
||||
@ -437,11 +450,11 @@ class StagingAPI(object):
|
||||
open_requests.remove(req)
|
||||
if req not in requests:
|
||||
requests.append(req)
|
||||
if len(open_requests) != 0:
|
||||
if open_requests:
|
||||
return ['Request(s) {} are not tracked but are open for the prj'.format(','.join(open_requests))]
|
||||
|
||||
# If we find no requests in staging then it is empty so we ignore it
|
||||
if len(requests) == 0:
|
||||
if not requests:
|
||||
return False
|
||||
|
||||
# Check if the requests are acceptable and bail out on
|
||||
@ -453,16 +466,17 @@ class StagingAPI(object):
|
||||
if not verbose:
|
||||
break
|
||||
|
||||
# Check the buildstatus
|
||||
buildstatus = self.gather_build_status(project)
|
||||
if buildstatus:
|
||||
# here no append as we are adding list to list
|
||||
report += self.generate_build_status_details(buildstatus, verbose)
|
||||
|
||||
# Check the openqa state
|
||||
ret = self.find_openqa_state(project)
|
||||
if ret:
|
||||
report.append(ret)
|
||||
# Check the build/openQA only if we have some ring packages
|
||||
if self.check_ring_packages(project, requests):
|
||||
# Check the buildstatus
|
||||
buildstatus = self.gather_build_status(project)
|
||||
if buildstatus:
|
||||
# here no append as we are adding list to list
|
||||
report += self.generate_build_status_details(buildstatus, verbose)
|
||||
# Check the openqa state
|
||||
ret = self.find_openqa_state(project)
|
||||
if ret:
|
||||
report.append(ret)
|
||||
|
||||
if report:
|
||||
return report
|
||||
@ -567,7 +581,7 @@ class StagingAPI(object):
|
||||
})
|
||||
|
||||
# Print the results
|
||||
if len(working) == 0 and len(broken) == 0:
|
||||
if not working and not broken:
|
||||
return None
|
||||
else:
|
||||
return [project, working, broken]
|
||||
@ -584,13 +598,13 @@ class StagingAPI(object):
|
||||
return retval
|
||||
project, working, broken = details
|
||||
|
||||
if len(working) != 0:
|
||||
if working:
|
||||
retval.append('At least following repositories is still building:')
|
||||
for i in working:
|
||||
retval.append(' {}: {}'.format(i['path'], i['state']))
|
||||
if not verbose:
|
||||
break
|
||||
if len(broken) != 0:
|
||||
if broken:
|
||||
retval.append('Following packages are broken:')
|
||||
for i in broken:
|
||||
retval.append(' {} ({}): {}'.format(i['pkg'], i['path'],
|
||||
@ -732,7 +746,7 @@ class StagingAPI(object):
|
||||
query['by_group'] = by_group
|
||||
if not msg:
|
||||
msg = 'Being evaluated by group "{}"'.format(by_group)
|
||||
if len(query) == 0:
|
||||
if not query:
|
||||
raise oscerr.WrongArgs('We need a group or a project')
|
||||
query['cmd'] = 'addreview'
|
||||
url = self.makeurl(['request', str(request_id)], query)
|
||||
|
@ -44,6 +44,7 @@ class TestApiCalls(unittest.TestCase):
|
||||
ring_packages = {
|
||||
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX',
|
||||
'wine': 'openSUSE:Factory:Rings:1-MinimalX',
|
||||
}
|
||||
|
||||
# Register OBS
|
||||
|
1
tests/fixtures/ring-1-project.xml
vendored
1
tests/fixtures/ring-1-project.xml
vendored
@ -1,3 +1,4 @@
|
||||
<directory count='1'>
|
||||
<entry name="elem-ring-1"/>
|
||||
<entry name="wine"/>
|
||||
</directory>
|
||||
|
11
tests/obs.py
11
tests/obs.py
@ -30,15 +30,6 @@ if PY3:
|
||||
else:
|
||||
string_types = basestring,
|
||||
|
||||
# Here place all mockable functions
|
||||
@contextlib.contextmanager
|
||||
def mock_generate_ring_packages():
|
||||
with mock.patch('oscs.StagingAPI._generate_ring_packages', return_value={
|
||||
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX'}):
|
||||
yield
|
||||
|
||||
|
||||
class OBS:
|
||||
"""
|
||||
Class trying to simulate a simple OBS
|
||||
@ -172,7 +163,7 @@ class OBS:
|
||||
if len(path) > 1:
|
||||
ret = self._pretty_callback(request, 'https://localhost' + posixpath.dirname(path), headers, False)
|
||||
if exception:
|
||||
raise BaseException("No tests/obs.pyresponse for {0} on {1} provided".format(request.method,uri))
|
||||
raise BaseException("No tests/obs.pyresponse for {0} on {1} provided".format(request.method, uri))
|
||||
else:
|
||||
return None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user