back port from pychangelogfactory

This commit is contained in:
cclecle
2023-03-26 20:25:57 +01:00
parent e64dcf4978
commit a9052f1d71
5 changed files with 35 additions and 28 deletions

2
.gitignore vendored
View File

@@ -41,3 +41,5 @@ docs
helpers-results helpers-results
.coverage .coverage
/.mypy_cache/ /.mypy_cache/
.coverage
.mypy_cache

14
Jenkinsfile vendored
View File

@@ -398,6 +398,8 @@ pipeline {
post { post {
always { always {
dir("gitrepo") { dir("gitrepo") {
publishCoverage adapters: [cobertura(mergeToOneReport: true, path: "helpers-results/types_check/cobertura.xml")]
junit 'helpers-results/types_check/junit.xml'
publishHTML([ publishHTML([
reportDir: "helpers-results/quality_check", reportDir: "helpers-results/quality_check",
reportFiles: "report.html", reportFiles: "report.html",
@@ -405,6 +407,13 @@ pipeline {
allowMissing: false, allowMissing: false,
alwaysLinkToLastBuild: true, alwaysLinkToLastBuild: true,
keepAll: true]) keepAll: true])
publishHTML([
reportDir: "helpers-results/types_check",
reportFiles: "index.html",
reportName: "types_check",
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true])
} }
} }
} }
@@ -482,11 +491,6 @@ pipeline {
badge_coverage.setStatus(sz_full_rate) badge_coverage.setStatus(sz_full_rate)
badge_coverage.setColor(getColorScale(full_rate)) badge_coverage.setColor(getColorScale(full_rate))
//complexity = new BigDecimal( 10*GetCoverageValue_complexity(coverage_report_path))
//sz_complexity = complexity.setScale(2, RoundingMode.HALF_EVEN).toString()
//badge_complexity.setStatus(sz_complexity)
//badge_quality.setColor(getColorScale_reversed(complexity))
//badge_maintainability //badge_maintainability
records = readCSV file: 'helpers-results/complexity_check/MI.csv' records = readCSV file: 'helpers-results/complexity_check/MI.csv'
maintainability = records[1][1] maintainability = records[1][1]

View File

@@ -57,10 +57,11 @@ class helper_base(ABC):
return process.stdout return process.stdout
@classmethod @classmethod
def run_cmd(cls, cmdarray): def run_cmd(cls, cmdarray, silent: bool = False):
p = subprocess.run(cmdarray, capture_output=True) p = subprocess.run(cmdarray, capture_output=True)
print(p.stdout) if not silent:
print(p.stderr) print(p.stdout.decode())
print(p.stderr.decode())
return p.stdout return p.stdout

View File

@@ -37,7 +37,7 @@ class quality_check(helper_withresults_base):
def GetPylintMessageList(cls): def GetPylintMessageList(cls):
Messagelist = dict() Messagelist = dict()
regex = r"^:([a-zA-Z-]+) \(([^\)]+)\)" regex = r"^:([a-zA-Z-]+) \(([^\)]+)\)"
for line in cls.run_cmd([sys.executable, "-m", "pylint", "--list-msgs"]).splitlines(): for line in cls.run_cmd([sys.executable, "-m", "pylint", "--list-msgs"], True).splitlines():
if res := re.search(regex, line.decode()): if res := re.search(regex, line.decode()):
Messagelist[res.group(1)] = res.group(2) Messagelist[res.group(1)] = res.group(2)
cls.PylintMessageList = Messagelist cls.PylintMessageList = Messagelist
@@ -52,6 +52,7 @@ class quality_check(helper_withresults_base):
@classmethod @classmethod
def do_job(cls): def do_job(cls):
print("checking code quality ...") print("checking code quality ...")
cls.GetPylintMessageList() cls.GetPylintMessageList()
RES_all = dict() RES_all = dict()

View File

@@ -24,22 +24,18 @@ class types_check(helper_withresults_base):
print("checking code typing ...") print("checking code typing ...")
result = api.run( result = api.run(
[ # project path [ # project path
"-m", "-p",
"src." + str(cls.pyproject["project"]["name"]), "src.pychangelogfactory",
# analysis configuration # analysis configuration
"--ignore-missing-imports", # "--show-traceback",
"--strict-equality", "--explicit-package-bases",
# "--strict-equality",
# "--check-untyped-defs",
# reports generation # reports generation
"--cobertura-xml-report", "--cobertura-xml-report",
str(cls.get_result_dir()), str(cls.get_result_dir()),
"--html-report", "--html-report",
str(cls.get_result_dir()), str(cls.get_result_dir()),
"--linecount-report",
str(cls.get_result_dir()),
"--linecoverage-report",
str(cls.get_result_dir()),
"--lineprecision-report",
str(cls.get_result_dir()),
"--txt-report", "--txt-report",
str(cls.get_result_dir()), str(cls.get_result_dir()),
"--xml-report", "--xml-report",
@@ -52,6 +48,9 @@ class types_check(helper_withresults_base):
if result[0]: if result[0]:
print("\nType checking report:\n") print("\nType checking report:\n")
print(result[0]) # stdout print(result[0]) # stdout
# converting the report using pylint_json2html (/!\ internal API, but as their is no leading '_' ...)
with open(cls.get_result_dir() / "raw_eport.txt", "w+", encoding="utf-8") as Outfile:
Outfile.write(result[0])
if result[1]: if result[1]:
print("\nError report:\n") print("\nError report:\n")