diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84f1a18..54d8b70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,9 @@ jobs: run: make dev-install - name: Run tests run: make test + - name: Report + run: | + python .github/workflows/get_markdown.py .coverage.xml 90 check: runs-on: ubuntu-20.04 diff --git a/.github/workflows/get_markdown.py b/.github/workflows/get_markdown.py new file mode 100644 index 0000000..cbb637e --- /dev/null +++ b/.github/workflows/get_markdown.py @@ -0,0 +1,32 @@ +import os +import re +import sys +import xml.dom.minidom + +if len(sys.argv)<3: + print("Not enough parameters") + sys.exit(-1) + +with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as fh: + print("| File | Coverage | |", file=fh) + print("|---------------|:--------:|:------------------:|", file=fh) + + min_perc = int(sys.argv[2]) + + with open(sys.argv[1], "r") as f: + xml_doc = xml.dom.minidom.parse(f) + perc_total = int(round(float(xml_doc.documentElement.getAttribute('line-rate'))*1000)) + sign_total = ":white_check_mark:" if (perc_total>=(min_perc*10)) else ":x:" + print(f"| **All files** | `{perc_total/10}%` | {sign_total} |", file=fh) + + for cl in xml_doc.getElementsByTagName('class'): + perc = int(round(float(cl.getAttribute('line-rate'))*1000)) + sign = ":white_check_mark:" if (perc>=(min_perc*10)) else ":x:" + escape_chars = r'_*[]()~`>#+-=|{}.!' + text = re.sub(f'([{re.escape(escape_chars)}])', r'\\\1', cl.getAttribute('filename')) + print(f"| {text} | `{perc/10}%` | {sign} |", file=fh) + + print("", file=fh) + if (perc_total