Improved pyproject.toml reading if settings don't exist.

This commit is contained in:
Patrick Lehmann
2025-10-04 21:30:24 +02:00
parent 5b97eaf241
commit 05e5d1f86c
3 changed files with 80 additions and 19 deletions

View File

@@ -114,7 +114,7 @@ jobs:
coverageRC = "${{ inputs.coverage_config }}".strip()
typingCoberturaFile = Path("report/typing/cobertura.xml")
typingJUnitFile = Path("report/typing/StaticTypingSummary.xml")
typingHTMLDirectory = Path("htmlmypy")
typingHTMLDirectory = Path("report/typing/html")
# Read output paths from 'pyproject.toml' file
if coverageRC == "pyproject.toml":
@@ -123,14 +123,34 @@ jobs:
with pyProjectFile.open("rb") as file:
pyProjectSettings = tomli_load(file)
unittestXMLFile = Path(pyProjectSettings["tool"]["pytest"]["junit_xml"])
mergedUnittestXMLFile = Path(pyProjectSettings["tool"]["pyedaa-reports"]["junit_xml"])
coverageHTMLDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"])
coverageXMLFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"])
coverageJSONFile= Path(pyProjectSettings["tool"]["coverage"]["json"]["output"])
typingCoberturaFile = Path(pyProjectSettings["tool"]["mypy"]["cobertura_xml_report"]) / "cobertura.xml"
typingJUnitFile = Path(pyProjectSettings["tool"]["mypy"]["junit_xml"])
typingHTMLDirectory = Path(pyProjectSettings["tool"]["mypy"]["html_report"])
toolSection = pyProjectSettings["tool"]
if "pytest" in toolSection:
section = toolSection["pytest"]
if "junit_xml" in section:
unittestXMLFile = Path(section["junit_xml"])
if "pyedaa-reports" in toolSection:
section = toolSection["pyedaa-reports"]
if "junit_xml" in section:
mergedUnittestXMLFile = Path(section["junit_xml"])
if "coverage" in toolSection:
section = toolSection["coverage"]
if "html" in section:
coverageHTMLDirectory = Path(section["html"]["directory"])
if "xml" in section:
coverageXMLFile = Path(section["xml"]["output"])
if "json" in section:
coverageJSONFile= Path(section["json"]["output"])
if "mypy" in toolSection:
section = toolSection["mypy"]
if "cobertura_xml_report" in section:
typingCoberturaFile = Path(section["cobertura_xml_report"]) / "cobertura.xml"
if "junit_xml" in section:
typingJUnitFile = Path(section["junit_xml"])
if "html_report" in section:
typingHTMLDirectory = Path(section["html_report"])
else:
print(f"File '{pyProjectFile}' not found.")
print(f"::error title=FileNotFoundError::File '{pyProjectFile}' not found.")