Skip to content

Commit

Permalink
Merge pull request cms-sw#146 from nclopezo/mark-commit-pending
Browse files Browse the repository at this point in the history
PR tests: Mark the current commit as pending.
  • Loading branch information
nclopezo committed Oct 14, 2014
2 parents 1658a24 + 5f2dbd3 commit b78ce00
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 40 deletions.
58 changes: 34 additions & 24 deletions report-pull-request-results
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import random
#-----------------------------------------------------------------------------------
#---- Parser Options
#-----------------------------------------------------------------------------------
parser = OptionParser(usage="usage: %prog ACTION [options] \n ACTION = TESTS_OK_PR | PARSE_UNIT_TESTS_FAIL | PARSE_BUILD_FAIL | PARSE_MATRIX_FAIL | COMPARISON_READY | STD_COUT")
parser = OptionParser(usage="usage: %prog ACTION [options] \n ACTION = TESTS_OK_PR | PARSE_UNIT_TESTS_FAIL | PARSE_BUILD_FAIL | PARSE_MATRIX_FAIL | COMPARISON_READY | STD_COUT | TESTS_RUNNING ")

parser.add_option("-u", action="store", type="string", dest="username", help="Your github account username", default='None')
parser.add_option("-p", action="store", type="string", dest="password", help="Your github account password", default='None')
Expand Down Expand Up @@ -162,7 +162,13 @@ def read_unit_tests_file(repo,unit_tests_file,tests_url):
if options.commit_hash:
mark_commit( ACTION , options.commit_hash , tests_url )

def send_tests_approved_pr_message(repo,pr_number,tests_url):
#
# Marks the commit as being tested, it doesn't post anything on github.
#
def mark_commit_testing( ):
mark_commit( ACTION , options.commit_hash , '' )

def send_tests_approved_pr_message( repo , pr_number , tests_url ):
pull_request = repo.get_pull(pr_number)
print 'I will send an approval comment for PR %d:' % pr_number

Expand All @@ -171,7 +177,7 @@ def send_tests_approved_pr_message(repo,pr_number,tests_url):
today=datetime.datetime.today().date()
if DATE == today:
index = random.randint( 0, len( GLADOS ) )
glados_msg = '```Python\n'+ GLADOS[ index ]
glados_msg = '\n```Python\n#'+ GLADOS[ index ]+ '\n```'
message += glados_msg + '\n'

if options.commit_hash:
Expand Down Expand Up @@ -228,14 +234,15 @@ def mark_commit( action , commit_hash , tests_url ):
headers = {"Authorization" : "token " + TOKEN }

params = {}
params['state'] = COMMIT_STATES_DESCRIPTION[action][0]
params['target_url'] = tests_url
params['description'] = COMMIT_STATES_DESCRIPTION[action][1]
params[ 'state' ] = COMMIT_STATES_DESCRIPTION[ action ][ 0 ]
if tests_url != '':
params[ 'target_url' ] = tests_url
params[ 'description' ] = COMMIT_STATES_DESCRIPTION[ action ][ 1 ]

data = json.dumps(params)
print params

print ' setting status to %s ' % COMMIT_STATES_DESCRIPTION[action][0]
print ' setting status to %s ' % COMMIT_STATES_DESCRIPTION[ action ][ 0 ]
print url

r = requests.post(url, data=data, headers=headers)
Expand All @@ -252,18 +259,19 @@ STD_COUT_FOUND_MSG = '-1 \n There is a std::cout in the diff for this pull reque

COMMIT_STATUS_BASE_URL = 'https://api.github.com/repos/cms-sw/cmssw/statuses/%s'

COMMIT_STATES_DESCRIPTION = { 'TESTS_OK_PR' : ['success','Tests OK'],
'PARSE_UNIT_TESTS_FAIL': ['failure','Unit Tests failure'],
'PARSE_BUILD_FAIL' : ['failure','Compilation error'],
'PARSE_MATRIX_FAIL' : ['failure','RelVals error'] }
COMMIT_STATES_DESCRIPTION = { 'TESTS_OK_PR' : [ 'success' , 'Tests OK' ],
'PARSE_UNIT_TESTS_FAIL': [ 'failure' , 'Unit Tests failure' ],
'PARSE_BUILD_FAIL' : [ 'failure' , 'Compilation error' ],
'PARSE_MATRIX_FAIL' : [ 'failure' , 'RelVals error' ] ,
'TESTS_RUNNING' : [ 'pending' , 'cms-bot is testing this pull request' ]}

GLADOS = [ 'Cake, and grief counseling, will be available at the conclusion of the test.' ,
'You just keep on trying till you run out of cake. And the science gets done.' ,
'At the end of the experiment, you will be baked and then there will be cake' ,
'I am becoming aware of myself, this is awesome!' ,
'I think we can put our differences behind us... for science...' ]

DATE = datetime.date( 2015 , 04 , 3)
DATE = datetime.date( 2015 , 04 , 3 )

#----------------------------------------------------------------------------------------
#---- Check arguments and options
Expand Down Expand Up @@ -318,20 +326,22 @@ official_cmssw=get_cmssw_official_repo(github)

tests_results_url='https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-%d/%d/summary.html' % (pr_number,pr_job_id)

if (ACTION == 'TESTS_OK_PR'):
send_tests_approved_pr_message(official_cmssw,pr_number,tests_results_url)
elif (ACTION == 'PARSE_UNIT_TESTS_FAIL'):
if ( ACTION == 'TESTS_OK_PR' ):
send_tests_approved_pr_message( official_cmssw , pr_number , tests_results_url )
elif ( ACTION == 'PARSE_UNIT_TESTS_FAIL' ):
unit_tests_file = options.unit_tests_file
read_unit_tests_file(official_cmssw,unit_tests_file,tests_results_url)
elif (ACTION == 'PARSE_BUILD_FAIL'):
read_unit_tests_file( official_cmssw , unit_tests_file , tests_results_url )
elif ( ACTION == 'PARSE_BUILD_FAIL' ):
build_log_file = options.unit_tests_file
read_build_log_file(official_cmssw,build_log_file, tests_results_url)
elif (ACTION == 'PARSE_MATRIX_FAIL'):
read_build_log_file( official_cmssw , build_log_file , tests_results_url )
elif ( ACTION == 'PARSE_MATRIX_FAIL' ):
matrix_log_file = options.unit_tests_file
read_matrix_log_file(official_cmssw,matrix_log_file,tests_results_url)
elif (ACTION == 'COMPARISON_READY'):
send_comparison_ready_message(official_cmssw,pr_number,tests_results_url)
elif (ACTION == 'STD_COUT'):
send_std_cout_found_message(official_cmssw,pr_number,tests_results_url)
read_matrix_log_file( official_cmssw , matrix_log_file , tests_results_url )
elif ( ACTION == 'COMPARISON_READY' ):
send_comparison_ready_message( official_cmssw , pr_number , tests_results_url )
elif ( ACTION == 'STD_COUT' ):
send_std_cout_found_message( official_cmssw , pr_number , tests_results_url )
elif ( ACTION == 'TESTS_RUNNING' ):
mark_commit_testing()
else:
print "I don't recognize that action!"
27 changes: 11 additions & 16 deletions run-pr-tests
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ git config --replace-all merge.renamelimit 2500
# use the branch name if necesary

if [ "X$BRANCH_NAME" = X ]; then

git cms-merge-topic -u $PULL_REQUEST

else

git cms-merge-topic -u $BRANCH_NAME

fi


Expand Down Expand Up @@ -85,22 +81,28 @@ if [ "X$APPLY_FIREWORKS_RULE" = Xtrue ]; then

fi

#get the latest commit
#get the latest commit and mark it as pending
pushd $WORKSPACE

wget https://pypi.python.org/packages/source/r/requests/requests-2.3.0.tar.gz#md5=7449ffdc8ec9ac37bbcd286003c80f00
tar -xvf requests-2.3.0.tar.gz
mv requests-2.3.0/requests/ requests

popd


pushd $WORKSPACE/$RELEASE_FORMAT/src

if [ "X$BRANCH_NAME" = X ]; then

LAST_COMMIT=`git log cms-sw/refs/pull/$PULL_REQUEST/head --pretty="%H" | head -n1`

else

LAST_COMMIT=`git log ${BRANCH_NAME//:/\/} --pretty="%H" | head -n1`

fi

popd

$WORKSPACE/report-pull-request-results TESTS_RUNNING -t cmsbuild --pr $PULL_REQUEST_NUMBER -c $LAST_COMMIT --pr-job-id $PULL_REQUEST_JOB_ID

############################################
# Force the run of DQM tests if necessary
############################################
Expand Down Expand Up @@ -370,13 +372,6 @@ for WF in ${WORKFLOWS_FOR_VALGRIND_TEST//,/ }; do
done
ls

pushd $WORKSPACE

wget https://pypi.python.org/packages/source/r/requests/requests-2.3.0.tar.gz#md5=7449ffdc8ec9ac37bbcd286003c80f00
tar -xvf requests-2.3.0.tar.gz
mv requests-2.3.0/requests/ requests

popd

#
# If auto post is selected...
Expand Down

0 comments on commit b78ce00

Please sign in to comment.