From e4df9f7d77184eacb74a2192e0dba9c859055492 Mon Sep 17 00:00:00 2001 From: cclecle Date: Tue, 28 Mar 2023 08:45:04 +0100 Subject: [PATCH] apply changes from pygitversionhelper helper --- Jenkinsfile | 45 ++++++++++++++++++++++++++++++++----- RUN_complexity.launch | 2 +- RUN_mkdocs.launch | 2 +- RUN_quality.launch | 2 +- RUN_unittest.launch | 2 +- helpers/__main__.py | 8 ------- helpers/changelog_gen.py | 23 ------------------- helpers/complexity_check.py | 1 - helpers/types_check.py | 3 ++- 9 files changed, 45 insertions(+), 43 deletions(-) delete mode 100644 helpers/changelog_gen.py diff --git a/Jenkinsfile b/Jenkinsfile index a097e14..71f2119 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ def _bPreRelease = false def _bDraft = false // release content / changelog management def _bAutoChangelog = true //Not supported yet -def _ReleaseContent_Title = "_CI/CD Automatic Release_" +def _ReleaseContent_Title = "# _CI/CD Automatic Release_" def bPushMasterOnPypi = true // full rebuild toogle def _bFullRebuilt = true @@ -148,6 +148,7 @@ pipeline { PY_PROJECT_NAME = "__NOTSET__" PY_PROJECT_VERSION = "__NOTSET__" PY_PROJECT_VERSION_STRIPPED = "__NOTSET__" + CHANGELOG = "__NOTSET__" } stages { @@ -184,16 +185,14 @@ pipeline { sh(". ~/BUILD_ENV/bin/activate && pip install --upgrade setuptools build pip copier jinja2-slug toml") - sh(". ~/TOOLS_ENV/bin/activate && pip install simple_rest_client requests twine") + sh(". ~/TOOLS_ENV/bin/activate && pip install simple_rest_client requests twine packaging") script { if(_PROJECT_NAME!="pygitversionhelper") { sh(". ~/TOOLS_ENV/bin/activate && pip install pygitversionhelper") } - else - { - //TODO: need to install pygitversionhelper deps from a better way... - sh(". ~/TOOLS_ENV/bin/activate && pip install packaging") + if(_PROJECT_NAME!="pychangelogfactory") { + sh(". ~/TOOLS_ENV/bin/activate && pip install pychangelogfactory") } } sh("git config --global user.email $_MaintainerEmail") @@ -217,6 +216,32 @@ pipeline { withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git") } + + CHANGELOG = sh(script: """#!/bin/sh - + |. ~/TOOLS_ENV/bin/activate + |exec python - << '__EOWRAPPER__' + | + |import re + | + |try: + | from pychangelogfactory import ChangelogFactory + |except ImportError: + | from src.pychangelogfactory import ChangelogFactory + | + |try: + | from pygitversionhelper import gitversionhelper + |except ImportError: + | from src.pygitversionhelper import gitversionhelper + | + | + |LastTag=gitversionhelper.tag.getLastTag(same_branch=True) + |CommitHistory=gitversionhelper.commit.getMessagesSinceTag(LastTag, merged_output=True, ignore_merged=True) + |Changelog = ChangelogFactory(CommitHistory).RenderFullChangelog(include_unknown=True) + |print(Changelog.replace("\\n","\\n\\n")) + | + |__EOWRAPPER__ + """.stripMargin(), + returnStdout: true).trim() if(_GIT_BRANCH=="master") { if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty()) { @@ -573,6 +598,7 @@ pipeline { |from simple_rest_client.api import API |from simple_rest_client.resource import Resource | + | |try: | from pygitversionhelper import gitversionhelper |except ImportError: @@ -619,6 +645,13 @@ pipeline { |ReleaseContent = "${_ReleaseContent_Title}" + "\\n" \\ | + "\\n" \\ | + "Reference documentation: [mkdocs page](https://chacha.ddns.net/mkdocs-web/${_PROJECT_USER_NAME}/${PY_PROJECT_NAME}/${_GIT_BRANCH}/${PY_PROJECT_VERSION_STRIPPED}/) " + | + |Changelog='''${CHANGELOG}''' + | + |ReleaseContent = ReleaseContent + "\\n"+ "\\n"+ "## Changelog:\\n" + Changelog + | + |if not Changelog: + | ReleaseContent = ReleaseContent + "code/project maintainance" | |data={ | "body": ReleaseContent, diff --git a/RUN_complexity.launch b/RUN_complexity.launch index 55ecc1c..65d47e2 100644 --- a/RUN_complexity.launch +++ b/RUN_complexity.launch @@ -7,7 +7,7 @@ - + diff --git a/RUN_mkdocs.launch b/RUN_mkdocs.launch index 7816ecf..5b79e08 100644 --- a/RUN_mkdocs.launch +++ b/RUN_mkdocs.launch @@ -10,7 +10,7 @@ - + diff --git a/RUN_quality.launch b/RUN_quality.launch index 689dcff..0d0c79f 100644 --- a/RUN_quality.launch +++ b/RUN_quality.launch @@ -7,7 +7,7 @@ - + diff --git a/RUN_unittest.launch b/RUN_unittest.launch index 98bd546..5331c03 100644 --- a/RUN_unittest.launch +++ b/RUN_unittest.launch @@ -7,7 +7,7 @@ - + diff --git a/helpers/__main__.py b/helpers/__main__.py index b4dd963..c5fb64a 100644 --- a/helpers/__main__.py +++ b/helpers/__main__.py @@ -22,7 +22,6 @@ if __package__ == "helpers": from .quality_check import quality_check from .unit_test import unit_test from .doc_gen import doc_gen - from .changelog_gen import changelog_gen from .complexity_check import complexity_check else: # when calling the __main__.py file (from IDE) @@ -30,7 +29,6 @@ else: from helpers.quality_check import quality_check from helpers.unit_test import unit_test from helpers.doc_gen import doc_gen - from helpers.changelog_gen import changelog_gen from helpers.complexity_check import complexity_check logging.getLogger().setLevel(logging.INFO) @@ -59,8 +57,6 @@ if __name__ == "__main__": "-pdf", "--doc-gen-pdf", dest="docgenpdf", action="store_true", help="enable pdf documentation export (requires doc-gen)" ) - parser.add_argument("-clg", "--changelog-gen", dest="changeloggen", action="store_true", help="enable changelog generation") - parser.add_argument("-cpc", "--complexity-check", dest="complexitycheck", action="store_true", help="enable complexity check") args = parser.parse_args() @@ -76,7 +72,6 @@ if __name__ == "__main__": # args.coveragecheck = True # args.docgen = True # args.docgenpdf = True - # args.changeloggen = True # args.complexitycheck = True helpers = [] @@ -104,9 +99,6 @@ if __name__ == "__main__": else: raise RuntimeError("doc-gen is required to enable doc-gen-pdf") - if args.changeloggen == True: - helpers.append(changelog_gen) - if args.complexitycheck == True: helpers.append(complexity_check) diff --git a/helpers/changelog_gen.py b/helpers/changelog_gen.py deleted file mode 100644 index f4a15cb..0000000 --- a/helpers/changelog_gen.py +++ /dev/null @@ -1,23 +0,0 @@ -# pyChaChaDummyProject (c) by chacha -# -# pyChaChaDummyProject is licensed under a -# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported License. -# -# You should have received a copy of the license along with this -# work. If not, see . - -from __future__ import annotations -from typing import TYPE_CHECKING - -# from pathlib import Path -# import os -# import datetime - - -from .helper_base import helper_base - - -class changelog_gen(helper_base): - @classmethod - def do_job(cls): - pass diff --git a/helpers/complexity_check.py b/helpers/complexity_check.py index 529e872..a61959a 100644 --- a/helpers/complexity_check.py +++ b/helpers/complexity_check.py @@ -19,7 +19,6 @@ from radon.cli import Config from radon.cli.harvest import CCHarvester, HCHarvester, MIHarvester from .helper_base import helper_withresults_base -from pprint import pprint class complexity_check(helper_withresults_base): diff --git a/helpers/types_check.py b/helpers/types_check.py index 62d17f0..e909464 100644 --- a/helpers/types_check.py +++ b/helpers/types_check.py @@ -25,12 +25,13 @@ class types_check(helper_withresults_base): result = api.run( [ # project path "-p", - "src.pychangelogfactory", + "src." + cls.pyproject["project"]["name"], # analysis configuration # "--show-traceback", "--explicit-package-bases", # "--strict-equality", # "--check-untyped-defs", + "--enable-incomplete-feature=Unpack", # reports generation "--cobertura-xml-report", str(cls.get_result_dir()),