Skip to content

Commit

Permalink
Merge pull request #1412 from cms-sw/run-das-query-test
Browse files Browse the repository at this point in the history
added run das queries test for PRs; reset statues on rerun
  • Loading branch information
smuzaffar authored Nov 11, 2020
2 parents a3a288d + 4817811 commit 60849d5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
14 changes: 13 additions & 1 deletion github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,20 @@ def get_gh_token(repository=None):
import repo_config
return open(expanduser(repo_config.GH_TOKEN)).read().strip()

def get_combined_statuses(commit, repository, token=None):
if not token: token = get_gh_token(repository)
return github_api("/repos/%s/commits/%s/status" % (repository, commit), token, method='GET')

def mark_commit_status(commit, repository, context="default", state="pending", url="", description="Test started", token=None):
def mark_commit_status(commit, repository, context="default", state="pending", url="", description="Test started", token=None, reset=False):
if not token: token = get_gh_token(repository)
params = {'state': state, 'target_url': url, 'description': description, 'context': context}
github_api('/repos/%s/statuses/%s' % (repository, commit), token, params)
if reset:
statuses = get_combined_statuses(commit, repository, token)
if 'statuses' not in statuses: return
params = {'state': 'pending', 'target_url': '', 'description': 'Not yet started'}
for s in statuses['statuses']:
if s['context'].startswith(context+"/"):
params['context'] = s['context']
github_api('/repos/%s/statuses/%s' % (repository, commit), token, params)
return
3 changes: 2 additions & 1 deletion mark_commit_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
parser.add_option("-C", "--context", dest="context", help="Status context", type=str, default="default")
parser.add_option("-u", "--url", dest="url", help="Status results URL", type=str, default="")
parser.add_option("-s", "--state", dest="state", help="State of the status e.g. pending, failure, error or success", type=str, default='pending')
parser.add_option("-R", "--reset-all", dest="reset_all", help="Reset all matching contexts", action="store_true", default=False)
opts, args = parser.parse_args()

mark_commit_status(opts.commit, opts.repository, opts.context, opts.state, opts.url, opts.description)
mark_commit_status(opts.commit, opts.repository, opts.context, opts.state, opts.url, opts.description, reset=opts.reset_all)

15 changes: 15 additions & 0 deletions pr_testing/run-das-query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
from __future__ import print_function
import os, sys
BOT_DIR=os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
sys.path.insert(0,BOT_DIR)
from _py2with3compatibility import run_cmd
from cmsutils import MachineCPUCount
from RelValArgs import GetMatrixOptions

os.environ["PATH"] = "%s/das-utils:%s" % (BOT_DIR, os.environ["PATH"])
cmd = "runTheMatrix.py -j %s --maxSteps=0 %s" % (MachineCPUCount, GetMatrixOptions(os.environ["CMSSW_VERSION"], os.environ["SCRAM_ARCH"]))
print("Running ",cmd)
e, o = run_cmd(cmd)
print(o)
if e: sys.exit(1)
37 changes: 32 additions & 5 deletions pr_testing/test_multiple_prs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function prepare_upload_results (){
else
mkdir -p upload
fi
for f in testsResults build-logs clang-logs runTheMatrix-results llvm-analysis *.log *.html *.txt *.js DQMTestsResults valgrindResults-* cfg-viewerResults igprof-results-data git-merge-result git-log-recent-commits addOnTests codeRules dupDict material-budget ; do
for f in dasqueries testsResults build-logs clang-logs runTheMatrix-results llvm-analysis *.log *.html *.txt *.js DQMTestsResults valgrindResults-* cfg-viewerResults igprof-results-data git-merge-result git-log-recent-commits addOnTests codeRules dupDict material-budget ; do
[ -e $f ] && mv $f upload/$f
done
if [ -e upload/renderPRTests.js ] ; then mkdir -p upload/js && mv upload/renderPRTests.js upload/js/ ; fi
Expand Down Expand Up @@ -176,7 +176,7 @@ for PR in ${PULL_REQUESTS}; do
echo "${PR}=${COMMIT}" >> ${WORKSPACE}/prs_commits.txt
done

mark_commit_status_all_prs '' 'pending' -u "${BUILD_URL}" -d 'Setting up build environment' || true
mark_commit_status_all_prs '' 'pending' -u "${BUILD_URL}" -d 'Setting up build environment' --reset || true

COMP_QUEUE=
case $CMSSW_QUEUE in
Expand Down Expand Up @@ -911,6 +911,27 @@ if [ "X$DO_DUPLICATE_CHECKS" = Xtrue -a "$ONLY_FIREWORKS" = false -a "X$CMSDIST_
fi

export CMS_PATH=/cvmfs/cms-ib.cern.ch
#
#Checking runTheMatrix das-queries
#
DAS_QUERY_RES="NOTRUN"
if [ "X$DO_SHORT_MATRIX" = Xtrue -a "X$BUILD_OK" = Xtrue -a "$ONLY_FIREWORKS" = false -a "$RUN_TESTS" = "true" ]; then
if [ $(runTheMatrix.py --help | grep ibeos | wc -l) -gt 0 ] ; then
mkdir -p $WORKSPACE/dasqueries/run
DAS_QUERY_RES="OK"
pushd $WORKSPACE/dasqueries/run
$SCRIPTPATH/run-das-query.py > ../run.txt 2>&1 || DAS_QUERY_RES="ERROR"
if [ -f runall-report-step123-.log ] ; then
grep 'FAILED' runall-report-step123-.log > ../failed_workflows.log || true
mv runall-report-step123-.log ..
if [ -s ../failed_workflows.log ] ; then DAS_QUERY_RES="ERROR" ; fi
fi
popd
rm -rf $WORKSPACE/dasqueries/run
echo "DAS_QUERIES;${DAS_QUERY_RES},DAS Queries,See Logs,dasqueries" >> ${RESULTS_FILE}/dasqueries.txt
fi
fi

#
# Unit tests
#
Expand Down Expand Up @@ -1247,11 +1268,14 @@ env | grep 'CMSSW_'
REPORT_OPTS="--report-pr ${REPORT_H_CODE} --pr-job-id ${BUILD_NUMBER} --recent-merges $RECENT_COMMITS_FILE $NO_POST"

if ${ALL_OK} ; then # if non of the test failed (non of them set ALL_OK to false)
BUILD_LOG_RES=""
if [ "${DAS_QUERY_RES}" = "ERROR" ] ; then
BUILD_LOG_RES="DAS Queries failed;"
fi
if [ "${BUILD_LOG_RES}" = "ERROR" ] ; then
BUILD_LOG_RES=" --add-comment 'Compilation Warnings: Yes'"
else
BUILD_LOG_RES=""
BUILD_LOG_RES="${BUILD_LOG_RES} Found compilation warnings'"
fi
if [ "${BUILD_LOG_RES}" != "" ] ; then BUILD_LOG_RES=" --add-comment '${BUILD_LOG_RES}'" ; fi
REPORT_OPTS="TESTS_OK_PR ${REPORT_OPTS} ${BUILD_LOG_RES}"
mark_commit_status_all_prs '' 'success' -u "${BUILD_URL}" -d "Passed" || true
else
Expand Down Expand Up @@ -1284,6 +1308,9 @@ else
if [ "X$PYTHON3_BUILD_OK" = Xfalse ]; then
$CMS_BOT_DIR/report-pull-request-results PYTHON3_FAIL -f $WORKSPACE/upload/python3.log ${REPORT_GEN_OPTS}
fi
if [ "${DAS_QUERY_RES}" = "ERROR" ] ; then
echo -e "\n* **DAS Queries**: The DAS query tests failed, see the summary page for details.\n" >> $WORKSPACE/report.txt
fi
REPORT_OPTS="REPORT_ERRORS ${REPORT_OPTS}" # Doc:
mark_commit_status_all_prs '' 'error' -u "${BUILD_URL}" -d "Failed: ${TESTS_FAILED}" || true
fi
Expand Down

0 comments on commit 60849d5

Please sign in to comment.