Skip to content

Commit

Permalink
Merge pull request cms-sw#262 from nclopezo/allow-trigger-tests
Browse files Browse the repository at this point in the history
Allow only authorized people to trigger PR tests
  • Loading branch information
nclopezo committed Dec 16, 2014
2 parents 0440d95 + 5e49e78 commit ea232f2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions categories.py
Expand Up @@ -3,6 +3,7 @@

REQUEST_BUILD_RELEASE = [ "nclopezo" , "ktf", "smuzaffar", "degano", "davidlange6", "mark-grimes" ]
APPROVE_BUILD_RELEASE = [ "nclopezo" , "ktf", "smuzaffar", "degano", "davidlange6" ]
TRIGGER_PR_TESTS = [ "nclopezo" , "ktf", "smuzaffar", "degano", "davidlange6" ]

CMSSW_L2 = {
"Martin-Grunewald": ["hlt"],
Expand Down
35 changes: 34 additions & 1 deletion process-pull-request
Expand Up @@ -2,18 +2,33 @@
from github import Github
from os.path import expanduser
from optparse import OptionParser
from categories import CMSSW_CATEGORIES, CMSSW_L2, CMSSW_L1
from categories import CMSSW_CATEGORIES, CMSSW_L2, CMSSW_L1, TRIGGER_PR_TESTS
from releases import RELEASE_BRANCH_MILESTONE, RELEASE_BRANCH_PRODUCTION, RELEASE_BRANCH_CLOSED
from releases import RELEASE_MANAGERS
import yaml

import re
from sys import exit

TRIGERING_TESTS_MSG = 'The tests are being triggered in jenkins.'

# Prepare various comments regardless of whether they will be made or not.
def format(s, **kwds):
return s % kwds

#
# creates a properties file to trigger the test of the pull request
#
def create_properties_file_tests( pr_number ):
out_file_name = 'trigger-tests-%s.properties' % pr_number
if opts.dryRun:
print 'Not creating cleanup properties file (dry-run): %s' % out_file_name
else:
print 'Creating properties file %s' % out_file_name
out_file = open( out_file_name , 'w' )
out_file.write( '%s=%s\n' % ( 'PULL_REQUEST_LIST', pr_number ) )
out_file.close()

# Update the milestone for a given issue.
def updateMilestone(issue, pr):
if issue.milestone:
Expand Down Expand Up @@ -111,6 +126,8 @@ if __name__ == "__main__":
already_seen = False
pull_request_updated = False
comparison_done = False
tests_already_queued = False
tests_requested = False
# A pull request is by default closed if the branch is a closed one.
mustClose = False
mustMerge = False
Expand Down Expand Up @@ -143,6 +160,9 @@ if __name__ == "__main__":
if commenter == "cmsbuild":
if re.match("Comparison is ready", first_line):
comparison_done = True
if re.match( TRIGERING_TESTS_MSG, first_line):
tests_already_queued = True
print 'Tests already queued'

# Check actions made by L1.
# L1 signatures are only relevant for closed releases where
Expand Down Expand Up @@ -197,6 +217,13 @@ if __name__ == "__main__":
elif re.match("^[-](test|tested)$", first_line):
signatures["tests"] = "rejected"

# Check if the someone asked to trigger the tests
if commenter in TRIGGER_PR_TESTS:
if re.match("^please test$", first_line):
print 'Tests requested:', commenter, 'asked to test this PR'
tests_requested = True


print "The labels of the pull request should be:"
# Labels coming from signature.
labels = [x + "-pending" for x in signing_categories]
Expand Down Expand Up @@ -248,6 +275,12 @@ if __name__ == "__main__":
releaseManagersMsg = format("%(rm)s can you please take care of it?",
rm=releaseManagersList)

# trigger the tests and inform it in the thread.
if tests_requested and ( not tests_already_queued ):
create_properties_file_tests( prId )
if not opts.dryRun:
pr.create_issue_comment( TRIGERING_TESTS_MSG )

# Do not complain about tests
requiresTestMessage = "or unless it breaks tests."
if "tests-approved" in set(labels):
Expand Down

0 comments on commit ea232f2

Please sign in to comment.