From cc5c7dfc6d01cd4fd9bcc8a89234ea6be72b996b Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Fri, 28 Jan 2022 14:10:25 -0500 Subject: [PATCH] Make jenkins python2 checks optional --- jenkins_python/scripts/PullRequestReport.py | 45 ++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/jenkins_python/scripts/PullRequestReport.py b/jenkins_python/scripts/PullRequestReport.py index 6de76c6..1827611 100755 --- a/jenkins_python/scripts/PullRequestReport.py +++ b/jenkins_python/scripts/PullRequestReport.py @@ -290,8 +290,10 @@ def buildPyFutureReport(templateEnv): html.write(py3UnitTestSummaryHTML) if py2UnitTestSummary: html.write(py2UnitTestSummaryHTML) - html.write(pylintSummaryHTML) - html.write(pylintReport) + if pylintSummaryHTML: + html.write(pylintSummaryHTML) + if pylintReport: + html.write(pylintReport) if pylintSummaryPy3: html.write(pylintSummaryHTMLPy3) html.write(pylintReportPy3) @@ -353,13 +355,14 @@ def buildPyFutureReport(templateEnv): if py3UnitTestSummary['unstableChanges']: message += ' * %s changes in unstable tests\n' % py3UnitTestSummary['unstableChanges'] -message += ' * Python2 Pylint check: %s\n' % statusMap[failedPylint]['readStatus'] -if pylintSummary['failures']: - message += ' * %s warnings and errors that must be fixed\n' % pylintSummary['failures'] -if pylintSummary['warnings']: - message += ' * %s warnings\n' % pylintSummary['warnings'] -if pylintSummary['comments']: - message += ' * %s comments to review\n' % pylintSummary['comments'] +if pylintSummary: + message += ' * Python2 Pylint check: %s\n' % statusMap[failedPylint]['readStatus'] + if pylintSummary['failures']: + message += ' * %s warnings and errors that must be fixed\n' % pylintSummary['failures'] + if pylintSummary['warnings']: + message += ' * %s warnings\n' % pylintSummary['warnings'] + if pylintSummary['comments']: + message += ' * %s comments to review\n' % pylintSummary['comments'] if pylintSummaryPy3: message += ' * Python3 Pylint check: %s\n' % statusMap[failedPylintPy3]['readStatus'] @@ -397,8 +400,10 @@ def buildPyFutureReport(templateEnv): timeNow = time.strftime("%d %b %Y %H:%M GMT") lastCommit = repo.get_pull(int(issueID)).get_commits().get_page(0)[-1] -lastCommit.create_status(state=statusMap[failedPylint]['ghStatus'], target_url=reportURL + '#pylintpy2', - description='Finished at %s' % timeNow, context='Py2 Pylint') + +if pylintSummary: + lastCommit.create_status(state=statusMap[failedPylint]['ghStatus'], target_url=reportURL + '#pylintpy2', + description='Finished at %s' % timeNow, context='Py2 Pylint') if pylintSummaryPy3: lastCommit.create_status(state=statusMap[failedPylint]['ghStatus'], target_url=reportURL + '#pylintpy3', description='Finished at %s' % timeNow, context='Py3 Pylint') @@ -415,10 +420,11 @@ def buildPyFutureReport(templateEnv): lastCommit.create_status(state=statusMap[failedPyFuture]['ghStatus'], target_url=reportURL + '#pyfuture', description='Finished at %s' % timeNow, context='Python3 compatibility') -if failedPylint: - print('Testing of python code. DMWM-FAIL-PYLINT') -else: - print('Testing of python code. DMWM-SUCCEED-PYLINT') +if pylintSummary: + if failedPylint: + print('Testing of python code. DMWM-FAIL-PYLINT') + else: + print('Testing of python code. DMWM-SUCCEED-PYLINT') if pylintSummary3k: if failedPy3k: @@ -426,10 +432,11 @@ def buildPyFutureReport(templateEnv): elif pylintSummary3k: print('Testing of python code. DMWM-SUCCEED-PYLINT3k') -if py2FailedUnitTests: - print('Testing of python code. DMWM-FAIL-PY2-UNIT') -else: - print('Testing of python code. DMWM-SUCCEED-PY2-UNIT') +if py2UnitTestSummary: + if py2FailedUnitTests: + print('Testing of python code. DMWM-FAIL-PY2-UNIT') + else: + print('Testing of python code. DMWM-SUCCEED-PY2-UNIT') if py3UnitTestSummary: if py3FailedUnitTests: