mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-07 12:32:54 +00:00
Update parse-reports to handle new paths
This commit is contained in:
parent
1c890e5a5c
commit
9cd728fea9
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import sys
|
|
||||||
import nbtlib
|
|
||||||
from nbtlib.tag import Compound, Int, List, String
|
|
||||||
|
|
||||||
_, file = sys.argv
|
|
||||||
|
|
||||||
with open(file, "r") as h:
|
|
||||||
structure = nbtlib.parse_nbt(h.read())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def make_state(item: dict) -> str:
|
|
||||||
name = item["Name"]
|
|
||||||
if "Properties" in item:
|
|
||||||
name += "{" + ",".join(f"{k}:{v}" for k, v in item["Properties"].items()) + "}"
|
|
||||||
return String(name)
|
|
||||||
|
|
||||||
def make_block(block: dict, new_palette: list) -> dict:
|
|
||||||
res = {
|
|
||||||
"pos": block["pos"],
|
|
||||||
"state": new_palette[block["state"]],
|
|
||||||
}
|
|
||||||
if "nbt" in block:
|
|
||||||
res["nbt"] = block["nbt"]
|
|
||||||
return Compound(res)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
new_palette = [make_state(x) for x in structure['palette']]
|
|
||||||
new_result = Compound({
|
|
||||||
"DataVersion": Int(2730),
|
|
||||||
"size": structure["size"],
|
|
||||||
"entities": structure["entities"],
|
|
||||||
"data": List([make_block(x, new_palette) for x in structure["blocks"]]),
|
|
||||||
"palette": List(new_palette),
|
|
||||||
})
|
|
||||||
|
|
||||||
with open(file, "w") as h:
|
|
||||||
h.write(nbtlib.serialize_tag(new_result, indent=4))
|
|
@ -27,15 +27,27 @@ SOURCE_LOCATIONS = [
|
|||||||
"src/test/resources",
|
"src/test/resources",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
PROJECT_LOCATIONS = [
|
||||||
|
".",
|
||||||
|
"projects/core-api",
|
||||||
|
"projects/core",
|
||||||
|
"projects/common",
|
||||||
|
"projects/common-api",
|
||||||
|
"projects/forge-api",
|
||||||
|
]
|
||||||
|
|
||||||
|
TEST_REPORTS = []
|
||||||
|
|
||||||
|
|
||||||
def find_file(path: str) -> Optional[str]:
|
def find_file(path: str) -> Optional[str]:
|
||||||
while len(path) > 0 and path[0] == '/':
|
while len(path) > 0 and path[0] == "/":
|
||||||
path = path[1:]
|
path = path[1:]
|
||||||
|
|
||||||
for source_dir in SOURCE_LOCATIONS:
|
for project in PROJECT_LOCATIONS:
|
||||||
child_path = os.path.join(source_dir, path)
|
for source_dir in SOURCE_LOCATIONS:
|
||||||
if os.path.exists(child_path):
|
child_path = os.path.join(project, source_dir, path)
|
||||||
return child_path
|
if os.path.exists(child_path):
|
||||||
|
return child_path
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -61,6 +73,35 @@ def find_location(message: str) -> Optional[Tuple[str, str]]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_junit_file(path: pathlib.Path):
|
||||||
|
for testcase in ET.parse(path).getroot():
|
||||||
|
if testcase.tag != "testcase":
|
||||||
|
continue
|
||||||
|
|
||||||
|
for result in testcase:
|
||||||
|
if result.tag != "failure":
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = f'{testcase.attrib["classname"]}.{testcase.attrib["name"]}'
|
||||||
|
message = result.attrib.get("message")
|
||||||
|
|
||||||
|
location = find_location(result.text)
|
||||||
|
error = ERROR_MESSAGE.match(message)
|
||||||
|
if error:
|
||||||
|
error = error[1]
|
||||||
|
else:
|
||||||
|
error = message
|
||||||
|
|
||||||
|
if location:
|
||||||
|
print(f'## {location[0]}:{location[1]}: {name} failed: {SPACES.sub(" ", error)}')
|
||||||
|
else:
|
||||||
|
print(f"::error::{name} failed")
|
||||||
|
|
||||||
|
print("::group::Full error message")
|
||||||
|
print(result.text)
|
||||||
|
print("::endgroup")
|
||||||
|
|
||||||
|
|
||||||
def parse_junit() -> None:
|
def parse_junit() -> None:
|
||||||
"""
|
"""
|
||||||
Scrape JUnit test reports for errors. We determine the location from the Lua
|
Scrape JUnit test reports for errors. We determine the location from the Lua
|
||||||
@ -68,37 +109,24 @@ def parse_junit() -> None:
|
|||||||
"""
|
"""
|
||||||
print("::add-matcher::.github/matchers/junit.json")
|
print("::add-matcher::.github/matchers/junit.json")
|
||||||
|
|
||||||
for path in pathlib.Path("build/test-results/test").glob("TEST-*.xml"):
|
for project in PROJECT_LOCATIONS:
|
||||||
for testcase in ET.parse(path).getroot():
|
for path in pathlib.Path(os.path.join(project, "build/test-results/test")).glob("TEST-*.xml"):
|
||||||
if testcase.tag != "testcase":
|
_parse_junit_file(path)
|
||||||
continue
|
|
||||||
|
|
||||||
for result in testcase:
|
|
||||||
if result.tag != "failure":
|
|
||||||
continue
|
|
||||||
|
|
||||||
name = f'{testcase.attrib["classname"]}.{testcase.attrib["name"]}'
|
|
||||||
message = result.attrib.get('message')
|
|
||||||
|
|
||||||
location = find_location(result.text)
|
|
||||||
error = ERROR_MESSAGE.match(message)
|
|
||||||
if error:
|
|
||||||
error = error[1]
|
|
||||||
else:
|
|
||||||
error = message
|
|
||||||
|
|
||||||
if location:
|
|
||||||
print(f'## {location[0]}:{location[1]}: {name} failed: {SPACES.sub(" ", error)}')
|
|
||||||
else:
|
|
||||||
print(f'::error::{name} failed')
|
|
||||||
|
|
||||||
print("::group::Full error message")
|
|
||||||
print(result.text)
|
|
||||||
print("::endgroup")
|
|
||||||
|
|
||||||
print("::remove-matcher owner=junit::")
|
print("::remove-matcher owner=junit::")
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_checkstyle(path: pathlib.Path):
|
||||||
|
for file in ET.parse(path).getroot():
|
||||||
|
for error in file:
|
||||||
|
filename = os.path.relpath(file.attrib["name"])
|
||||||
|
|
||||||
|
attrib = error.attrib
|
||||||
|
print(
|
||||||
|
f'{attrib["severity"]} {filename}:{attrib["line"]}:{attrib.get("column", 1)}: {SPACES.sub(" ", attrib["message"])}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_checkstyle() -> None:
|
def parse_checkstyle() -> None:
|
||||||
"""
|
"""
|
||||||
Scrape JUnit test reports for errors. We determine the location from the Lua
|
Scrape JUnit test reports for errors. We determine the location from the Lua
|
||||||
@ -106,16 +134,13 @@ def parse_checkstyle() -> None:
|
|||||||
"""
|
"""
|
||||||
print("::add-matcher::.github/matchers/checkstyle.json")
|
print("::add-matcher::.github/matchers/checkstyle.json")
|
||||||
|
|
||||||
for path in pathlib.Path("build/reports/checkstyle/").glob("*.xml"):
|
for project in PROJECT_LOCATIONS:
|
||||||
for file in ET.parse(path).getroot():
|
for path in pathlib.Path(os.path.join(project, "build/reports/checkstyle/")).glob("*.xml"):
|
||||||
for error in file:
|
_parse_checkstyle(path)
|
||||||
filename = os.path.relpath(file.attrib['name'])
|
|
||||||
|
|
||||||
attrib = error.attrib
|
|
||||||
print(f'{attrib["severity"]} {filename}:{attrib["line"]}:{attrib.get("column", 1)}: {SPACES.sub(" ", attrib["message"])}')
|
|
||||||
|
|
||||||
print("::remove-matcher owner=checkstyle::")
|
print("::remove-matcher owner=checkstyle::")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
parse_junit()
|
parse_junit()
|
||||||
parse_checkstyle()
|
parse_checkstyle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user