Separate votes from Jenkins queues

It was seen that all the queues for Jenkins post the vote under
same ci_owner. This patch separates out the votes based on the
queues.

Also includes performance improvements during compilation of
regex patterns.

Change-Id: I998749316d0b0488068ca20f9be68faf3caecd3a
Closes-Bug: #1517677
This commit is contained in:
apoorvad 2015-12-15 11:43:57 -08:00
parent 5d66cc9fa0
commit 7b96be1572
1 changed files with 18 additions and 5 deletions

View File

@ -23,21 +23,34 @@ from ciwatch import db
from ciwatch.log import logger
from ciwatch import models
pipeline_pattern = re.compile("\((.*)\spipeline\)")
possible_results = "FAILURE|SUCCESS|NOT_REGISTERED|UNSTABLE"
comment_pattern = re.compile("[-*]\s+([^\s*]+)\s+(http[^\s*]+) : (%s)" %
possible_results)
jenkins_check = "Jenkins check"
def _process_project_name(project_name):
return project_name.split('/')[-1]
def is_jenkins_pipeline(line):
match = pipeline_pattern.search(line)
if match is not None:
return match.group(1)
def _process_event(event):
comment = event['comment']
# Find all the CIs voting in this comment
lines = comment.splitlines()
event['ci-status'] = {}
pipeline = is_jenkins_pipeline(lines[0])
if pipeline is not None:
event["author"]["name"] = event["author"]["name"] + ' ' + pipeline
for line in lines:
possible_results = "FAILURE|SUCCESS|NOT_REGISTERED|UNSTABLE"
pattern = re.compile("[-*]\s+([^\s*]+)\s+(http[^\s*]+) : (%s)" %
possible_results)
match = pattern.search(line)
match = comment_pattern.search(line)
if match is not None:
ci_name = match.group(1)
log_url = match.group(2)
@ -131,7 +144,7 @@ def add_event_to_db(event, commit_=True):
commit_message=event['change']['commitMessage'],
created=datetime.fromtimestamp(
int(event['patchSet']['createdOn'])))
trusted = (event["author"]["username"] == "jenkins")
trusted = (event["author"]["name"] == jenkins_check)
if trusted and "approvals" in event:
if event["approvals"][0]["value"] in ("1", "2"):