summaryrefslogtreecommitdiff
path: root/zuul/driver/github/githubmodel.py
diff options
context:
space:
mode:
authorJesse Keating <omgjlk@us.ibm.com>2017-01-19 13:55:50 -0800
committerJesse Keating <omgjlk@us.ibm.com>2017-05-23 17:00:51 -0700
commitd96e5887b8b2de3ab000036c5aa355d53ac86de9 (patch)
tree663ea6adc9b67870f18ca875dc00fe3924684192 /zuul/driver/github/githubmodel.py
parent2cf8d2ac6d045d22f66b28c3d5bac5a6721945cb (diff)
downloadzuul-d96e5887b8b2de3ab000036c5aa355d53ac86de9.tar.gz
Add support for requiring github pr head status
When creating a github pull request change object, the statuses of the head commit are fetched, and the latest status of each user and context set is appended into a list of statuses. The string is 'user:context:state', where state can be success, error, or failure. Context is freeform, and the user is the login of the entity that set the status. Tests have been added to validate that github based requirements on pipelines are honored. Change-Id: I45abbd6cbddd36b8491bdf9bb8d545216537ad2f Signed-off-by: Jesse Keating <omgjlk@us.ibm.com>
Diffstat (limited to 'zuul/driver/github/githubmodel.py')
-rw-r--r--zuul/driver/github/githubmodel.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/zuul/driver/github/githubmodel.py b/zuul/driver/github/githubmodel.py
index 0d77cae34..22f549fa9 100644
--- a/zuul/driver/github/githubmodel.py
+++ b/zuul/driver/github/githubmodel.py
@@ -16,7 +16,7 @@
import re
-from zuul.model import Change, TriggerEvent, EventFilter
+from zuul.model import Change, TriggerEvent, EventFilter, RefFilter
EMPTY_GIT_REF = '0' * 40 # git sha of all zeros, used during creates/deletes
@@ -161,3 +161,31 @@ class GithubEventFilter(EventFilter):
return False
return True
+
+
+class GithubRefFilter(RefFilter):
+ def __init__(self, statuses=[]):
+ RefFilter.__init__(self)
+
+ self.statuses = statuses
+
+ def __repr__(self):
+ ret = '<GithubRefFilter'
+
+ if self.statuses:
+ ret += ' statuses: %s' % ', '.join(self.statuses)
+
+ ret += '>'
+
+ return ret
+
+ def matches(self, change):
+ # statuses are ORed
+ # A PR head can have multiple statuses on it. If the change
+ # statuses and the filter statuses are a null intersection, there
+ # are no matches and we return false
+ if self.statuses:
+ if set(change.status).isdisjoint(set(self.statuses)):
+ return False
+
+ return True