Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Jan 22, 2024
2 parents 6755eda + ffbb244 commit edada68
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 93 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:

jobs:
UnitTestingParams:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev
uses: pyTooling/Actions/.github/workflows/Parameters.yml@r1
with:
name: sphinx-reports
python_version_list: "3.9 3.10 3.11 3.12 pypy-3.9 pypy-3.10"
# disable_list: "windows:pypy-3.8 windows:pypy-3.9 windows:pypy-3.10"

UnitTesting:
uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@dev
uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@r1
needs:
- UnitTestingParams
with:
Expand All @@ -27,7 +27,7 @@ jobs:
coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}

StaticTypeCheck:
uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@dev
uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r1
needs:
- UnitTestingParams
with:
Expand All @@ -38,7 +38,7 @@ jobs:
html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}

DocCoverage:
uses: pyTooling/Actions/.github/workflows/CheckDocumentation.yml@dev
uses: pyTooling/Actions/.github/workflows/CheckDocumentation.yml@r1
needs:
- UnitTestingParams
with:
Expand All @@ -47,7 +47,7 @@ jobs:
# fail_below: 70

Package:
uses: pyTooling/Actions/.github/workflows/Package.yml@dev
uses: pyTooling/Actions/.github/workflows/Package.yml@r1
needs:
- UnitTestingParams
- UnitTesting
Expand All @@ -56,7 +56,7 @@ jobs:
artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}

PublishCoverageResults:
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@dev
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r1
needs:
- UnitTestingParams
- UnitTesting
Expand All @@ -69,15 +69,15 @@ jobs:
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}

PublishTestResults:
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@r1
needs:
- UnitTestingParams
- UnitTesting
with:
merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}

IntermediateCleanUp:
uses: pyTooling/Actions/.github/workflows/IntermediateCleanUp.yml@dev
uses: pyTooling/Actions/.github/workflows/IntermediateCleanUp.yml@r1
needs:
- UnitTestingParams
- PublishCoverageResults
Expand All @@ -88,14 +88,14 @@ jobs:
xml_unittest_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}-

# VerifyDocs:
# uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@dev
# uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@r1
# needs:
# - UnitTestingParams
# with:
# python_version: ${{ needs.UnitTestingParams.outputs.python_version }}

HTMLDocumentation:
uses: pyTooling/Actions/.github/workflows/SphinxDocumentation.yml@dev
uses: pyTooling/Actions/.github/workflows/SphinxDocumentation.yml@r1
needs:
- UnitTestingParams
- PublishTestResults
Expand All @@ -109,7 +109,7 @@ jobs:
latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }}

PDFDocumentation:
uses: pyTooling/Actions/.github/workflows/LaTeXDocumentation.yml@dev
uses: pyTooling/Actions/.github/workflows/LaTeXDocumentation.yml@r1
needs:
- UnitTestingParams
- HTMLDocumentation
Expand All @@ -119,7 +119,7 @@ jobs:
pdf_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_pdf }}

PublishToGitHubPages:
uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@dev
uses: pyTooling/Actions/.github/workflows/PublishToGitHubPages.yml@r1
needs:
- UnitTestingParams
- HTMLDocumentation
Expand All @@ -132,14 +132,14 @@ jobs:
typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}

ReleasePage:
uses: pyTooling/Actions/.github/workflows/Release.yml@dev
uses: pyTooling/Actions/.github/workflows/Release.yml@r1
if: startsWith(github.ref, 'refs/tags')
needs:
- Package
- PublishToGitHubPages

PublishOnPyPI:
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@dev
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@r1
if: startsWith(github.ref, 'refs/tags')
needs:
- UnitTestingParams
Expand All @@ -152,7 +152,7 @@ jobs:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

ArtifactCleanUp:
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@dev
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@r1
needs:
- UnitTestingParams
- UnitTesting
Expand Down
1 change: 0 additions & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
setuptools >= 69.0.0

pyTooling ~= 6.0
colorama >= 0.4.6

# Enforce latest version on ReadTheDocs
sphinx >= 7.2, < 8.0
Expand Down
2 changes: 1 addition & 1 deletion run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if ($install)
{ Write-Host -ForegroundColor Cyan "[ADMIN][UNINSTALL] Uninstalling $PackageName ..."
py -3.12 -m pip uninstall -y $PackageName
Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Installing $PackageName from wheel ..."
py -3.12 -m pip install .\dist\$PackageName-0.5.1-py3-none-any.whl
py -3.12 -m pip install .\dist\$PackageName-0.6.0-py3-none-any.whl

Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Closing window in 5 seconds ..."
Start-Sleep -Seconds 5
Expand Down
44 changes: 39 additions & 5 deletions sphinx_reports/Adapter/JUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
"""
**A Sphinx extension providing uni test results embedded in documentation pages.**
"""
from datetime import datetime, timedelta
from pathlib import Path
from xml.dom import minidom, Node
from xml.dom.minidom import Element

from pyTooling.Decorators import export, readonly
from pyTooling.Decorators import export, readonly

from sphinx_reports.Common import ReportExtensionError
from sphinx_reports.DataModel.Unittest import Testsuite, Testcase, TestsuiteSummary, Test
from sphinx_reports.DataModel.Unittest import Testsuite, Testcase, TestsuiteSummary, Test, TestcaseState


@export
Expand Down Expand Up @@ -72,7 +73,17 @@ def Convert(self) -> TestsuiteSummary:
return self._testsuiteSummary

def _ParseRootElement(self, root: Element) -> None:
self._testsuiteSummary = TestsuiteSummary("root")
name = root.getAttribute("name") if root.hasAttribute("name") else "root"
testsuiteRuntime = float(root.getAttribute("time")) if root.hasAttribute("time") else -1.0
timestamp = datetime.fromisoformat(root.getAttribute("timestamp")) if root.hasAttribute("timestamp") else None

self._testsuiteSummary = TestsuiteSummary(name, timedelta(seconds=testsuiteRuntime))

tests = root.getAttribute("tests")
skipped = root.getAttribute("skipped")
errors = root.getAttribute("errors")
failures = root.getAttribute("failures")
assertions = root.getAttribute("assertions")

for rootNode in root.childNodes:
if rootNode.nodeName == "testsuite":
Expand All @@ -89,6 +100,7 @@ def _ParseTestsuite(self, testsuitesNode: Element) -> None:
def _ParseTestcase(self, testsuiteNode: Element) -> None:
className = testsuiteNode.getAttribute("classname")
name = testsuiteNode.getAttribute("name")
time = float(testsuiteNode.getAttribute("time"))

concurrentSuite = self._testsuiteSummary

Expand All @@ -97,8 +109,30 @@ def _ParseTestcase(self, testsuiteNode: Element) -> None:
try:
concurrentSuite = concurrentSuite[testsuiteName]
except KeyError:
new = Testsuite(testsuiteName)
new = Testsuite(testsuiteName, timedelta(seconds=time))
concurrentSuite._testsuites[testsuiteName] = new
concurrentSuite = new

concurrentSuite._testcases[name] = Testcase(name)
testcase = Testcase(name, timedelta(seconds=time))
concurrentSuite._testcases[name] = testcase

for node in testsuiteNode.childNodes:
if node.nodeType == Node.ELEMENT_NODE:
if node.tagName == "skipped":
testcase._state = TestcaseState.Skipped
elif node.tagName == "failure":
testcase._state = TestcaseState.Failed
elif node.tagName == "error":
testcase._state = TestcaseState.Error
elif node.tagName == "system-out":
pass
elif node.tagName == "system-err":
pass
elif node.tagName == "properties":
pass
else:
raise UnittestError(f"Unknown element '{node.tagName}' in junit file.")

if testcase._state is TestcaseState.Unknown:
testcase._state = TestcaseState.Passed

38 changes: 23 additions & 15 deletions sphinx_reports/CodeCoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
**Report code coverage as Sphinx documentation page(s).**
"""
from pathlib import Path
from typing import Dict, Tuple, Any, List, Iterable, Mapping, Generator, TypedDict, Union
from typing import Dict, Tuple, Any, List, Iterable, Mapping, Generator, TypedDict, Union, Optional as Nullable

from docutils import nodes
from pyTooling.Decorators import export
Expand Down Expand Up @@ -167,22 +167,30 @@ def _ConvertToColor(self, currentLevel: float, configKey: str) -> str:
return self._levels[100][configKey]

def _GenerateCoverageTable(self) -> nodes.table:
# Create a table and table header with 5 columns
# Create a table and table header with 10 columns
table, tableGroup = self._PrepareTable(
identifier=self._packageID,
columns={
"Module": 500,
"Total Statements": 100,
"Excluded Statements": 100,
"Covered Statements": 100,
"Missing Statements": 100,
"Total Branches": 100,
"Covered Branches": 100,
"Partial Branches": 100,
"Missing Branches": 100,
"Coverage in %": 100
},
classes=["report-doccov-table"]
columns=[
("Package", [
(" Module", 500)
], None),
("Statments", [
("Total", 100),
("Excluded", 100),
("Covered", 100),
("Missing", 100)
], None),
("Branches", [
("Total", 100),
("Covered", 100),
("Partial", 100),
("Missing", 100)
], None),
("Coverage", [
("in %", 100)
], None)
],
classes=["report-codecov-table"]
)
tableBody = nodes.tbody()
tableGroup += tableBody
Expand Down
4 changes: 1 addition & 3 deletions sphinx_reports/DataModel/CodeCoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"""
**Abstract documentation coverage data model for Python code.**
"""

from enum import Flag
from pathlib import Path
from typing import Optional as Nullable, Iterable, Dict, Union, Tuple
from typing import Optional as Nullable, Dict, Union

from pyTooling.Decorators import export, readonly

Expand Down
Loading

0 comments on commit edada68

Please sign in to comment.