File tree 3 files changed +37
-2
lines changed
3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 13
13
run : make dev-install
14
14
- name : Run tests
15
15
run : make test
16
+ - name : Report
17
+ run : |
18
+ python .github/workflows/get_markdown.py .coverage.xml 90
16
19
17
20
check :
18
21
runs-on : ubuntu-20.04
Original file line number Diff line number Diff line change
1
+ import os
2
+ import re
3
+ import sys
4
+ import xml .dom .minidom
5
+
6
+ if len (sys .argv )< 3 :
7
+ print ("Not enough parameters" )
8
+ sys .exit (- 1 )
9
+
10
+ with open (os .environ ['GITHUB_STEP_SUMMARY' ], 'a' ) as fh :
11
+ print ("| File | Coverage | |" , file = fh )
12
+ print ("|---------------|:--------:|:------------------:|" , file = fh )
13
+
14
+ min_perc = int (sys .argv [2 ])
15
+
16
+ with open (sys .argv [1 ], "r" ) as f :
17
+ xml_doc = xml .dom .minidom .parse (f )
18
+ perc_total = int (round (float (xml_doc .documentElement .getAttribute ('line-rate' ))* 1000 ))
19
+ sign_total = ":white_check_mark:" if (perc_total >= (min_perc * 10 )) else ":x:"
20
+ print (f"| **All files** | `{ perc_total / 10 } %` | { sign_total } |" , file = fh )
21
+
22
+ for cl in xml_doc .getElementsByTagName ('class' ):
23
+ perc = int (round (float (cl .getAttribute ('line-rate' ))* 1000 ))
24
+ sign = ":white_check_mark:" if (perc >= (min_perc * 10 )) else ":x:"
25
+ escape_chars = r'_*[]()~`>#+-=|{}.!'
26
+ text = re .sub (f'([{ re .escape (escape_chars )} ])' , r'\\\1' , cl .getAttribute ('filename' ))
27
+ print (f"| { text } | `{ perc / 10 } %` | { sign } |" , file = fh )
28
+
29
+ print ("" , file = fh )
30
+ if (perc_total < min_perc ):
31
+ print ("**Minimum coverage requirement was not satisfied**" , file = fh )
32
+ sys .exit (- 1 )
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ docs-%:
46
46
47
47
test :
48
48
$(PYTHON ) -m pytest \
49
- --cov-report html --cov-report term \
49
+ --cov-report html --cov-report xml:.coverage.xml --cov-report term \
50
50
--cov yosys_mau \
51
51
-n auto -q $(O )
52
52
@@ -71,4 +71,4 @@ dev-install:
71
71
ci : formatting lint typecheck test docs-html
72
72
73
73
clean : docs-clean
74
- rm -rf .coverage .pytest_cache .mypy_cache .ruff_cache htmlcov
74
+ rm -rf .coverage .pytest_cache .mypy_cache .ruff_cache htmlcov .coverage.xml
You can’t perform that action at this time.
0 commit comments