Merge "gerritdriver: enable triggering on wip state"
This commit is contained in:
commit
8d00836416
|
@ -350,6 +350,11 @@ order to be enqueued into the pipeline.
|
||||||
A boolean value (``true`` or ``false``) that indicates whether the
|
A boolean value (``true`` or ``false``) that indicates whether the
|
||||||
change must be the current patchset in order to be enqueued.
|
change must be the current patchset in order to be enqueued.
|
||||||
|
|
||||||
|
.. attr:: wip
|
||||||
|
|
||||||
|
A boolean value (``true`` or ``false``) that indicates whether the
|
||||||
|
change must be wip or not wip in order to be enqueued.
|
||||||
|
|
||||||
.. attr:: status
|
.. attr:: status
|
||||||
|
|
||||||
A string value that corresponds with the status of the change
|
A string value that corresponds with the status of the change
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Pipelines can now trigger on ``wip-state-changed`` and filter events on the
|
||||||
|
wip state of a change with :attr:`pipeline.require.<gerrit source>.wip`.
|
|
@ -49,6 +49,23 @@
|
||||||
gerrit:
|
gerrit:
|
||||||
Verified: -1
|
Verified: -1
|
||||||
|
|
||||||
|
- pipeline:
|
||||||
|
name: wip-check
|
||||||
|
manager: independent
|
||||||
|
require:
|
||||||
|
gerrit:
|
||||||
|
wip: false
|
||||||
|
trigger:
|
||||||
|
gerrit:
|
||||||
|
- event: patchset-created
|
||||||
|
- event: comment-added
|
||||||
|
success:
|
||||||
|
gerrit:
|
||||||
|
Verified: 1
|
||||||
|
failure:
|
||||||
|
gerrit:
|
||||||
|
Verified: -1
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: base
|
name: base
|
||||||
parent: null
|
parent: null
|
||||||
|
@ -74,3 +91,9 @@
|
||||||
status-check:
|
status-check:
|
||||||
jobs:
|
jobs:
|
||||||
- project-job
|
- project-job
|
||||||
|
|
||||||
|
- project:
|
||||||
|
name: wip-project
|
||||||
|
wip-check:
|
||||||
|
jobs:
|
||||||
|
- project-job
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
test
|
|
@ -8,3 +8,4 @@
|
||||||
- current-project
|
- current-project
|
||||||
- open-project
|
- open-project
|
||||||
- status-project
|
- status-project
|
||||||
|
- wip-project
|
||||||
|
|
|
@ -309,6 +309,18 @@ class TestRequirementsState(ZuulTestCase):
|
||||||
self.waitUntilSettled()
|
self.waitUntilSettled()
|
||||||
self.assertEqual(len(self.history), 1)
|
self.assertEqual(len(self.history), 1)
|
||||||
|
|
||||||
|
def test_pipeline_require_wip(self):
|
||||||
|
A = self.fake_gerrit.addFakeChange('wip-project', 'master', 'A')
|
||||||
|
A.setWorkInProgress(True)
|
||||||
|
self.fake_gerrit.addEvent(A.addApproval('Code-Review', 2))
|
||||||
|
self.waitUntilSettled()
|
||||||
|
self.assertEqual(len(self.history), 0)
|
||||||
|
|
||||||
|
B = self.fake_gerrit.addFakeChange('wip-project', 'master', 'B')
|
||||||
|
self.fake_gerrit.addEvent(B.addApproval('Code-Review', 2))
|
||||||
|
self.waitUntilSettled()
|
||||||
|
self.assertEqual(len(self.history), 1)
|
||||||
|
|
||||||
|
|
||||||
class TestRequirementsRejectUsername(ZuulTestCase):
|
class TestRequirementsRejectUsername(ZuulTestCase):
|
||||||
"""Requirements with reject username requirement"""
|
"""Requirements with reject username requirement"""
|
||||||
|
|
|
@ -491,7 +491,7 @@ class GerritEventFilter(EventFilter, GerritApprovalFilter):
|
||||||
|
|
||||||
class GerritRefFilter(RefFilter, GerritApprovalFilter):
|
class GerritRefFilter(RefFilter, GerritApprovalFilter):
|
||||||
def __init__(self, connection_name, open=None, current_patchset=None,
|
def __init__(self, connection_name, open=None, current_patchset=None,
|
||||||
statuses=[], required_approvals=[],
|
wip=None, statuses=[], required_approvals=[],
|
||||||
reject_approvals=[]):
|
reject_approvals=[]):
|
||||||
RefFilter.__init__(self, connection_name)
|
RefFilter.__init__(self, connection_name)
|
||||||
|
|
||||||
|
@ -500,6 +500,7 @@ class GerritRefFilter(RefFilter, GerritApprovalFilter):
|
||||||
reject_approvals=reject_approvals)
|
reject_approvals=reject_approvals)
|
||||||
|
|
||||||
self.open = open
|
self.open = open
|
||||||
|
self.wip = wip
|
||||||
self.current_patchset = current_patchset
|
self.current_patchset = current_patchset
|
||||||
self.statuses = statuses
|
self.statuses = statuses
|
||||||
|
|
||||||
|
@ -524,23 +525,30 @@ class GerritRefFilter(RefFilter, GerritApprovalFilter):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def matches(self, change):
|
def matches(self, change):
|
||||||
if self.open is not None:
|
|
||||||
# if a "change" has no number, it's not a change, but a push
|
|
||||||
# and cannot possibly pass this test.
|
|
||||||
if hasattr(change, 'number'):
|
|
||||||
if self.open != change.open:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.current_patchset is not None:
|
filters = [
|
||||||
# if a "change" has no number, it's not a change, but a push
|
{
|
||||||
# and cannot possibly pass this test.
|
"required": self.open,
|
||||||
if hasattr(change, 'number'):
|
"value": change.open
|
||||||
if self.current_patchset != change.is_current_patchset:
|
},
|
||||||
return False
|
{
|
||||||
else:
|
"required": self.current_patchset,
|
||||||
|
"value": change.is_current_patchset
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required": self.wip,
|
||||||
|
"value": change.wip
|
||||||
|
},
|
||||||
|
]
|
||||||
|
configured = filter(lambda x: x["required"] is not None, filters)
|
||||||
|
|
||||||
|
# if a "change" has no number, it's not a change, but a push
|
||||||
|
# and cannot possibly pass this test.
|
||||||
|
if hasattr(change, 'number'):
|
||||||
|
if any(map(lambda x: x["required"] != x["value"], configured)):
|
||||||
return False
|
return False
|
||||||
|
elif configured:
|
||||||
|
return False
|
||||||
|
|
||||||
if self.statuses:
|
if self.statuses:
|
||||||
if change.status not in self.statuses:
|
if change.status not in self.statuses:
|
||||||
|
|
|
@ -203,6 +203,7 @@ class GerritSource(BaseSource):
|
||||||
connection_name=self.connection.connection_name,
|
connection_name=self.connection.connection_name,
|
||||||
open=config.get('open'),
|
open=config.get('open'),
|
||||||
current_patchset=config.get('current-patchset'),
|
current_patchset=config.get('current-patchset'),
|
||||||
|
wip=config.get('wip'),
|
||||||
statuses=to_list(config.get('status')),
|
statuses=to_list(config.get('status')),
|
||||||
required_approvals=to_list(config.get('approval')),
|
required_approvals=to_list(config.get('approval')),
|
||||||
)
|
)
|
||||||
|
@ -234,6 +235,7 @@ def getRequireSchema():
|
||||||
require = {'approval': scalar_or_list(approval),
|
require = {'approval': scalar_or_list(approval),
|
||||||
'open': bool,
|
'open': bool,
|
||||||
'current-patchset': bool,
|
'current-patchset': bool,
|
||||||
|
'wip': bool,
|
||||||
'status': scalar_or_list(str)}
|
'status': scalar_or_list(str)}
|
||||||
|
|
||||||
return require
|
return require
|
||||||
|
|
|
@ -85,7 +85,8 @@ def getSchema():
|
||||||
'comment-added',
|
'comment-added',
|
||||||
'ref-updated',
|
'ref-updated',
|
||||||
'pending-check',
|
'pending-check',
|
||||||
'vote-deleted')),
|
'vote-deleted',
|
||||||
|
'wip-state-changed')),
|
||||||
'uuid': str,
|
'uuid': str,
|
||||||
'scheme': str,
|
'scheme': str,
|
||||||
'comment_filter': scalar_or_list(str),
|
'comment_filter': scalar_or_list(str),
|
||||||
|
|
Loading…
Reference in New Issue