Skip to content

Commit

Permalink
Allow manual override to PR test results
Browse files Browse the repository at this point in the history
  • Loading branch information
iarspider committed Nov 6, 2023
1 parent b786586 commit ead3af7
Show file tree
Hide file tree
Showing 262 changed files with 25,249 additions and 19,633 deletions.
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reformat everything with Black, part 1
d64ce0527da177ffaf4a9efcb1fc9fd31a9f416e
# Reformat everything with Black, part 2
64e3a6a4d9a8de478b780ea090fe33f2a8e8646f
19 changes: 19 additions & 0 deletions .github/workflows/black.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Black Style Check

on:
pull_request:
paths:
- '**/*.py'

jobs:
black_check:
name: Check Python Code Style with Black
runs-on: ubuntu-latest

steps:
- name: Check out the code
uses: actions/checkout@v2

- uses: psf/black@stable
with:
options: "--check --diff --verbose -l 99 -t py36 -t py37 -t py38 -t py39 -t py310 -t py311"
52 changes: 24 additions & 28 deletions DMWM/AggregatePylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
label = args[0]

try:
with open('pylintReport.json', 'r') as reportFile:
with open("pylintReport.json", "r") as reportFile:
report = json.load(reportFile)
except IOError:
report = {}
Expand All @@ -24,22 +24,22 @@
refactors = 0
score = 0

with open('pylint.out', 'r') as pylintFile:
with open("pylint.out", "r") as pylintFile:
for line in pylintFile:
if line.startswith('Your code has been rated at '):
scorePart = line.strip('Your code has been rated at ')
score = scorePart.split('/')[0]
if line.startswith("Your code has been rated at "):
scorePart = line.strip("Your code has been rated at ")
score = scorePart.split("/")[0]
try:
if not filename in report:
report[filename] = {}
if not label in report[filename]:
report[filename][label] = {}
if filename and label:
report[filename][label]['score'] = score
report[filename][label]["score"] = score
except NameError:
print("Score of %s found, but no filename" % score)

parts = line.split(':')
parts = line.split(":")
if len(parts) != 3:
continue
try:
Expand All @@ -49,47 +49,43 @@
continue
lineNumber = int(lineNumber)
filename = newFilename
rmParts = rawMessage.split(']', 1)
rmParts = rawMessage.split("]", 1)
rawCode = rmParts[0].strip()
message = rmParts[1].strip()
severity = rawCode[1:2]
code = rawCode[2:6]
shortMsg = rawCode[7:]
msgParts = shortMsg.split(',')
msgParts = shortMsg.split(",")
objectName = msgParts[1].strip()

if severity == 'R':
if severity == "R":
refactors += 1
elif severity == 'W':
elif severity == "W":
warnings += 1
elif severity == 'E':
elif severity == "E":
errors += 1
elif severity == 'C':
elif severity == "C":
comments += 1

if not filename in report:
report[filename] = {}

if not label in report[filename]:
report[filename][label] = {}
if not 'events' in report[filename][label]:
report[filename][label]['events'] = []
report[filename][label]['events'].append((lineNumber, severity, code, objectName, message))
if not "events" in report[filename][label]:
report[filename][label]["events"] = []
report[filename][label]["events"].append(
(lineNumber, severity, code, objectName, message)
)

report[filename][label]['refactors'] = refactors
report[filename][label]['warnings'] = warnings
report[filename][label]['errors'] = errors
report[filename][label]['comments'] = comments
report[filename][label]["refactors"] = refactors
report[filename][label]["warnings"] = warnings
report[filename][label]["errors"] = errors
report[filename][label]["comments"] = comments

except ValueError:
continue

with open('pylintReport.json', 'w') as reportFile:
with open("pylintReport.json", "w") as reportFile:
json.dump(report, reportFile, indent=2)
reportFile.write('\n')






reportFile.write("\n")
38 changes: 20 additions & 18 deletions DMWM/AnalyzePy27.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,60 @@

from github import Github

summaryMessage = ''
summaryMessage = ""
reportOn = {}
failed = False

with open('added.message', 'r') as messageFile:
with open("added.message", "r") as messageFile:
lines = messageFile.readlines()

if len(lines):
summaryMessage += 'Imports for Python3 compatability missing in new files. Please fix this:\n'
summaryMessage += (
"Imports for Python3 compatability missing in new files. Please fix this:\n"
)

summaryMessage += ''.join(lines)
summaryMessage += "".join(lines)
summaryMessage += "\n\n"
failed = True

with open('test.patch', 'r') as patchFile:
with open("test.patch", "r") as patchFile:
lines = patchFile.readlines()

if len(lines):
summaryMessage += 'Pre-python 2.6 constructs are introduced by this pull request. This must be fixed. Suggested patch follows:\n\n'
summaryMessage += "Pre-python 2.6 constructs are introduced by this pull request. This must be fixed. Suggested patch follows:\n\n"

summaryMessage += "```diff\n"
summaryMessage += ''.join(lines)
summaryMessage += "".join(lines)
summaryMessage += "\n```\n\n"
failed = True

with open('idioms.patch', 'r') as patchFile:
with open("idioms.patch", "r") as patchFile:
lines = patchFile.readlines()

if len(lines):
summaryMessage += 'Pre-python 2.6 idioms found in changed files. Please consider updating the code. Suggested patch follows:\n\n'
summaryMessage += "Pre-python 2.6 idioms found in changed files. Please consider updating the code. Suggested patch follows:\n\n"

summaryMessage += "```diff\n"
summaryMessage += ''.join(lines)
summaryMessage += "".join(lines)
summaryMessage += "\n```\n\n"


issueID = None

if 'ghprbPullId' in os.environ:
issueID = os.environ['ghprbPullId']
if "ghprbPullId" in os.environ:
issueID = os.environ["ghprbPullId"]

gh = Github(os.environ['DMWMBOT_TOKEN'])
codeRepo = os.environ.get('CODE_REPO', 'WMCore')
repoName = '%s/%s' % (os.environ['WMCORE_REPO'], codeRepo)
gh = Github(os.environ["DMWMBOT_TOKEN"])
codeRepo = os.environ.get("CODE_REPO", "WMCore")
repoName = "%s/%s" % (os.environ["WMCORE_REPO"], codeRepo)

issue = gh.get_repo(repoName).get_issue(int(issueID))
if len(summaryMessage) > 250000:
summaryMessage = summaryMessage[:250000]
if summaryMessage:
issue.create_comment('%s' % summaryMessage)
issue.create_comment("%s" % summaryMessage)

if failed:
print('Testing of python code. DMWM-FAIL-PY27')
print("Testing of python code. DMWM-FAIL-PY27")
else:
print('Testing of python code. DMWM-SUCCEED-PY27')
print("Testing of python code. DMWM-SUCCEED-PY27")
15 changes: 9 additions & 6 deletions DMWM/AnalyzePyFuture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

from __future__ import print_function, division

with open('addedFiles.txt', 'r') as addedFiles:
with open("addedFiles.txt", "r") as addedFiles:
for fileName in addedFiles:
fileName = fileName.strip()
if fileName.endswith('__init__.py'):
if fileName.endswith("__init__.py"):
continue
with open(fileName, 'r') as pyFile:
with open(fileName, "r") as pyFile:
pyLines = pyFile.readlines()
if fileName.endswith('.py') or 'python' in pyLines[0]:
if fileName.endswith(".py") or "python" in pyLines[0]:
foundDivision = False
for line in pyLines:
if '__future__' in line and 'division' in line:
if "__future__" in line and "division" in line:
foundDivision = True
if not foundDivision:
print ("* New file %s does not use python 3 division. Please add `from __future__ import division`.\n" % fileName)
print(
"* New file %s does not use python 3 division. Please add `from __future__ import division`.\n"
% fileName
)
Loading

0 comments on commit ead3af7

Please sign in to comment.