From a9052f1d7156c8dcff8ae9efa4ab06d05a0cf3d6 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 26 Mar 2023 20:25:57 +0100 Subject: [PATCH] back port from pychangelogfactory --- .gitignore | 2 ++ Jenkinsfile | 32 ++++++++++++++++++-------------- helpers/helper_base.py | 7 ++++--- helpers/quality_check.py | 3 ++- helpers/types_check.py | 19 +++++++++---------- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 58782a1..221ee37 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ docs helpers-results .coverage /.mypy_cache/ +.coverage +.mypy_cache \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 5a0144c..a097e14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -397,14 +397,23 @@ pipeline { } post { always { - dir("gitrepo") { - publishHTML([ - reportDir: "helpers-results/quality_check", - reportFiles: "report.html", - reportName: "quality-report", - allowMissing: false, - alwaysLinkToLastBuild: true, - keepAll: true]) + dir("gitrepo") { + publishCoverage adapters: [cobertura(mergeToOneReport: true, path: "helpers-results/types_check/cobertura.xml")] + junit 'helpers-results/types_check/junit.xml' + publishHTML([ + reportDir: "helpers-results/quality_check", + reportFiles: "report.html", + reportName: "quality-report", + allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true]) + publishHTML([ + reportDir: "helpers-results/types_check", + reportFiles: "index.html", + reportName: "types_check", + allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true]) } } } @@ -481,12 +490,7 @@ pipeline { sz_full_rate = full_rate.setScale(2, RoundingMode.HALF_EVEN).toString() badge_coverage.setStatus(sz_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 records = readCSV file: 'helpers-results/complexity_check/MI.csv' maintainability = records[1][1] diff --git a/helpers/helper_base.py b/helpers/helper_base.py index 294ca80..ab88e6a 100644 --- a/helpers/helper_base.py +++ b/helpers/helper_base.py @@ -57,10 +57,11 @@ class helper_base(ABC): return process.stdout @classmethod - def run_cmd(cls, cmdarray): + def run_cmd(cls, cmdarray, silent: bool = False): p = subprocess.run(cmdarray, capture_output=True) - print(p.stdout) - print(p.stderr) + if not silent: + print(p.stdout.decode()) + print(p.stderr.decode()) return p.stdout diff --git a/helpers/quality_check.py b/helpers/quality_check.py index d57c523..4028148 100644 --- a/helpers/quality_check.py +++ b/helpers/quality_check.py @@ -37,7 +37,7 @@ class quality_check(helper_withresults_base): def GetPylintMessageList(cls): Messagelist = dict() 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()): Messagelist[res.group(1)] = res.group(2) cls.PylintMessageList = Messagelist @@ -52,6 +52,7 @@ class quality_check(helper_withresults_base): @classmethod def do_job(cls): print("checking code quality ...") + cls.GetPylintMessageList() RES_all = dict() diff --git a/helpers/types_check.py b/helpers/types_check.py index 6179581..62d17f0 100644 --- a/helpers/types_check.py +++ b/helpers/types_check.py @@ -24,22 +24,18 @@ class types_check(helper_withresults_base): print("checking code typing ...") result = api.run( [ # project path - "-m", - "src." + str(cls.pyproject["project"]["name"]), + "-p", + "src.pychangelogfactory", # analysis configuration - "--ignore-missing-imports", - "--strict-equality", + # "--show-traceback", + "--explicit-package-bases", + # "--strict-equality", + # "--check-untyped-defs", # reports generation "--cobertura-xml-report", str(cls.get_result_dir()), "--html-report", 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", str(cls.get_result_dir()), "--xml-report", @@ -52,6 +48,9 @@ class types_check(helper_withresults_base): if result[0]: print("\nType checking report:\n") 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]: print("\nError report:\n")