Compare commits
130 Commits
0.0.1.post
...
1.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
| d4b90b1f91 | |||
|
|
a07bcc37c4 | ||
| ac70d4dde4 | |||
|
|
0d1e981b6b | ||
| 6e1c60ee53 | |||
|
|
b01779dd06 | ||
|
|
f7ec5d98a7 | ||
|
|
82d4b1bd70 | ||
|
|
880fa29bbd | ||
|
|
7347106694 | ||
| dd6f24a82e | |||
|
|
e1c1e643c3 | ||
|
|
a5f39d6cb2 | ||
|
|
c6ed7ef0a1 | ||
|
|
0ef5a8f463 | ||
|
|
e06a3b00ae | ||
|
|
d3bf6ddaa6 | ||
|
|
a419af2ade | ||
| 78d7fbe39d | |||
|
|
5f9d513c59 | ||
|
|
5087cf9614 | ||
|
|
dc322e52da | ||
|
|
a9052f1d71 | ||
| 3f5ee5f117 | |||
|
|
e64dcf4978 | ||
| 2d16b0e264 | |||
|
|
a045a47cb0 | ||
|
|
876e428003 | ||
|
|
f32127abd7 | ||
|
|
b20e5bd868 | ||
|
|
f1b1901f8a | ||
| 088dbf8a90 | |||
|
|
f63a7b76cd | ||
|
|
7ce1a04eb9 | ||
|
|
658eef2df6 | ||
| bd49b23b59 | |||
|
|
3d2b8d3762 | ||
|
|
da9fa475e8 | ||
|
|
93d2046c98 | ||
|
|
fa7eaf0769 | ||
|
|
cad73c4711 | ||
|
|
5621ba99f6 | ||
|
|
c49468e294 | ||
|
|
bec5f9234d | ||
|
|
4e50b8d03f | ||
|
|
e74a53e3bf | ||
|
|
ef7469f35b | ||
|
|
9e5f0de5c4 | ||
|
|
99f38741fd | ||
|
|
eee2bf551c | ||
|
|
01ce809823 | ||
|
|
4ab70409a0 | ||
|
|
7b9752a17a | ||
|
|
879a7ca03d | ||
|
|
bd3389aeb2 | ||
|
|
886a22bef2 | ||
|
|
e9355471ba | ||
|
|
3bbbe946a1 | ||
|
|
cc2f6353ac | ||
|
|
6e1bff135b | ||
|
|
f74633cee3 | ||
|
|
3bb580689a | ||
|
|
235af0fd6d | ||
|
|
8bdc425b3c | ||
|
|
4701015ba8 | ||
|
|
bf9b4f2207 | ||
| f5d61d8d04 | |||
|
|
31df26eb48 | ||
| d21c839f07 | |||
|
|
7fa5de67a6 | ||
|
|
99ee668fe0 | ||
|
|
e13561007b | ||
|
|
fe0bb13d86 | ||
|
|
4fc9032cd0 | ||
|
|
72e43e7c1c | ||
|
|
6d7411693e | ||
| 6542c80e8f | |||
|
|
1338ef5f8e | ||
| 4272a55dde | |||
|
|
da411f51e3 | ||
|
|
e9559e97fb | ||
|
|
158b85e29c | ||
| 382e39e684 | |||
|
|
d4545f999b | ||
|
|
21fc9e7c52 | ||
|
|
13a584c7d9 | ||
|
|
6dfe0682d7 | ||
|
|
d15b495f0a | ||
|
|
c9df0e7409 | ||
|
|
866e8ff7ff | ||
|
|
d786d27cd7 | ||
| 34c07e0d9f | |||
|
|
fb2f3eb412 | ||
| 2c9886b251 | |||
|
|
d93fd3286c | ||
| 782562eef8 | |||
|
|
f361a5189a | ||
|
|
3751ef1c93 | ||
|
|
d5e003c86c | ||
|
|
8b2b0ca07f | ||
|
|
ab1a69b8f8 | ||
|
|
a564e04219 | ||
| 82c32ff58c | |||
|
|
a29c1778fc | ||
|
|
2ee687959e | ||
| 794e54c88b | |||
|
|
e226f16292 | ||
|
|
8ea6b43a73 | ||
|
|
cb213df6b6 | ||
|
|
2c87f5488d | ||
| 078f5624b2 | |||
|
|
348204abb5 | ||
| 44c10b88a5 | |||
|
|
48114149fb | ||
| a4b7b27a65 | |||
|
|
5eb2f1c5cf | ||
|
|
65927077aa | ||
| 77e2be2714 | |||
|
|
0c02512814 | ||
| f422b9ff7d | |||
|
|
9f900ba597 | ||
| 660270d49b | |||
| 9f442a7b8e | |||
| 8fb9ba8406 | |||
| 38abaa58c5 | |||
| 35d75ea019 | |||
| 0b8651a30a | |||
| c5b3055bfe | |||
| 92a1d1a30f | |||
| f2c0bf1ddd |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -41,3 +41,5 @@ docs
|
|||||||
helpers-results
|
helpers-results
|
||||||
.coverage
|
.coverage
|
||||||
/.mypy_cache/
|
/.mypy_cache/
|
||||||
|
.coverage
|
||||||
|
.mypy_cache
|
||||||
2
.project
2
.project
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>gitversionhelper</name>
|
<name>pygitversionhelper</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||||
|
|
||||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||||
<path>/${PROJECT_DIR_NAME}/src</path>
|
|
||||||
<path>/${PROJECT_DIR_NAME}</path>
|
<path>/${PROJECT_DIR_NAME}</path>
|
||||||
</pydev_pathproperty>
|
</pydev_pathproperty>
|
||||||
|
|
||||||
|
|||||||
293
Jenkinsfile
vendored
293
Jenkinsfile
vendored
@@ -6,6 +6,14 @@
|
|||||||
// You should have received a copy of the license along with this
|
// You should have received a copy of the license along with this
|
||||||
// work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
// work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||||
|
|
||||||
|
import groovy.xml.XmlUtil
|
||||||
|
import static javax.xml.xpath.XPathConstants.*
|
||||||
|
import javax.xml.xpath.*
|
||||||
|
import groovy.xml.DOMBuilder
|
||||||
|
import groovy.xml.dom.DOMCategory
|
||||||
|
import java.math.RoundingMode
|
||||||
|
import java.math.BigDecimal
|
||||||
|
|
||||||
// configurable settings:
|
// configurable settings:
|
||||||
// use to send email if workflow problem
|
// use to send email if workflow problem
|
||||||
def _MaintainerName = "CHACHA"
|
def _MaintainerName = "CHACHA"
|
||||||
@@ -17,12 +25,19 @@ def _bPreRelease = false
|
|||||||
// toogle Draft flag on Gitea release system => If False, TAG is not created
|
// toogle Draft flag on Gitea release system => If False, TAG is not created
|
||||||
def _bDraft = false
|
def _bDraft = false
|
||||||
// release content / changelog management
|
// release content / changelog management
|
||||||
def _bAutoChangelog = false //Not supported yet
|
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
|
// full rebuild toogle
|
||||||
def _bFullRebuilt = true
|
def _bFullRebuilt = true
|
||||||
def _MkDocsWebURL = "dabauto--mkdocs-web.dmz.chacha.home/mkdocs-web/"
|
def _MkDocsWebURL = "dabauto--mkdocs-web.dmz.chacha.home/mkdocs-web/"
|
||||||
def _MkDocsWebCredentials = "2c5b684e-3787-4b37-8aca-b3dd4a383fe2"
|
def _MkDocsWebCredentials = "2c5b684e-3787-4b37-8aca-b3dd4a383fe2"
|
||||||
|
def _PypiCredentials = "Pypi"
|
||||||
|
|
||||||
|
|
||||||
|
def badge_coverage = addEmbeddableBadgeConfiguration(id: "coverage", subject: "coverage")
|
||||||
|
def badge_maintainability = addEmbeddableBadgeConfiguration(id: "maintainability", subject: "maintainability")
|
||||||
|
def badge_quality = addEmbeddableBadgeConfiguration(id: "quality", subject: "quality score")
|
||||||
|
|
||||||
// commands Helper: /!\ Made for GITEA /!\
|
// commands Helper: /!\ Made for GITEA /!\
|
||||||
String determineRepoUserName() {
|
String determineRepoUserName() {
|
||||||
@@ -59,6 +74,46 @@ String ExtractBaseVersion(inVersion) {
|
|||||||
return matcher[0][1]
|
return matcher[0][1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetCoverageValue(String CoverageFilePath,String XPath)
|
||||||
|
{
|
||||||
|
//File file = new File(CoverageFilePath)
|
||||||
|
//coverageReportRaw = file.getText('UTF-8')
|
||||||
|
coverageReportRaw = readFile(CoverageFilePath)
|
||||||
|
coverageReport = DOMBuilder.parse(new StringReader(coverageReportRaw), false, false)
|
||||||
|
coverageReportRoot = coverageReport.documentElement
|
||||||
|
|
||||||
|
def xpath = XPathFactory.newInstance().newXPath()
|
||||||
|
res = xpath.evaluate(XPath,coverageReportRoot,NUMBER)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
String getColorScale(BigDecimal value)
|
||||||
|
{
|
||||||
|
if( value >9) { return "Goldenrod"}
|
||||||
|
else if( value >6) { return "seagreen"}
|
||||||
|
else if( value >4) { return "orange"}
|
||||||
|
else if( value >2) { return "darkred"}
|
||||||
|
else { return "dimgrey"}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getColorScale_reversed(BigDecimal value)
|
||||||
|
{
|
||||||
|
if( value >9) { return "dimgrey"}
|
||||||
|
else if( value >6) { return "darkred"}
|
||||||
|
else if( value >4) { return "orange"}
|
||||||
|
else if( value >2) { return "seagreen"}
|
||||||
|
else { return "Goldenrod"}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetCoverageValue_lines_valid(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@lines-valid") }
|
||||||
|
int GetCoverageValue_lines_covered(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@lines-covered") }
|
||||||
|
int GetCoverageValue_line_rate(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@line-rate") }
|
||||||
|
int GetCoverageValue_branches_valid(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branches-valid") }
|
||||||
|
int GetCoverageValue_branches_covered(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branches-covered") }
|
||||||
|
int GetCoverageValue_branch_rate(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@branch-rate") }
|
||||||
|
int GetCoverageValue_complexity(String CoverageFilePath) { return GetCoverageValue(CoverageFilePath,"/coverage/@complexity") }
|
||||||
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
|
||||||
// for Docker based build (preferable)
|
// for Docker based build (preferable)
|
||||||
@@ -93,13 +148,14 @@ pipeline {
|
|||||||
PY_PROJECT_NAME = "__NOTSET__"
|
PY_PROJECT_NAME = "__NOTSET__"
|
||||||
PY_PROJECT_VERSION = "__NOTSET__"
|
PY_PROJECT_VERSION = "__NOTSET__"
|
||||||
PY_PROJECT_VERSION_STRIPPED = "__NOTSET__"
|
PY_PROJECT_VERSION_STRIPPED = "__NOTSET__"
|
||||||
|
CHANGELOG = "__NOTSET__"
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
stage("Prepare") {
|
stage("Prepare") {
|
||||||
steps {
|
steps {
|
||||||
script{
|
script {
|
||||||
if (_bFullRebuilt) {
|
if (_bFullRebuilt) {
|
||||||
// start by cleaning the workspace (not using cleanWs() because we want to keep the directory itself)
|
// start by cleaning the workspace (not using cleanWs() because we want to keep the directory itself)
|
||||||
// => this is needed to fetch it again with custom options
|
// => this is needed to fetch it again with custom options
|
||||||
@@ -108,8 +164,7 @@ pipeline {
|
|||||||
else {
|
else {
|
||||||
sh("find ~/. -name . ! -path './TEST_ENV/*' ! -path './BUILD_ENV/*' -o -prune -exec rm -rf -- {} +")
|
sh("find ~/. -name . ! -path './TEST_ENV/*' ! -path './BUILD_ENV/*' -o -prune -exec rm -rf -- {} +")
|
||||||
}
|
}
|
||||||
if(_GIT_BRANCH!="master")
|
if(_GIT_BRANCH!="master") {
|
||||||
{
|
|
||||||
_bPreRelease = true
|
_bPreRelease = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,45 +175,88 @@ pipeline {
|
|||||||
echo("_GITEA_BASE_URL: . . . . . . . . $_GITEA_BASE_URL")
|
echo("_GITEA_BASE_URL: . . . . . . . . $_GITEA_BASE_URL")
|
||||||
echo("GIT_COMMIT:. . . . . . . . . . . $GIT_COMMIT ")
|
echo("GIT_COMMIT:. . . . . . . . . . . $GIT_COMMIT ")
|
||||||
echo("_PROJECT_USER_NAME:. . . . . . . $_PROJECT_USER_NAME")
|
echo("_PROJECT_USER_NAME:. . . . . . . $_PROJECT_USER_NAME")
|
||||||
echo("_GITEA_PROJECT_NAME: . . . . . . $_PROJECT_NAME")
|
echo("_PROJECT_NAME: . . . . . . . . . $_PROJECT_NAME")
|
||||||
echo("_MaintainerEmail:. . . . . . . . $_MaintainerEmail")
|
echo("_MaintainerEmail:. . . . . . . . $_MaintainerEmail")
|
||||||
echo("_MaintainerName:. . . . . . . . $_MaintainerName")
|
echo("_MaintainerName:. . . . . . . . $_MaintainerName")
|
||||||
|
|
||||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python BUILD_ENV")
|
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python BUILD_ENV")
|
||||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TEST_ENV")
|
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TEST_ENV")
|
||||||
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TOOLS_ENV")
|
sh("virtualenv --pip=embed --setuptools=embed --wheel=embed --no-periodic-update --activators bash,python TOOLS_ENV")
|
||||||
|
|
||||||
sh(". ~/BUILD_ENV/bin/activate && pip install --upgrade setuptools build pip copier jinja2-slug toml \"setuptools-git-versioning<2\"")
|
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")
|
sh(". ~/TOOLS_ENV/bin/activate && pip install simple_rest_client requests twine packaging")
|
||||||
sh(". ~/TOOLS_ENV/bin/activate && pip install git+https://chacha.ddns.net/gitea/chacha/pygitversionhelper.git@master")
|
|
||||||
|
script {
|
||||||
|
if(_PROJECT_NAME!="pygitversionhelper") {
|
||||||
|
sh(". ~/TOOLS_ENV/bin/activate && pip install pygitversionhelper")
|
||||||
|
}
|
||||||
|
if(_PROJECT_NAME!="pychangelogfactory") {
|
||||||
|
sh(". ~/TOOLS_ENV/bin/activate && pip install pychangelogfactory")
|
||||||
|
}
|
||||||
|
}
|
||||||
sh("git config --global user.email $_MaintainerEmail")
|
sh("git config --global user.email $_MaintainerEmail")
|
||||||
sh("git config --global user.name $_MaintainerName")
|
sh("git config --global user.name $_MaintainerName")
|
||||||
|
sh("git config --global init.defaultBranch master")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("GetCode") {
|
stage("GetCode") {
|
||||||
steps {
|
steps {
|
||||||
dir("gitrepo") {
|
dir("gitrepo") {
|
||||||
// manually checkout the repository, with All branches and tags
|
// manually checkout the repository, with All branches and tags
|
||||||
// => because we might need them for version and changelog computing
|
// => because we might need them for version and changelog computing
|
||||||
checkout([ $class: "GitSCM",
|
checkout([ $class: "GitSCM",
|
||||||
branches: [[name: GIT_BRANCH]],
|
branches: [[name: GIT_BRANCH]],
|
||||||
extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']],
|
extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']],
|
||||||
userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]])
|
userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]])
|
||||||
script{
|
script {
|
||||||
if(_GIT_BRANCH=="master")
|
|
||||||
{
|
withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||||
if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty())
|
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()) {
|
||||||
|
|
||||||
BUMPED_VERSION = sh(script: """#!/bin/sh -
|
BUMPED_VERSION = sh(script: """#!/bin/sh -
|
||||||
|. ~/TOOLS_ENV/bin/activate
|
|. ~/TOOLS_ENV/bin/activate
|
||||||
|exec python - << '__EOWRAPPER__'
|
|exec python - << '__EOWRAPPER__'
|
||||||
|
|
|
|
||||||
|from pygitversionhelper import gitversionhelper
|
|
||||||
|import re
|
|import re
|
||||||
|
|
|
|
||||||
|
|try:
|
||||||
|
| from pygitversionhelper import gitversionhelper
|
||||||
|
|except ImportError:
|
||||||
|
| from src.pygitversionhelper import gitversionhelper
|
||||||
|
|
|
||||||
|lastcommit=gitversionhelper.commit.getLast(same_branch=True)
|
|lastcommit=gitversionhelper.commit.getLast(same_branch=True)
|
||||||
|msg=gitversionhelper.commit.getMessage(lastcommit)
|
|msg=gitversionhelper.commit.getMessage(lastcommit)
|
||||||
|
|
|
|
||||||
@@ -168,46 +266,45 @@ pipeline {
|
|||||||
|__EOWRAPPER__
|
|__EOWRAPPER__
|
||||||
""".stripMargin(),
|
""".stripMargin(),
|
||||||
returnStdout: true).trim()
|
returnStdout: true).trim()
|
||||||
if(BUMPED_VERSION.isEmpty())
|
|
||||||
{
|
if(BUMPED_VERSION.isEmpty()) {
|
||||||
echo "master push/merge must have an explicit tag release number, stopping pipeline"
|
echo "master push/merge must have an explicit tag release number, stopping pipeline"
|
||||||
currentBuild.getRawBuild().getExecutor().doStop()
|
currentBuild.getRawBuild().getExecutor().doStop()
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo "new-tag requested in commit message: $BUMPED_VERSION"
|
echo "new-tag requested in commit message: $BUMPED_VERSION"
|
||||||
sh("git tag -a $BUMPED_VERSION")
|
|
||||||
sh("git push origin master --tags")
|
sh("git tag $BUMPED_VERSION")
|
||||||
|
sh("git push origin --tags")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// using git to get the latest tag on this branch
|
|
||||||
def latestTag = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim()
|
|
||||||
echo("latestTag:. . . . . . . . . . . . $latestTag ")
|
|
||||||
|
|
||||||
sh(script: """#!/bin/sh -
|
latestTag = sh(script: """#!/bin/sh -
|
||||||
|. ~/TOOLS_ENV/bin/activate
|
|. ~/TOOLS_ENV/bin/activate
|
||||||
|exec python - << '__EOWRAPPER__'
|
|exec python - << '__EOWRAPPER__'
|
||||||
|
|
|
|
||||||
|from pygitversionhelper import gitversionhelper
|
|try:
|
||||||
|
|
| from pygitversionhelper import gitversionhelper
|
||||||
|print(f"most recent repository tag: {gitversionhelper.tag.getLastTag()}")
|
|except ImportError:
|
||||||
|print(f"most recent repository tag: {gitversionhelper.tag.getLastTag(same_branch=True)}")
|
| from src.pygitversionhelper import gitversionhelper
|
||||||
|print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag()}")
|
|
|
||||||
|print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag(same_branch=True)}")
|
|print(gitversionhelper.tag.getLastTag(same_branch=True),end ="")
|
||||||
|print(f"most recent repository version: {gitversionhelper.version.getLastVersion(formated_output=True)}")
|
|
|
||||||
|print(f'current repository version: {gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post")}')
|
|__EOWRAPPER__
|
||||||
|
|
""".stripMargin(),
|
||||||
|__EOWRAPPER__
|
returnStdout: true)
|
||||||
""".stripMargin())
|
echo("latestTag:. . . . . . . . . . . . $latestTag ")
|
||||||
|
|
||||||
// get current (or bumped) version number from git history
|
// get current (or bumped) version number from git history
|
||||||
PY_PROJECT_VERSION = sh(script: """#!/bin/sh -
|
PY_PROJECT_VERSION = sh(script: """#!/bin/sh -
|
||||||
|. ~/TOOLS_ENV/bin/activate
|
|. ~/TOOLS_ENV/bin/activate
|
||||||
|exec python - << '__EOWRAPPER__'
|
|exec python - << '__EOWRAPPER__'
|
||||||
|
|
|
|
||||||
|from pygitversionhelper import gitversionhelper
|
|try:
|
||||||
|
| from pygitversionhelper import gitversionhelper
|
||||||
|
|except ImportError:
|
||||||
|
| from src.pygitversionhelper import gitversionhelper
|
||||||
|
|
|
|
||||||
|print(gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post"),end ="")
|
|print(gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post"),end ="")
|
||||||
|
|
|
|
||||||
@@ -217,11 +314,16 @@ pipeline {
|
|||||||
echo("PY_PROJECT_VERSION: . . . . . . . . . $PY_PROJECT_VERSION")
|
echo("PY_PROJECT_VERSION: . . . . . . . . . $PY_PROJECT_VERSION")
|
||||||
PY_PROJECT_VERSION_STRIPPED=ExtractBaseVersion(PY_PROJECT_VERSION)
|
PY_PROJECT_VERSION_STRIPPED=ExtractBaseVersion(PY_PROJECT_VERSION)
|
||||||
|
|
||||||
|
// Manually pushing a new tag with version string guessed by gitversionhelper
|
||||||
|
// because setuptools-git-versioning / setuptools_scm cant fing tag on other branches, so will guess a wrong version without this tag.
|
||||||
|
if(latestTag!=PY_PROJECT_VERSION) {
|
||||||
|
sh("git tag $PY_PROJECT_VERSION")
|
||||||
|
sh("git push origin --tags")
|
||||||
|
}
|
||||||
|
|
||||||
// specific handling to test the template itself
|
// specific handling to test the template itself
|
||||||
// => little hacky... creating a new git repo with a commit/tag corresponding to HEAD of the official one
|
// => little hacky... creating a new git repo with a commit/tag corresponding to HEAD of the official one
|
||||||
if(_PROJECT_NAME=="pyChaChaDummyProject") //specific case to test the template itself
|
if(_PROJECT_NAME=="pyChaChaDummyProject") { //specific case to test the template itself
|
||||||
{
|
|
||||||
|
|
||||||
sh("rm -Rf ~/_gitrepo || true")
|
sh("rm -Rf ~/_gitrepo || true")
|
||||||
|
|
||||||
sh(script: """#!/bin/sh -
|
sh(script: """#!/bin/sh -
|
||||||
@@ -282,7 +384,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
// no need for a build-env: setuptools is already creating one
|
// no need for a build-env: setuptools is already creating one
|
||||||
dir("gitrepo") {
|
dir("gitrepo") {
|
||||||
script{
|
script {
|
||||||
// actually doing the package build
|
// actually doing the package build
|
||||||
sh(". ~/BUILD_ENV/bin/activate && python -m build .")
|
sh(". ~/BUILD_ENV/bin/activate && python -m build .")
|
||||||
}
|
}
|
||||||
@@ -298,7 +400,7 @@ pipeline {
|
|||||||
def wheelPath = findFiles(glob: "**/dist/*.whl")[0]
|
def wheelPath = findFiles(glob: "**/dist/*.whl")[0]
|
||||||
echo "wheel artifact path: $wheelPath"
|
echo "wheel artifact path: $wheelPath"
|
||||||
// install the package, with *test* optionnal packages, as user
|
// install the package, with *test* optionnal packages, as user
|
||||||
sh(". ~/TEST_ENV/bin/activate && pip install --find-links dist/ ${PY_PROJECT_NAME} .[test,coverage-check,quality-check,type-check,doc-gen]")
|
sh(". ~/TEST_ENV/bin/activate && pip install --find-links dist/ ${PY_PROJECT_NAME} .[test,coverage-check,quality-check,type-check,doc-gen,complexity-check]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,19 +410,36 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
dir("gitrepo") {
|
dir("gitrepo") {
|
||||||
sh(". ~/TEST_ENV/bin/activate && python -m helpers --type-check --quality-check")
|
sh(". ~/TEST_ENV/bin/activate && python -m helpers --type-check --quality-check")
|
||||||
|
script {
|
||||||
|
def jsonObj = readJSON file: "helpers-results/quality_check/metrics.json"
|
||||||
|
quality_score = new BigDecimal(jsonObj["GlobalScore"])
|
||||||
|
sz_quality_score = quality_score.setScale(2, RoundingMode.HALF_EVEN).toString()
|
||||||
|
badge_quality.setStatus(sz_quality_score)
|
||||||
|
badge_quality.setColor(getColorScale(quality_score))
|
||||||
|
}
|
||||||
|
sh(". ~/TEST_ENV/bin/activate && python -m helpers --complexity-check")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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",
|
||||||
reportName: "quality-report",
|
reportName: "quality-report",
|
||||||
allowMissing: false,
|
allowMissing: false,
|
||||||
alwaysLinkToLastBuild: true,
|
alwaysLinkToLastBuild: true,
|
||||||
|
keepAll: true])
|
||||||
|
publishHTML([
|
||||||
|
reportDir: "helpers-results/types_check",
|
||||||
|
reportFiles: "index.html",
|
||||||
|
reportName: "types_check",
|
||||||
|
allowMissing: false,
|
||||||
|
alwaysLinkToLastBuild: true,
|
||||||
keepAll: true])
|
keepAll: true])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,6 +481,14 @@ pipeline {
|
|||||||
style: 'stackedArea',
|
style: 'stackedArea',
|
||||||
keepRecords: true,
|
keepRecords: true,
|
||||||
numBuilds: ''])
|
numBuilds: ''])
|
||||||
|
|
||||||
|
plot([ csvFileName: 'plot-4ceb9ee2-ca78-11ed-afa1-0242ac120002.csv',
|
||||||
|
csvSeries: [[ file: 'gitrepo/helpers-results/complexity_check/MI.csv', inclusionFlag: 'INCLUDE_BY_STRING',exclusionValues: 'MeanMaintainability', url: '']],
|
||||||
|
group: 'metrics',
|
||||||
|
title: 'maintainability',
|
||||||
|
style: 'stackedArea',
|
||||||
|
keepRecords: true,
|
||||||
|
numBuilds: ''])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,6 +501,31 @@ pipeline {
|
|||||||
println unit_test_full_name__html
|
println unit_test_full_name__html
|
||||||
unit_test_full_name__xml=findFiles(glob: "helpers-results/unit_test_full/*.xml")[0].getName()
|
unit_test_full_name__xml=findFiles(glob: "helpers-results/unit_test_full/*.xml")[0].getName()
|
||||||
println unit_test_full_name__xml
|
println unit_test_full_name__xml
|
||||||
|
|
||||||
|
coverage_report_path = "helpers-results/unit_test_coverage/test_coverage.xml"
|
||||||
|
println GetCoverageValue_lines_valid(coverage_report_path)
|
||||||
|
println GetCoverageValue_lines_covered(coverage_report_path)
|
||||||
|
println GetCoverageValue_line_rate(coverage_report_path)
|
||||||
|
println GetCoverageValue_branches_valid(coverage_report_path)
|
||||||
|
println GetCoverageValue_branches_covered(coverage_report_path)
|
||||||
|
println GetCoverageValue_branch_rate(coverage_report_path)
|
||||||
|
println GetCoverageValue_complexity(coverage_report_path)
|
||||||
|
|
||||||
|
full_rate = new BigDecimal( 10*(GetCoverageValue_line_rate(coverage_report_path) + GetCoverageValue_branch_rate(coverage_report_path)) / 2 )
|
||||||
|
sz_full_rate = full_rate.setScale(2, RoundingMode.HALF_EVEN).toString()
|
||||||
|
badge_coverage.setStatus(sz_full_rate)
|
||||||
|
badge_coverage.setColor(getColorScale(full_rate))
|
||||||
|
|
||||||
|
//badge_maintainability
|
||||||
|
records = readCSV file: 'helpers-results/complexity_check/MI.csv'
|
||||||
|
maintainability = records[1][1]
|
||||||
|
badge_maintainability.setStatus(maintainability)
|
||||||
|
|
||||||
|
if ( maintainability == 'D') { badge_maintainability.setColor( "dimgrey")}
|
||||||
|
else if( maintainability == 'C') { badge_maintainability.setColor( "darkred")}
|
||||||
|
else if( maintainability == 'B') { badge_maintainability.setColor( "orange")}
|
||||||
|
else if( maintainability == 'A') { badge_maintainability.setColor( "seagreen")}
|
||||||
|
else if( maintainability == 'A+') { badge_maintainability.setColor( "Goldenrod")}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,19 +585,25 @@ pipeline {
|
|||||||
dir("gitrepo") {
|
dir("gitrepo") {
|
||||||
script {
|
script {
|
||||||
def CurrentDateTime=java.time.LocalDateTime.now()
|
def CurrentDateTime=java.time.LocalDateTime.now()
|
||||||
withCredentials([string( credentialsId: _MkDocsWebCredentials,variable: 'MKDOCSTOKEN' )])
|
withCredentials([string( credentialsId: _MkDocsWebCredentials,variable: 'MKDOCSTOKEN' )]) {
|
||||||
{
|
|
||||||
sh(script: """#!/bin/sh -
|
sh(script: """#!/bin/sh -
|
||||||
|. ~/TOOLS_ENV/bin/activate
|
|. ~/TOOLS_ENV/bin/activate
|
||||||
|exec python - << '__EOWRAPPER__'
|
|exec python - << '__EOWRAPPER__'
|
||||||
|
|
|
|
||||||
|from simple_rest_client.api import API
|
|
||||||
|from simple_rest_client.resource import Resource
|
|
||||||
|import json
|
|import json
|
||||||
|import glob
|
|import glob
|
||||||
|import requests
|
|import requests
|
||||||
|import shutil
|
|import shutil
|
||||||
|
|
|
|
||||||
|
|from simple_rest_client.api import API
|
||||||
|
|from simple_rest_client.resource import Resource
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|try:
|
||||||
|
| from pygitversionhelper import gitversionhelper
|
||||||
|
|except ImportError:
|
||||||
|
| from src.pygitversionhelper import gitversionhelper
|
||||||
|
|
|
||||||
|from urllib.parse import urljoin
|
|from urllib.parse import urljoin
|
||||||
|
|
|
|
||||||
|class GiteaRepoCommits(Resource):
|
|class GiteaRepoCommits(Resource):
|
||||||
@@ -487,6 +645,13 @@ pipeline {
|
|||||||
|ReleaseContent = "${_ReleaseContent_Title}" + "\\n" \\
|
|ReleaseContent = "${_ReleaseContent_Title}" + "\\n" \\
|
||||||
| + "\\n" \\
|
| + "\\n" \\
|
||||||
| + "Reference documentation: [mkdocs page](https://chacha.ddns.net/mkdocs-web/${_PROJECT_USER_NAME}/${PY_PROJECT_NAME}/${_GIT_BRANCH}/${PY_PROJECT_VERSION_STRIPPED}/) "
|
| + "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={
|
|data={
|
||||||
| "body": ReleaseContent,
|
| "body": ReleaseContent,
|
||||||
@@ -526,6 +691,14 @@ pipeline {
|
|||||||
|__EOWRAPPER__
|
|__EOWRAPPER__
|
||||||
""".stripMargin())
|
""".stripMargin())
|
||||||
}
|
}
|
||||||
|
if((_GIT_BRANCH=="master") && (bPushMasterOnPypi)) {
|
||||||
|
withCredentials([usernamePassword( credentialsId: _PypiCredentials, passwordVariable: 'PYPI_PASSWORD', usernameVariable: 'PYPI_USERNAME')]) {
|
||||||
|
sh(script: """#!/bin/sh -
|
||||||
|
|. ~/TOOLS_ENV/bin/activate
|
||||||
|
|exec twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} --non-interactive --disable-progress-bar dist/*
|
||||||
|
""".stripMargin())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -1,5 +1,10 @@
|
|||||||
|

|
||||||
|

|
||||||

|

|
||||||

|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -9,8 +14,7 @@ _A tiny library to help versioning management of git python projects_
|
|||||||
|
|
||||||
Because a good developer is a lazy developer and version management in CI/CD can be very time consuming.
|
Because a good developer is a lazy developer and version management in CI/CD can be very time consuming.
|
||||||
|
|
||||||
|
Checkout [Latest Documentation](https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/master/latest/).
|
||||||
Checkout [Latest Documentation](https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/{{branch}}/latest/).
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- list tags
|
- list tags
|
||||||
@@ -19,13 +23,14 @@ Checkout [Latest Documentation](https://chacha.ddns.net/mkdocs-web/chacha/pygitv
|
|||||||
- get current version (bumped)
|
- get current version (bumped)
|
||||||
- convert / switch from SemVer to PEP440 (both ways)
|
- convert / switch from SemVer to PEP440 (both ways)
|
||||||
- automatic version format detection (SemVer by default)
|
- automatic version format detection (SemVer by default)
|
||||||
|
- get commit message history
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
- restrict to same branch
|
- restrict to same branch
|
||||||
- both SemVer and PEP440 support
|
- both SemVer and PEP440 support
|
||||||
- custom output format
|
- custom output format
|
||||||
- configurable default bump type major, minor, patch or dev
|
- configurable default bump type: major, minor, patch or dev
|
||||||
- configurable default bump type: post, pre-patch, pre-minor, pre-major
|
- configurable default bump strategy: post, pre-patch, pre-minor, pre-major
|
||||||
- ignore non-version tag
|
- ignore non-version tag
|
||||||
- force version format
|
- force version format
|
||||||
|
|
||||||
|
|||||||
16
RUN_changelog.launch
Normal file
16
RUN_changelog.launch
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.python.pydev.debug.regularLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/${project_name}/helpers"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/helpers"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--changelog-gen"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pygitversionhelper"/>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
||||||
16
RUN_complexity.launch
Normal file
16
RUN_complexity.launch
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.python.pydev.debug.regularLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/${project_name}/helpers"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/helpers"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--complexity-check"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pygitversionhelper"/>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
||||||
19
RUN_mkdocs.launch
Normal file
19
RUN_mkdocs.launch
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.python.pydev.debug.regularLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/${project_name}/helpers"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
|
||||||
|
<mapEntry key="PATH" value="C:\Program Files\GTK3-Runtime Win64\bin"/>
|
||||||
|
</mapAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/helpers"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--doc-gen --doc-gen-pdf"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pygitversionhelper"/>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
||||||
16
RUN_quality.launch
Normal file
16
RUN_quality.launch
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.python.pydev.debug.regularLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/${project_name}/helpers"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/helpers"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--type-check --quality-check"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pygitversionhelper"/>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
||||||
16
RUN_unittest.launch
Normal file
16
RUN_unittest.launch
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.python.pydev.debug.regularLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/${project_name}/helpers"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/helpers"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--unit-test --coverage-check"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||||
|
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pygitversionhelper"/>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
||||||
@@ -2,28 +2,33 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
From master repository:
|
From pypi repository (prefered):
|
||||||
|
```console
|
||||||
|
/> python -m pip install pygitversionhelper
|
||||||
|
```
|
||||||
|
|
||||||
|
From downloaded .whl file:
|
||||||
|
```console
|
||||||
|
/> python -m pip install pygitversionhelper-<VERSION>-py3-none-any.whl
|
||||||
|
```
|
||||||
|
|
||||||
python -m pip install git+https://chacha.ddns.net/gitea/chacha/pygitversionhelper.git@master
|
From master git repository:
|
||||||
|
```console
|
||||||
|
/> python -m pip install git+https://chacha.ddns.net/gitea/chacha/pygitversionhelper.git@master
|
||||||
|
```
|
||||||
|
|
||||||
From local .whl file:
|
|
||||||
|
|
||||||
python -m pip install pygitversionhelper-<VERSION>-py3-none-any.whl
|
|
||||||
|
|
||||||
From public repository:
|
|
||||||
|
|
||||||
TBD
|
|
||||||
|
|
||||||
## Import in your project
|
## Import in your project
|
||||||
|
|
||||||
Add this line on the top of your python script:
|
Add this line on the top of your python script:
|
||||||
|
```py
|
||||||
#from pygitversionhelper import gitversionhelper
|
from pygitversionhelper import gitversionhelper
|
||||||
|
```
|
||||||
[optionnal] If you need to catch exception from this module:
|
[optionnal] If you need to catch exception from this module:
|
||||||
|
```py
|
||||||
#from pygitversionhelper import gitversionhelperException
|
from pygitversionhelper import gitversionhelperException
|
||||||
|
```
|
||||||
## Basic API
|
## Basic API
|
||||||
|
|
||||||
All the API commands are static so it is not needed to create instantiate any object.
|
All the API commands are static so it is not needed to create instantiate any object.
|
||||||
@@ -31,93 +36,100 @@ All the API commands are static so it is not needed to create instantiate any ob
|
|||||||
They are all executed in the current active directory.
|
They are all executed in the current active directory.
|
||||||
|
|
||||||
One easy way to change directory:
|
One easy way to change directory:
|
||||||
|
```py
|
||||||
import os
|
import os
|
||||||
os.chdir("<YOUR DIRECTORY>")
|
os.chdir("<YOUR DIRECTORY>")
|
||||||
|
```
|
||||||
### sublib: repository
|
### sub-lib: repository
|
||||||
|
|
||||||
To check if a repository is dirty:
|
To check if a repository is dirty:
|
||||||
|
```py
|
||||||
if gitversionhelper.repository.isDirty():
|
if gitversionhelper.repository.isDirty():
|
||||||
print("repository is dirty")
|
print("repository is dirty")
|
||||||
|
```
|
||||||
### sublib: tag
|
### sub-lib: tag
|
||||||
|
|
||||||
List all tags [default to taggerdate order]:
|
List all tags [default to taggerdate order]:
|
||||||
|
```py
|
||||||
for tag in gitversionhelper.tag.getTags():
|
for tag in gitversionhelper.tag.getTags():
|
||||||
print(f"found tag: {tag}")
|
print(f"found tag: {tag}")
|
||||||
|
```
|
||||||
List all tags [using git refname order]:
|
List all tags [using git refname order]:
|
||||||
|
```py
|
||||||
for tag in gitversionhelper.tag.getTags("v:refname"):
|
for tag in gitversionhelper.tag.getTags("v:refname"):
|
||||||
print(f"found tag: {tag}")
|
print(f"found tag: {tag}")
|
||||||
|
```
|
||||||
Get the last tag:
|
Get the last tag:
|
||||||
|
```py
|
||||||
print(f"most recent repository tag: {gitversionhelper.tag.getLastTag()}")
|
print(f"most recent repository tag: {gitversionhelper.tag.getLastTag()}")
|
||||||
|
```
|
||||||
Get the last tag [only on same branch]:
|
Get the last tag [only on same branch]:
|
||||||
|
```py
|
||||||
print(f"most recent repository tag: {gitversionhelper.tag.getLastTag(same_branch=True)}")
|
print(f"most recent repository tag: {gitversionhelper.tag.getLastTag(same_branch=True)}")
|
||||||
|
```
|
||||||
|
|
||||||
Get the distance from HEAD to last tag:
|
Get the distance from HEAD to last tag:
|
||||||
|
```py
|
||||||
print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag()}")
|
print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag()}")
|
||||||
|
```
|
||||||
Get the distance from HEAD to last tag [only on same branch]:
|
Get the distance from HEAD to last tag [only on same branch]:
|
||||||
|
```py
|
||||||
print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag(same_branch=True)}")
|
print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag(same_branch=True)}")
|
||||||
|
```
|
||||||
### sublib: version
|
### sub-lib: version
|
||||||
|
|
||||||
Get the last found version in the repository [return MetaVersion object]:
|
Get the last found version in the repository [return MetaVersion object]:
|
||||||
|
```py
|
||||||
print(f"most recent repository version: {gitversionhelper.version.getLastVersion()}")
|
print(f"most recent repository version: {gitversionhelper.version.getLastVersion()}")
|
||||||
|
```
|
||||||
Get the last found version in the repository [return formated string]:
|
Get the last found version in the repository [return formated string]:
|
||||||
|
```py
|
||||||
print(f"most recent repository version: {gitversionhelper.version.getLastVersion(formated_output=True)}")
|
print(f"most recent repository version: {gitversionhelper.version.getLastVersion(formated_output=True)}")
|
||||||
|
```
|
||||||
Others kwargs available to this function:
|
Others kwargs available to this function:
|
||||||
|
|
||||||
* version_std: string to force a version standard for rendering ["PEP440" or "SemVer"]
|
* version_std: string to force a version standard for rendering ["PEP440" or "SemVer"]
|
||||||
* same_branch: boolean to force searching on same branch
|
* same_branch: boolean to force searching on same branch
|
||||||
* ignore\_unknown\_tags: boolean to allow unknown tag to be ignored
|
* ignore\_unknown\_tags: boolean to allow unknown tag to be ignored
|
||||||
|
|
||||||
Get the current version of the repository, automatically bump it if the last one is not tagged [returns MetaVersion object]:
|
Get the current version of the repository, automatically bump it if the last commit is not tagged [returns MetaVersion object]:
|
||||||
|
```py
|
||||||
print(f"current repository version: {gitversionhelper.version.getCurrentVersion()}")
|
print(f"current repository version: {gitversionhelper.version.getCurrentVersion()}")
|
||||||
|
```
|
||||||
Or with formated output:
|
Or with formated output:
|
||||||
|
```py
|
||||||
print(f"current repository version: {gitversionhelper.version.getCurrentVersion(formated_output=True)}")
|
print(f"current repository version: {gitversionhelper.version.getCurrentVersion(formated_output=True)}")
|
||||||
|
```
|
||||||
Typical usage in CI/CD env:
|
Typical usage in CI/CD env:
|
||||||
|
```py
|
||||||
bumped_version = gitversionhelper.version.getCurrentVersion( formated_output=True, \
|
bumped_version = gitversionhelper.version.getCurrentVersion( formated_output=True, \
|
||||||
version_std="PEP440", \
|
version_std="PEP440", \
|
||||||
bump_type="dev", \
|
bump_type="dev", \
|
||||||
bump_dev_strategy="post")
|
bump_dev_strategy="post")
|
||||||
print(f"current repository version: {bumped_version}")
|
print(f"current repository version: {bumped_version}")
|
||||||
|
```
|
||||||
kwargs available to this function:
|
kwargs available to this function:
|
||||||
|
|
||||||
* All same args as getLastVersion()
|
* All same args as getLastVersion()
|
||||||
* bump_type: if version need to be pump, allow to configure next release update type: __major, minor, patch, dev__
|
* bump_type: if version need to be pump, allow to configure next release update type: __major, minor, patch, dev__
|
||||||
* bump\_dev\_strategy: if bump\_type is dev, allow to choose dev update strategy: __post, pre-patch, pre-minor, pre-major__
|
* bump\_dev\_strategy: if bump\_type is dev, allow to choose dev update strategy: __post, pre-patch, pre-minor, pre-major__
|
||||||
|
|
||||||
|
|
||||||
A version object can also be manually formated:
|
A version object can also be manually formated:
|
||||||
|
```py
|
||||||
|
_version = gitversionhelper.tag.getCurrentVersion()
|
||||||
|
```
|
||||||
|
Then;
|
||||||
|
```py
|
||||||
|
_version.doFormatVersion()
|
||||||
|
```
|
||||||
|
or;
|
||||||
|
```py
|
||||||
|
gitversionhelper.version.doFormatVersion(_version)
|
||||||
|
```
|
||||||
|
kwargs available to this function:
|
||||||
|
|
||||||
_version = gitversionhelper.tag.getCurrentVersion()
|
- output_format: string to choose a rendering format ["Auto","PEP440" or "SemVer"]
|
||||||
_version.doFormatVersion()
|
|
||||||
#or
|
|
||||||
gitversionhelper.version.doFormatVersion(_version)
|
|
||||||
|
|
||||||
kwargs available to those function:
|
|
||||||
- output_format: string to choose a rendering format ["Auto","PEP440" or "SemVer"]
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|||||||
@@ -16,89 +16,101 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __package__=="helpers":
|
if __package__ == "helpers":
|
||||||
# when calling the module from: > python -m helpers
|
# when calling the module from: > python -m helpers
|
||||||
from .types_check import types_check
|
from .types_check import types_check
|
||||||
from .quality_check import quality_check
|
from .quality_check import quality_check
|
||||||
from .unit_test import unit_test
|
from .unit_test import unit_test
|
||||||
from .doc_gen import doc_gen
|
from .doc_gen import doc_gen
|
||||||
from .changelog_gen import changelog_gen
|
from .changelog_gen import changelog_gen
|
||||||
else:
|
from .complexity_check import complexity_check
|
||||||
|
else:
|
||||||
# when calling the __main__.py file (from IDE)
|
# when calling the __main__.py file (from IDE)
|
||||||
from helpers.types_check import types_check
|
from helpers.types_check import types_check
|
||||||
from helpers.quality_check import quality_check
|
from helpers.quality_check import quality_check
|
||||||
from helpers.unit_test import unit_test
|
from helpers.unit_test import unit_test
|
||||||
from helpers.doc_gen import doc_gen
|
from helpers.doc_gen import doc_gen
|
||||||
from helpers.changelog_gen import changelog_gen
|
from helpers.changelog_gen import changelog_gen
|
||||||
|
from helpers.complexity_check import complexity_check
|
||||||
|
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
project_rootdir_path=Path(__file__).parent.parent.absolute()
|
project_rootdir_path = Path(__file__).parent.parent.absolute()
|
||||||
|
|
||||||
with open(project_rootdir_path / "pyproject.toml", mode="rb") as fp:
|
with open(project_rootdir_path / "pyproject.toml", mode="rb") as fp:
|
||||||
pyproject = tomli.load(fp)
|
pyproject = tomli.load(fp)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser( prog = 'continuous-integration-helper',
|
|
||||||
description = 'A tiny set of scripts to help continous integration on python')
|
|
||||||
|
|
||||||
parser.add_argument('-tc', '--type-check', dest='typecheck', action='store_true', help='enable static typing check')
|
|
||||||
|
|
||||||
parser.add_argument('-ut', '--unit-test', dest='unittest', action='store_true', help='enable unit-test')
|
|
||||||
parser.add_argument('-cc', '--coverage-check', dest='coveragecheck', action='store_true', help='enable unit-test coverage check (requires unit-test)')
|
|
||||||
|
|
||||||
parser.add_argument('-qc', '--quality-check', dest='qualitycheck', action='store_true', help='enable code quality check')
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="continuous-integration-helper", description="A tiny set of scripts to help continous integration on python"
|
||||||
parser.add_argument('-dg', '--doc-gen', dest='docgen', action='store_true', help='enable documentation generation using MkDoc')
|
)
|
||||||
parser.add_argument('-pdf', '--doc-gen-pdf', dest='docgenpdf', action='store_true', help='enable pdf documentation export (requires doc-gen)')
|
|
||||||
|
parser.add_argument("-tc", "--type-check", dest="typecheck", action="store_true", help="enable static typing check")
|
||||||
parser.add_argument('-clg', '--changelog-gen', dest='changeloggen', action='store_true', help='enable changelog generation')
|
|
||||||
|
parser.add_argument("-ut", "--unit-test", dest="unittest", action="store_true", help="enable unit-test")
|
||||||
|
parser.add_argument(
|
||||||
|
"-cc", "--coverage-check", dest="coveragecheck", action="store_true", help="enable unit-test coverage check (requires unit-test)"
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument("-qc", "--quality-check", dest="qualitycheck", action="store_true", help="enable code quality check")
|
||||||
|
|
||||||
|
parser.add_argument("-dg", "--doc-gen", dest="docgen", action="store_true", help="enable documentation generation using MkDoc")
|
||||||
|
parser.add_argument(
|
||||||
|
"-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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# Dev / Debug forced toogles
|
# Dev / Debug forced toogles
|
||||||
#
|
#
|
||||||
#--------------------------------
|
# --------------------------------
|
||||||
#
|
#
|
||||||
#args.typecheck = True
|
# args.typecheck = True
|
||||||
#args.qualitycheck = True
|
# args.qualitycheck = True
|
||||||
#args.unittest = True
|
# args.unittest = True
|
||||||
#args.coveragecheck = True
|
# args.coveragecheck = True
|
||||||
#args.docgen = True
|
# args.docgen = True
|
||||||
#args.docgenpdf = True
|
# args.docgenpdf = True
|
||||||
#args.changeloggen = True
|
# args.changeloggen = True
|
||||||
|
# args.complexitycheck = True
|
||||||
|
|
||||||
helpers = []
|
helpers = []
|
||||||
if args.typecheck == True:
|
if args.typecheck == True:
|
||||||
helpers.append(types_check)
|
helpers.append(types_check)
|
||||||
|
|
||||||
if args.unittest == True:
|
if args.unittest == True:
|
||||||
helpers.append(unit_test)
|
helpers.append(unit_test)
|
||||||
|
|
||||||
if args.coveragecheck == True:
|
if args.coveragecheck == True:
|
||||||
if args.unittest == True:
|
if args.unittest == True:
|
||||||
unit_test.enable_coverage_check = True
|
unit_test.enable_coverage_check = True
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("unit-test is required to enable coverage-check")
|
raise RuntimeError("unit-test is required to enable coverage-check")
|
||||||
|
|
||||||
if args.qualitycheck == True:
|
if args.qualitycheck == True:
|
||||||
helpers.append(quality_check)
|
helpers.append(quality_check)
|
||||||
|
|
||||||
if args.docgen == True:
|
if args.docgen == True:
|
||||||
helpers.append(doc_gen)
|
helpers.append(doc_gen)
|
||||||
|
|
||||||
if args.docgenpdf==True:
|
if args.docgenpdf == True:
|
||||||
if args.docgen == True:
|
if args.docgen == True:
|
||||||
doc_gen.enable_gen_pdf = True
|
doc_gen.enable_gen_pdf = True
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("doc-gen is required to enable doc-gen-pdf")
|
raise RuntimeError("doc-gen is required to enable doc-gen-pdf")
|
||||||
|
|
||||||
if args.changeloggen == True:
|
if args.changeloggen == True:
|
||||||
helpers.append(changelog_gen)
|
helpers.append(changelog_gen)
|
||||||
|
|
||||||
|
if args.complexitycheck == True:
|
||||||
|
helpers.append(complexity_check)
|
||||||
|
|
||||||
for helper in helpers:
|
for helper in helpers:
|
||||||
helper.set_context(project_rootdir_path,pyproject)
|
helper.set_context(project_rootdir_path, pyproject)
|
||||||
helper.reset_result_dir()
|
helper.reset_result_dir()
|
||||||
helper.do_job()
|
helper.do_job()
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,15 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
#from pathlib import Path
|
# from pathlib import Path
|
||||||
#import os
|
# import os
|
||||||
#import datetime
|
# import datetime
|
||||||
|
|
||||||
|
|
||||||
from .helper_base import helper_base
|
from .helper_base import helper_base
|
||||||
|
|
||||||
|
|
||||||
class changelog_gen(helper_base):
|
class changelog_gen(helper_base):
|
||||||
|
@classmethod
|
||||||
@classmethod
|
def do_job(cls):
|
||||||
def do_job(cls):
|
pass
|
||||||
pass
|
|
||||||
|
|||||||
69
helpers/complexity_check.py
Normal file
69
helpers/complexity_check.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# 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 <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
# from pathlib import Path
|
||||||
|
# import os
|
||||||
|
import statistics
|
||||||
|
import csv
|
||||||
|
from json import loads as JSON_LOADS
|
||||||
|
from radon.complexity import cc_rank, SCORE
|
||||||
|
from radon.cli import Config
|
||||||
|
from radon.cli.harvest import CCHarvester, HCHarvester, MIHarvester
|
||||||
|
|
||||||
|
from .helper_base import helper_withresults_base
|
||||||
|
|
||||||
|
|
||||||
|
class complexity_check(helper_withresults_base):
|
||||||
|
@classmethod
|
||||||
|
def do_job(cls):
|
||||||
|
config = Config(
|
||||||
|
exclude="__init__\.py",
|
||||||
|
ignore=None,
|
||||||
|
order=SCORE,
|
||||||
|
show_closures=False,
|
||||||
|
no_assert=True,
|
||||||
|
min="A",
|
||||||
|
max="F",
|
||||||
|
multi=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
h = MIHarvester([str(_) for _ in sorted((cls.project_rootdir_path / "src").rglob("*.py"))], config).as_json()
|
||||||
|
res = JSON_LOADS(h)
|
||||||
|
|
||||||
|
with open(cls.get_result_dir() / "MI.json", "w", newline="") as oFile:
|
||||||
|
oFile.write(h)
|
||||||
|
|
||||||
|
mean = statistics.mean(_["mi"] for _ in res.values())
|
||||||
|
|
||||||
|
if mean >= 65:
|
||||||
|
rank = "A+"
|
||||||
|
elif mean >= 20:
|
||||||
|
rank = "A"
|
||||||
|
elif mean >= 10:
|
||||||
|
rank = "B"
|
||||||
|
else:
|
||||||
|
rank = "C"
|
||||||
|
|
||||||
|
RES_MI = {"MeanMaintainability": mean, "MaintainabilityIndex": rank}
|
||||||
|
with open(cls.get_result_dir() / "MI.csv", "w", newline="") as oFile:
|
||||||
|
writer = csv.DictWriter(oFile, fieldnames=RES_MI.keys())
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerow(RES_MI)
|
||||||
|
|
||||||
|
config = Config(exclude=None, ignore=None, order=SCORE, show_closures=False, no_assert=True, min="A", max="F", multi=False)
|
||||||
|
h = CCHarvester([str(_) for _ in sorted((cls.project_rootdir_path / "src").rglob("*.py"))], config).as_json()
|
||||||
|
with open(cls.get_result_dir() / "CC.json", "w", newline="") as oFile:
|
||||||
|
oFile.write(h)
|
||||||
|
|
||||||
|
config = Config(exclude=None, ignore=None, order=SCORE, show_closures=False, no_assert=True, min="A", max="F", by_function=None)
|
||||||
|
h = HCHarvester([str(_) for _ in sorted((cls.project_rootdir_path / "src").rglob("*.py"))], config).as_json()
|
||||||
|
with open(cls.get_result_dir() / "HC.json", "w", newline="") as oFile:
|
||||||
|
oFile.write(h)
|
||||||
@@ -17,6 +17,7 @@ from pathlib import Path
|
|||||||
from distutils.dir_util import copy_tree
|
from distutils.dir_util import copy_tree
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yaml import CLoader as Loader, CDumper as Dumper
|
from yaml import CLoader as Loader, CDumper as Dumper
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -24,35 +25,34 @@ except ImportError:
|
|||||||
|
|
||||||
from .helper_base import helper_withresults_base
|
from .helper_base import helper_withresults_base
|
||||||
|
|
||||||
class doc_gen(helper_withresults_base):
|
|
||||||
|
class doc_gen(helper_withresults_base):
|
||||||
enable_gen_pdf: bool = False
|
enable_gen_pdf: bool = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_job(cls):
|
def do_job(cls):
|
||||||
print(cls.project_rootdir_path)
|
|
||||||
print()
|
|
||||||
|
|
||||||
# create doc root dir
|
# create doc root dir
|
||||||
doc_path = cls.project_rootdir_path/"docs"
|
doc_path = cls.project_rootdir_path / "docs"
|
||||||
cls._reset_dir(doc_path)
|
cls._reset_dir(doc_path)
|
||||||
|
|
||||||
site_path = cls.get_result_dir()/"site"
|
site_path = cls.get_result_dir() / "site"
|
||||||
cls._reset_dir(site_path)
|
cls._reset_dir(site_path)
|
||||||
|
|
||||||
# copy files from main project dir
|
# copy files from main project dir
|
||||||
shutil.copyfile(str(cls.project_rootdir_path/"README.md"),str(doc_path/"README.md"))
|
shutil.copyfile(str(cls.project_rootdir_path / "README.md"), str(doc_path / "README.md"))
|
||||||
shutil.copyfile(str(cls.project_rootdir_path/"LICENSE.md"),str(doc_path/"LICENSE.md"))
|
shutil.copyfile(str(cls.project_rootdir_path / "LICENSE.md"), str(doc_path / "LICENSE.md"))
|
||||||
|
|
||||||
# copy files from static-doc dir
|
# copy files from static-doc dir
|
||||||
copy_tree(str(cls.project_rootdir_path/"docs-static"),str(doc_path))
|
copy_tree(str(cls.project_rootdir_path / "docs-static"), str(doc_path))
|
||||||
|
|
||||||
# generating API doc + nav from python docstrings
|
# generating API doc + nav from python docstrings
|
||||||
reference_path = doc_path / "reference"
|
reference_path = doc_path / "reference"
|
||||||
cls._reset_dir(reference_path)
|
cls._reset_dir(reference_path)
|
||||||
|
|
||||||
for path in sorted((cls.project_rootdir_path / "src").rglob("*.py")):
|
for path in sorted((cls.project_rootdir_path / "src").rglob("*.py")):
|
||||||
module_path = path.relative_to(cls.project_rootdir_path/ "src").with_suffix("")
|
module_path = path.relative_to(cls.project_rootdir_path / "src").with_suffix("")
|
||||||
doc_path = path.relative_to(cls.project_rootdir_path/ "src").with_suffix(".md")
|
doc_path = path.relative_to(cls.project_rootdir_path / "src").with_suffix(".md")
|
||||||
full_doc_path = Path(reference_path, doc_path)
|
full_doc_path = Path(reference_path, doc_path)
|
||||||
|
|
||||||
parts = list(module_path.parts)
|
parts = list(module_path.parts)
|
||||||
@@ -61,43 +61,38 @@ class doc_gen(helper_withresults_base):
|
|||||||
parts = parts[:-1]
|
parts = parts[:-1]
|
||||||
elif parts[-1] == "__main__":
|
elif parts[-1] == "__main__":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cls._reset_dir(os.path.dirname(full_doc_path))
|
cls._reset_dir(os.path.dirname(full_doc_path))
|
||||||
with open(full_doc_path, "w+") as fd:
|
with open(full_doc_path, "w+") as fd:
|
||||||
identifier = "src."+".".join(parts)
|
identifier = "src." + ".".join(parts)
|
||||||
print("::: " + identifier, file=fd)
|
print("::: " + identifier, file=fd)
|
||||||
|
|
||||||
|
cmdopts = [f"{sys.executable}", "-m", "mkdocs", "-v", "build", "--site-dir", str(site_path), "--clean"]
|
||||||
cmdopts = [f"{sys.executable}","-m","mkdocs","-v","build","--site-dir",str(site_path),"--clean"]
|
|
||||||
|
|
||||||
# little hack here, to enable / disable pdf generation using own class config
|
# little hack here, to enable / disable pdf generation using own class config
|
||||||
# => reason is mkdocs seems to try loading the plugin even if we disable it, so we need to
|
# => reason is mkdocs seems to try loading the plugin even if we disable it, so we need to
|
||||||
# manually process the configuration file.
|
# manually process the configuration file.
|
||||||
mkdocsCfg=None
|
with open(cls.project_rootdir_path / "mkdocs.yml", "r") as mkdocsCfgFile:
|
||||||
with open(cls.project_rootdir_path / "mkdocs.yml",'r') as mkdocsCfgFile:
|
mkdocsCfg = yaml.load(mkdocsCfgFile, Loader=yaml.Loader)
|
||||||
mkdocsCfg = yaml.load(mkdocsCfgFile, Loader=yaml.SafeLoader)
|
|
||||||
|
if "plugins" in mkdocsCfg:
|
||||||
if cls.enable_gen_pdf==True:
|
mkdocsCfg["plugins"] = [_ for _ in mkdocsCfg["plugins"] if (not isinstance(_, dict) or "with-pdf" not in _.keys())]
|
||||||
mkdocsCfg['plugins'].append({ 'with-pdf':{
|
|
||||||
'cover_subtitle': 'User Manual',
|
if cls.enable_gen_pdf == True:
|
||||||
'cover_logo': str(cls.project_rootdir_path / 'docs-static' / 'Library.jpg'),
|
mkdocsCfg["plugins"].append(
|
||||||
'verbose': False,
|
{
|
||||||
'media_type': 'print',
|
"with-pdf": {
|
||||||
'exclude_pages': ['LICENSE'],
|
"cover_subtitle": "User Manual",
|
||||||
'output_path': str(site_path / 'pdf' / 'manual.pdf')
|
"cover_logo": str(cls.project_rootdir_path / "docs-static" / "Library.jpg"),
|
||||||
}})
|
"verbose": False,
|
||||||
else:
|
"exclude_pages": ["LICENSE"],
|
||||||
for subelem in mkdocsCfg['plugins']:
|
"output_path": str(site_path / "pdf" / "manual.pdf"),
|
||||||
if isinstance(subelem,dict) :
|
}
|
||||||
if 'with-pdf' in subelem.keys():
|
}
|
||||||
mkdocsCfg['plugins'].remove(subelem)
|
)
|
||||||
break
|
with open(cls.project_rootdir_path / "mkdocs.yml", "w") as mkdocsCfgFile:
|
||||||
|
mkdocsCfgFile.write(yaml.dump(mkdocsCfg, Dumper=Dumper, default_flow_style=False, sort_keys=False))
|
||||||
with open(cls.project_rootdir_path / "mkdocs.yml",'w') as mkdocsCfgFile:
|
|
||||||
mkdocsCfgFile.write(yaml.dump(mkdocsCfg, Dumper=Dumper,default_flow_style=False, sort_keys=False))
|
res = cls.run_cmd(cmdopts)
|
||||||
|
|
||||||
|
|
||||||
res=cls.run_cmd(cmdopts)
|
|
||||||
print(res.decode())
|
print(res.decode())
|
||||||
print(' !! done')
|
print(" !! done")
|
||||||
|
|
||||||
|
|||||||
@@ -9,64 +9,67 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from abc import ABC,abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
if TYPE_CHECKING: # Only imports the below statements during type checking
|
if TYPE_CHECKING: # Only imports the below statements during type checking
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class helper_base(ABC):
|
class helper_base(ABC):
|
||||||
project_rootdir_path: Union[Path,None] = None
|
project_rootdir_path: Union[Path, None] = None
|
||||||
pyproject: Union[dict,None] = None
|
pyproject: Union[dict, None] = None
|
||||||
current_dir: Union[Path,None] = None
|
current_dir: Union[Path, None] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_context(cls,project_rootdir_path:Path, pyproject:dict):
|
def set_context(cls, project_rootdir_path: Path, pyproject: dict):
|
||||||
cls.project_rootdir_path = project_rootdir_path
|
cls.project_rootdir_path = project_rootdir_path
|
||||||
cls.pyproject = pyproject
|
cls.pyproject = pyproject
|
||||||
cls.current_dir = Path(__file__).parent.absolute()
|
cls.current_dir = Path(__file__).parent.absolute()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_result_dir(cls):
|
def get_result_dir(cls):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _reset_dir(dirpath:Path):
|
def _reset_dir(dirpath: Path):
|
||||||
dirpath = Path(dirpath)
|
dirpath = Path(dirpath)
|
||||||
if not os.path.exists(dirpath):
|
if not os.path.exists(dirpath):
|
||||||
os.makedirs(dirpath)
|
os.makedirs(dirpath)
|
||||||
[f.unlink() for f in Path(dirpath).glob("*") if f.is_file()]
|
[f.unlink() for f in Path(dirpath).glob("*") if f.is_file()]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reset_result_dir(cls):
|
def reset_result_dir(cls):
|
||||||
result_dir = cls.get_result_dir()
|
result_dir = cls.get_result_dir()
|
||||||
if result_dir != None:
|
if result_dir != None:
|
||||||
cls._reset_dir(result_dir)
|
cls._reset_dir(result_dir)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def do_job(cls):
|
def do_job(cls):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_cmd_(cls, cmdarray):
|
def run_cmd_(cls, cmdarray):
|
||||||
process = subprocess.run(cmdarray, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, check=True)
|
process = subprocess.run(cmdarray, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, check=True)
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
class helper_withresults_base(helper_base):
|
class helper_withresults_base(helper_base):
|
||||||
helper_results_dir: Union[Path,None] = None
|
helper_results_dir: Union[Path, None] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_result_dir(cls):
|
def get_result_dir(cls):
|
||||||
if cls.helper_results_dir==None:
|
if cls.helper_results_dir == None:
|
||||||
cls.helper_results_dir=cls.__name__
|
cls.helper_results_dir = cls.__name__
|
||||||
return Path(__file__).parent.parent.absolute() / "helpers-results" / cls.helper_results_dir
|
return Path(__file__).parent.parent.absolute() / "helpers-results" / cls.helper_results_dir
|
||||||
|
|||||||
@@ -25,197 +25,223 @@ import pylint_json2html
|
|||||||
|
|
||||||
from .helper_base import helper_withresults_base
|
from .helper_base import helper_withresults_base
|
||||||
|
|
||||||
|
|
||||||
class PyLintMetricNotFound(Warning):
|
class PyLintMetricNotFound(Warning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class quality_check(helper_withresults_base):
|
|
||||||
PylintMessageList=dict()
|
class quality_check(helper_withresults_base):
|
||||||
|
PylintMessageList = dict()
|
||||||
@classmethod
|
|
||||||
|
@classmethod
|
||||||
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
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def TryExtractPYReportMetric(line: str,tag: str):
|
def TryExtractPYReportMetric(line: str, tag: str):
|
||||||
regex=f"^(?:\|{tag}\s*\|)(\d+)(?=\s*|)"
|
regex = f"^(?:\|{tag}\s*\|)(\d+)(?=\s*|)"
|
||||||
if res:=re.search(regex,line):
|
if res := re.search(regex, line):
|
||||||
return float(res.group(1))
|
return float(res.group(1))
|
||||||
raise PyLintMetricNotFound()
|
raise PyLintMetricNotFound()
|
||||||
|
|
||||||
@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()
|
||||||
with StringIO() as StdOutput:
|
with StringIO() as StdOutput:
|
||||||
JsonContent=""
|
JsonContent = ""
|
||||||
with redirect_stdout(StdOutput):
|
with redirect_stdout(StdOutput):
|
||||||
pylint_Run(['--output-format=json,parseable',
|
pylint_Run(
|
||||||
'--disable=invalid-name',
|
[
|
||||||
'--ignore=_version.py',
|
"--load-plugins=pylint.extensions.mccabe",
|
||||||
'--reports=y',
|
"--output-format=json,parseable",
|
||||||
'--score=yes',
|
"--disable=invalid-name",
|
||||||
'--max-line-length=140',
|
"--ignore=_version.py",
|
||||||
'src.' + cls.pyproject['project']['name']], exit=False)
|
"--reports=y",
|
||||||
|
"--score=yes",
|
||||||
with open(cls.get_result_dir()/"report.json","w+", encoding='utf-8') as Outfile:
|
"--max-line-length=140",
|
||||||
|
"src." + cls.pyproject["project"]["name"],
|
||||||
|
],
|
||||||
|
exit=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(cls.get_result_dir() / "report.json", "w+", encoding="utf-8") as Outfile:
|
||||||
# hacky way of exctracting json + having overall score...
|
# hacky way of exctracting json + having overall score...
|
||||||
class TScanState(Enum):
|
class TScanState(Enum):
|
||||||
TEXT_REPORT = 1
|
TEXT_REPORT = 1
|
||||||
JSON_REPORT = 2
|
JSON_REPORT = 2
|
||||||
OTHER_REPORT_START = 3
|
OTHER_REPORT_START = 3
|
||||||
OTHER_REPORT_STATISTICS = 4
|
OTHER_REPORT_STATISTICS = 4
|
||||||
OTHER_REPORT_METRICS = 5
|
OTHER_REPORT_METRICS = 5
|
||||||
OTHER_REPORT_DUPLICATION = 6
|
OTHER_REPORT_DUPLICATION = 6
|
||||||
OTHER_REPORT_MESSAGES_CAT = 7
|
OTHER_REPORT_MESSAGES_CAT = 7
|
||||||
OTHER_REPORT_MESSAGES = 8
|
OTHER_REPORT_MESSAGES = 8
|
||||||
OTHER_REPORT_END = 99
|
OTHER_REPORT_END = 99
|
||||||
|
|
||||||
RES_all['Statistics'] = dict()
|
RES_all["Statistics"] = dict()
|
||||||
RES_all['RawMetrics'] = dict()
|
RES_all["RawMetrics"] = dict()
|
||||||
RES_all['RawMetricsPercent'] = dict()
|
RES_all["RawMetricsPercent"] = dict()
|
||||||
RES_all['Duplication'] = dict()
|
RES_all["Duplication"] = dict()
|
||||||
RES_all['MessagesCat'] = dict()
|
RES_all["MessagesCat"] = dict()
|
||||||
RES_all['Messages'] = dict()
|
RES_all["Messages"] = dict()
|
||||||
RES_all['GlobalScore'] = -999
|
RES_all["GlobalScore"] = -999
|
||||||
RES_all['NbAnalysedStatments'] = -999
|
RES_all["NbAnalysedStatments"] = -999
|
||||||
RES_all['NbAnalysedLines'] = -999
|
RES_all["NbAnalysedLines"] = -999
|
||||||
|
|
||||||
ScanState = TScanState.TEXT_REPORT
|
ScanState = TScanState.TEXT_REPORT
|
||||||
for line in StdOutput.getvalue().split('\n'):
|
for line in StdOutput.getvalue().split("\n"):
|
||||||
print(line)
|
print(line)
|
||||||
if ScanState == TScanState.TEXT_REPORT:
|
if ScanState == TScanState.TEXT_REPORT:
|
||||||
# ignoring this part, we need json
|
# ignoring this part, we need json
|
||||||
if line=='[':
|
if line == "[":
|
||||||
JsonContent+=line
|
JsonContent += line
|
||||||
ScanState = TScanState.JSON_REPORT
|
ScanState = TScanState.JSON_REPORT
|
||||||
elif line=='[]':
|
elif line == "[]":
|
||||||
JsonContent+=line
|
JsonContent += line
|
||||||
ScanState = TScanState.OTHER_REPORT_START
|
ScanState = TScanState.OTHER_REPORT_START
|
||||||
|
|
||||||
elif ScanState == TScanState.JSON_REPORT:
|
elif ScanState == TScanState.JSON_REPORT:
|
||||||
JsonContent+=line
|
JsonContent += line
|
||||||
if line==']':
|
if line == "]":
|
||||||
ScanState = TScanState.OTHER_REPORT_START
|
ScanState = TScanState.OTHER_REPORT_START
|
||||||
|
|
||||||
elif ScanState == TScanState.OTHER_REPORT_START:
|
elif ScanState == TScanState.OTHER_REPORT_START:
|
||||||
if res:=re.search(r"^(\d+)(?= statements analysed.)",line):
|
if res := re.search(r"^(\d+)(?= statements analysed.)", line):
|
||||||
RES_all['NbAnalysedStatments'] = float(res.group(1))
|
RES_all["NbAnalysedStatments"] = float(res.group(1))
|
||||||
if line == "Statistics by type":
|
if line == "Statistics by type":
|
||||||
ScanState = TScanState.OTHER_REPORT_STATISTICS
|
ScanState = TScanState.OTHER_REPORT_STATISTICS
|
||||||
|
|
||||||
elif ScanState == TScanState.OTHER_REPORT_STATISTICS:
|
elif ScanState == TScanState.OTHER_REPORT_STATISTICS:
|
||||||
if res:=re.search(r"^(\d+)(?= lines have been analyzed)",line):
|
if res := re.search(r"^(\d+)(?= lines have been analyzed)", line):
|
||||||
RES_all['NbAnalysedLines' ]= float(res.group(1))
|
RES_all["NbAnalysedLines"] = float(res.group(1))
|
||||||
elif line == "Raw metrics":
|
elif line == "Raw metrics":
|
||||||
ScanState = TScanState.OTHER_REPORT_METRICS
|
ScanState = TScanState.OTHER_REPORT_METRICS
|
||||||
else:
|
else:
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Statistics']['module'] = cls.TryExtractPYReportMetric(line,"module")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Statistics']['class'] = cls.TryExtractPYReportMetric(line,"class")
|
RES_all["Statistics"]["module"] = cls.TryExtractPYReportMetric(line, "module")
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Statistics']['method'] = cls.TryExtractPYReportMetric(line,"method")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Statistics']['function'] = cls.TryExtractPYReportMetric(line,"function")
|
RES_all["Statistics"]["class"] = cls.TryExtractPYReportMetric(line, "class")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
elif ScanState == TScanState.OTHER_REPORT_METRICS:
|
RES_all["Statistics"]["method"] = cls.TryExtractPYReportMetric(line, "method")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
|
RES_all["Statistics"]["function"] = cls.TryExtractPYReportMetric(line, "function")
|
||||||
|
|
||||||
|
elif ScanState == TScanState.OTHER_REPORT_METRICS:
|
||||||
if line == "Duplication":
|
if line == "Duplication":
|
||||||
RES_all['RawMetricsPercent']['code'] = RES_all['RawMetrics']['code'] / RES_all['NbAnalysedLines' ]
|
RES_all["RawMetricsPercent"]["code"] = RES_all["RawMetrics"]["code"] / RES_all["NbAnalysedLines"]
|
||||||
RES_all['RawMetricsPercent']['docstring'] = RES_all['RawMetrics']['docstring'] / RES_all['NbAnalysedLines' ]
|
RES_all["RawMetricsPercent"]["docstring"] = RES_all["RawMetrics"]["docstring"] / RES_all["NbAnalysedLines"]
|
||||||
RES_all['RawMetricsPercent']['comment'] = RES_all['RawMetrics']['comment'] / RES_all['NbAnalysedLines' ]
|
RES_all["RawMetricsPercent"]["comment"] = RES_all["RawMetrics"]["comment"] / RES_all["NbAnalysedLines"]
|
||||||
RES_all['RawMetricsPercent']['empty'] = RES_all['RawMetrics']['empty'] / RES_all['NbAnalysedLines' ]
|
RES_all["RawMetricsPercent"]["empty"] = RES_all["RawMetrics"]["empty"] / RES_all["NbAnalysedLines"]
|
||||||
ScanState = TScanState.OTHER_REPORT_DUPLICATION
|
ScanState = TScanState.OTHER_REPORT_DUPLICATION
|
||||||
else:
|
else:
|
||||||
with suppress(PyLintMetricNotFound): RES_all['RawMetrics']['code'] = cls.TryExtractPYReportMetric(line,"code")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['RawMetrics']['docstring'] = cls.TryExtractPYReportMetric(line,"docstring")
|
RES_all["RawMetrics"]["code"] = cls.TryExtractPYReportMetric(line, "code")
|
||||||
with suppress(PyLintMetricNotFound): RES_all['RawMetrics']['comment'] = cls.TryExtractPYReportMetric(line,"comment")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['RawMetrics']['empty'] = cls.TryExtractPYReportMetric(line,"empty")
|
RES_all["RawMetrics"]["docstring"] = cls.TryExtractPYReportMetric(line, "docstring")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
elif ScanState == TScanState.OTHER_REPORT_DUPLICATION:
|
RES_all["RawMetrics"]["comment"] = cls.TryExtractPYReportMetric(line, "comment")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
|
RES_all["RawMetrics"]["empty"] = cls.TryExtractPYReportMetric(line, "empty")
|
||||||
|
|
||||||
|
elif ScanState == TScanState.OTHER_REPORT_DUPLICATION:
|
||||||
if line == "Messages by category":
|
if line == "Messages by category":
|
||||||
ScanState = TScanState.OTHER_REPORT_MESSAGES_CAT
|
ScanState = TScanState.OTHER_REPORT_MESSAGES_CAT
|
||||||
else:
|
else:
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Duplication']['NbDupLines'] = cls.TryExtractPYReportMetric(line,"nb duplicated lines")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Duplication']['PersentDuplicatedLines'] = cls.TryExtractPYReportMetric(line,"percent duplicated lines")
|
RES_all["Duplication"]["NbDupLines"] = cls.TryExtractPYReportMetric(line, "nb duplicated lines")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
elif ScanState == TScanState.OTHER_REPORT_MESSAGES_CAT:
|
RES_all["Duplication"]["PersentDuplicatedLines"] = cls.TryExtractPYReportMetric(
|
||||||
|
line, "percent duplicated lines"
|
||||||
|
)
|
||||||
|
|
||||||
|
elif ScanState == TScanState.OTHER_REPORT_MESSAGES_CAT:
|
||||||
if line == "Messages":
|
if line == "Messages":
|
||||||
ScanState = TScanState.OTHER_REPORT_MESSAGES
|
ScanState = TScanState.OTHER_REPORT_MESSAGES
|
||||||
else:
|
else:
|
||||||
with suppress(PyLintMetricNotFound): RES_all['MessagesCat']['Convention'] = cls.TryExtractPYReportMetric(line,"convention")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['MessagesCat']['Refactor'] = cls.TryExtractPYReportMetric(line,"refactor")
|
RES_all["MessagesCat"]["Convention"] = cls.TryExtractPYReportMetric(line, "convention")
|
||||||
with suppress(PyLintMetricNotFound): RES_all['MessagesCat']['Warning'] = cls.TryExtractPYReportMetric(line,"warning")
|
with suppress(PyLintMetricNotFound):
|
||||||
with suppress(PyLintMetricNotFound): RES_all['MessagesCat']['Error'] = cls.TryExtractPYReportMetric(line,"error")
|
RES_all["MessagesCat"]["Refactor"] = cls.TryExtractPYReportMetric(line, "refactor")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
elif ScanState == TScanState.OTHER_REPORT_MESSAGES:
|
RES_all["MessagesCat"]["Warning"] = cls.TryExtractPYReportMetric(line, "warning")
|
||||||
|
with suppress(PyLintMetricNotFound):
|
||||||
|
RES_all["MessagesCat"]["Error"] = cls.TryExtractPYReportMetric(line, "error")
|
||||||
|
|
||||||
|
elif ScanState == TScanState.OTHER_REPORT_MESSAGES:
|
||||||
# approx match because the number of '-' depend on screen width..
|
# approx match because the number of '-' depend on screen width..
|
||||||
if line.startswith("--------"):
|
if line.startswith("--------"):
|
||||||
ScanState = TScanState.OTHER_REPORT_END
|
ScanState = TScanState.OTHER_REPORT_END
|
||||||
else:
|
else:
|
||||||
for PylintMessage in cls.PylintMessageList.keys():
|
for PylintMessage in cls.PylintMessageList.keys():
|
||||||
with suppress(PyLintMetricNotFound): RES_all['Messages'][PylintMessage] = cls.TryExtractPYReportMetric(line,PylintMessage)
|
with suppress(PyLintMetricNotFound):
|
||||||
|
RES_all["Messages"][PylintMessage] = cls.TryExtractPYReportMetric(line, PylintMessage)
|
||||||
elif ScanState == TScanState.OTHER_REPORT_END:
|
|
||||||
if res:=re.search(r"(?<=Your code has been rated at )(\d+(?:\.\d+)?)/10",line):
|
elif ScanState == TScanState.OTHER_REPORT_END:
|
||||||
RES_all['GlobalScore']=float(res.group(1))
|
if res := re.search(r"(?<=Your code has been rated at )(\d+(?:\.\d+)?)/10", line):
|
||||||
print(RES_all['GlobalScore'])
|
RES_all["GlobalScore"] = float(res.group(1))
|
||||||
|
print(RES_all["GlobalScore"])
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Invalid ScanState")
|
raise RuntimeError("Invalid ScanState")
|
||||||
Outfile.write(JsonContent)
|
Outfile.write(JsonContent)
|
||||||
|
|
||||||
with open(cls.get_result_dir()/"metrics.json", 'w') as json_file:
|
with open(cls.get_result_dir() / "metrics.json", "w") as json_file:
|
||||||
json.dump(RES_all, json_file)
|
json.dump(RES_all, json_file)
|
||||||
|
|
||||||
# exporting all Data in one csv, unused atm because jenkins seems not able to select columns from csv an keep displaying all...
|
# exporting all Data in one csv, unused atm because jenkins seems not able to select columns from csv an keep displaying all...
|
||||||
# => to export a working full csv we need to a 'flat' dict (no more nested dict)
|
# => to export a working full csv we need to a 'flat' dict (no more nested dict)
|
||||||
RES_all_trim = copy.deepcopy(RES_all)
|
RES_all_trim = copy.deepcopy(RES_all)
|
||||||
del RES_all_trim["Messages"]
|
del RES_all_trim["Messages"]
|
||||||
flat_RES_all=pandas.json_normalize(RES_all_trim, sep='_').to_dict(orient='records')[0]
|
flat_RES_all = pandas.json_normalize(RES_all_trim, sep="_").to_dict(orient="records")[0]
|
||||||
|
|
||||||
with open(cls.get_result_dir()/"metrics.csv", 'w', newline='') as csv_file:
|
with open(cls.get_result_dir() / "metrics.csv", "w", newline="") as csv_file:
|
||||||
writer = csv.DictWriter(csv_file,fieldnames=flat_RES_all.keys())
|
writer = csv.DictWriter(csv_file, fieldnames=flat_RES_all.keys())
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerow(flat_RES_all)
|
writer.writerow(flat_RES_all)
|
||||||
|
|
||||||
# splited csv exports for jenkins plots: RawMetricsPercent
|
# splited csv exports for jenkins plots: RawMetricsPercent
|
||||||
RES_all_percent = RES_all["RawMetricsPercent"]
|
RES_all_percent = RES_all["RawMetricsPercent"]
|
||||||
with open(cls.get_result_dir()/"metrics_rawpercent.csv", 'w', newline='') as csv_file:
|
with open(cls.get_result_dir() / "metrics_rawpercent.csv", "w", newline="") as csv_file:
|
||||||
writer = csv.DictWriter(csv_file,fieldnames=RES_all_percent.keys())
|
writer = csv.DictWriter(csv_file, fieldnames=RES_all_percent.keys())
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerow(RES_all_percent)
|
writer.writerow(RES_all_percent)
|
||||||
|
|
||||||
# splited csv exports for jenkins plots: Statistics + Duplication + NbAnalysedStatments + NbAnalysedLines
|
# splited csv exports for jenkins plots: Statistics + Duplication + NbAnalysedStatments + NbAnalysedLines
|
||||||
RES_all_stats = copy.deepcopy(RES_all["Statistics"])
|
RES_all_stats = copy.deepcopy(RES_all["Statistics"])
|
||||||
RES_all_stats["NbDupLines"] = RES_all['Duplication']['NbDupLines']
|
RES_all_stats["NbDupLines"] = RES_all["Duplication"]["NbDupLines"]
|
||||||
RES_all_stats["PersentDuplicatedLines"] = RES_all['Duplication']['PersentDuplicatedLines']
|
RES_all_stats["PersentDuplicatedLines"] = RES_all["Duplication"]["PersentDuplicatedLines"]
|
||||||
RES_all_stats["NbAnalysedStatments"] = RES_all['NbAnalysedStatments' ]
|
RES_all_stats["NbAnalysedStatments"] = RES_all["NbAnalysedStatments"]
|
||||||
RES_all_stats["NbAnalysedLines"] = RES_all['NbAnalysedLines' ]
|
RES_all_stats["NbAnalysedLines"] = RES_all["NbAnalysedLines"]
|
||||||
with open(cls.get_result_dir()/"metrics_Statistics.csv", 'w', newline='') as csv_file:
|
with open(cls.get_result_dir() / "metrics_Statistics.csv", "w", newline="") as csv_file:
|
||||||
writer = csv.DictWriter(csv_file,fieldnames=RES_all_stats.keys())
|
writer = csv.DictWriter(csv_file, fieldnames=RES_all_stats.keys())
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerow(RES_all_stats)
|
writer.writerow(RES_all_stats)
|
||||||
|
|
||||||
# splited csv exports for jenkins plots: Statistics + Duplication
|
# splited csv exports for jenkins plots: Statistics + Duplication
|
||||||
RES_all_MessagesCat = RES_all['MessagesCat']
|
RES_all_MessagesCat = RES_all["MessagesCat"]
|
||||||
with open(cls.get_result_dir()/"metrics_MessagesCat.csv", 'w', newline='') as csv_file:
|
with open(cls.get_result_dir() / "metrics_MessagesCat.csv", "w", newline="") as csv_file:
|
||||||
writer = csv.DictWriter(csv_file,fieldnames=RES_all_MessagesCat.keys())
|
writer = csv.DictWriter(csv_file, fieldnames=RES_all_MessagesCat.keys())
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerow(RES_all_MessagesCat)
|
writer.writerow(RES_all_MessagesCat)
|
||||||
|
|
||||||
# splited csv exports for jenkins plots: GlobalScore
|
# splited csv exports for jenkins plots: GlobalScore
|
||||||
RES_GlobalScore = {'GlobalScore': RES_all['GlobalScore']}
|
RES_GlobalScore = {"GlobalScore": RES_all["GlobalScore"]}
|
||||||
with open(cls.get_result_dir()/"metrics_GlobalScore.csv", 'w', newline='') as csv_file:
|
with open(cls.get_result_dir() / "metrics_GlobalScore.csv", "w", newline="") as csv_file:
|
||||||
writer = csv.DictWriter(csv_file,fieldnames=RES_GlobalScore.keys())
|
writer = csv.DictWriter(csv_file, fieldnames=RES_GlobalScore.keys())
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerow(RES_GlobalScore)
|
writer.writerow(RES_GlobalScore)
|
||||||
|
|
||||||
# converting the report using pylint_json2html (/!\ internal API, but as their is no leading '_' ...)
|
# converting the report using pylint_json2html (/!\ internal API, but as their is no leading '_' ...)
|
||||||
with open(cls.get_result_dir()/"report.html","w+", encoding='utf-8') as Outfile:
|
with open(cls.get_result_dir() / "report.html", "w+", encoding="utf-8") as Outfile:
|
||||||
raw_data = json.loads(JsonContent)
|
raw_data = json.loads(JsonContent)
|
||||||
report=pylint_json2html.Report( raw_data)
|
report = pylint_json2html.Report(raw_data)
|
||||||
Outfile.write(report.render())
|
Outfile.write(report.render())
|
||||||
|
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|||||||
@@ -16,36 +16,46 @@ from mypy import api
|
|||||||
from .helper_base import helper_withresults_base
|
from .helper_base import helper_withresults_base
|
||||||
|
|
||||||
|
|
||||||
class types_check(helper_withresults_base):
|
class types_check(helper_withresults_base):
|
||||||
JUnitReportName = "junit.xml"
|
JUnitReportName = "junit.xml"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_job(cls):
|
def do_job(cls):
|
||||||
print("checking code typing ...")
|
print("checking code typing ...")
|
||||||
result = api.run([ # project path
|
result = api.run(
|
||||||
"-m",
|
[ # project path
|
||||||
"src." + str(cls.pyproject['project']['name']),
|
"-p",
|
||||||
# analysis configuration
|
"src." + cls.pyproject["project"]["name"],
|
||||||
"--ignore-missing-imports",
|
# analysis configuration
|
||||||
"--strict-equality",
|
# "--show-traceback",
|
||||||
# reports generation
|
"--explicit-package-bases",
|
||||||
"--cobertura-xml-report", str(cls.get_result_dir()),
|
# "--strict-equality",
|
||||||
"--html-report", str(cls.get_result_dir()),
|
# "--check-untyped-defs",
|
||||||
"--linecount-report", str(cls.get_result_dir()),
|
"--enable-incomplete-feature=Unpack",
|
||||||
"--linecoverage-report", str(cls.get_result_dir()),
|
# reports generation
|
||||||
"--lineprecision-report", str(cls.get_result_dir()),
|
"--cobertura-xml-report",
|
||||||
"--txt-report", str(cls.get_result_dir()),
|
str(cls.get_result_dir()),
|
||||||
"--xml-report", str(cls.get_result_dir()),
|
"--html-report",
|
||||||
"--junit-xml", str(cls.get_result_dir()) + "/" + cls.JUnitReportName
|
str(cls.get_result_dir()),
|
||||||
])
|
"--txt-report",
|
||||||
|
str(cls.get_result_dir()),
|
||||||
|
"--xml-report",
|
||||||
|
str(cls.get_result_dir()),
|
||||||
|
"--junit-xml",
|
||||||
|
str(cls.get_result_dir()) + "/" + cls.JUnitReportName,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
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")
|
||||||
print(result[1]) # stderr
|
print(result[1]) # stderr
|
||||||
|
|
||||||
print('\nExit status:', result[2])
|
print("\nExit status:", result[2])
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|||||||
@@ -21,34 +21,36 @@ from junit2htmlreport import parser as junit2html_parser
|
|||||||
from .helper_base import helper_withresults_base
|
from .helper_base import helper_withresults_base
|
||||||
|
|
||||||
|
|
||||||
class unit_test(helper_withresults_base):
|
class unit_test(helper_withresults_base):
|
||||||
enable_coverage_check: bool = False
|
enable_coverage_check: bool = False
|
||||||
enable_xml_export: bool = True
|
enable_xml_export: bool = True
|
||||||
enable_full_xml_export: bool = True
|
enable_full_xml_export: bool = True
|
||||||
FullReportName: str = "full_report"
|
FullReportName: str = "full_report"
|
||||||
CoverageReportName: str = "test_coverage"
|
CoverageReportName: str = "test_coverage"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_job(cls):
|
def do_job(cls):
|
||||||
if cls.enable_coverage_check==True:
|
if cls.enable_coverage_check == True:
|
||||||
import coverage
|
import coverage
|
||||||
|
|
||||||
# preparing unittest framework
|
# preparing unittest framework
|
||||||
test_loader = unittest.TestLoader()
|
test_loader = unittest.TestLoader()
|
||||||
|
|
||||||
if cls.enable_coverage_check == True:
|
if cls.enable_coverage_check == True:
|
||||||
#we start coverage now because module files discovery is part of the coverage measurement
|
# we start coverage now because module files discovery is part of the coverage measurement
|
||||||
CoverageReportPath = Path(str(cls.get_result_dir())+"_coverage")
|
CoverageReportPath = Path(str(cls.get_result_dir()) + "_coverage")
|
||||||
cls._reset_dir(CoverageReportPath)
|
cls._reset_dir(CoverageReportPath)
|
||||||
cov = coverage.Coverage(cover_pylib=False,branch=True,source_pkgs=["src."+cls.pyproject['project']['name']])
|
cov = coverage.Coverage(cover_pylib=False, branch=True, source_pkgs=["src." + cls.pyproject["project"]["name"]])
|
||||||
cov.start()
|
cov.start()
|
||||||
|
|
||||||
package_tests = test_loader.discover(start_dir=str(cls.project_rootdir_path / "test"),top_level_dir=str(cls.project_rootdir_path / "test"))
|
package_tests = test_loader.discover(
|
||||||
|
start_dir=str(cls.project_rootdir_path / "test"), top_level_dir=str(cls.project_rootdir_path / "test")
|
||||||
|
)
|
||||||
if cls.enable_xml_export:
|
if cls.enable_xml_export:
|
||||||
testRunner = xmlrunner.XMLTestRunner(output=str(str(cls.get_result_dir())))
|
testRunner = xmlrunner.XMLTestRunner(output=str(str(cls.get_result_dir())))
|
||||||
else:
|
else:
|
||||||
testRunner = unittest.TextTestRunner()
|
testRunner = unittest.TextTestRunner()
|
||||||
|
|
||||||
# running the test
|
# running the test
|
||||||
testRunner.run(package_tests)
|
testRunner.run(package_tests)
|
||||||
|
|
||||||
@@ -57,23 +59,23 @@ class unit_test(helper_withresults_base):
|
|||||||
cov.stop()
|
cov.stop()
|
||||||
cov.save()
|
cov.save()
|
||||||
cov.html_report(directory=str(CoverageReportPath))
|
cov.html_report(directory=str(CoverageReportPath))
|
||||||
cov.xml_report(outfile=(CoverageReportPath/f"{cls.CoverageReportName}.xml"))
|
cov.xml_report(outfile=(CoverageReportPath / f"{cls.CoverageReportName}.xml"))
|
||||||
|
|
||||||
# computing results (Only if xml available)
|
# computing results (Only if xml available)
|
||||||
if cls.enable_full_xml_export == True:
|
if cls.enable_full_xml_export == True:
|
||||||
print("Full reports generation...")
|
print("Full reports generation...")
|
||||||
FullReportPath = Path(str(cls.get_result_dir())+"_full")
|
FullReportPath = Path(str(cls.get_result_dir()) + "_full")
|
||||||
cls._reset_dir(FullReportPath)
|
cls._reset_dir(FullReportPath)
|
||||||
|
|
||||||
FullJUnitReport = JUnitXml()
|
FullJUnitReport = JUnitXml()
|
||||||
for fname in [fname for fname in os.listdir(cls.get_result_dir()) if fname.endswith('.xml')]:
|
for fname in [fname for fname in os.listdir(cls.get_result_dir()) if fname.endswith(".xml")]:
|
||||||
FullJUnitReport+=JUnitXml.fromfile(str(cls.get_result_dir() / fname))
|
FullJUnitReport += JUnitXml.fromfile(str(cls.get_result_dir() / fname))
|
||||||
|
|
||||||
current_datetime = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
|
current_datetime = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
|
||||||
full_report_base_name = f'{cls.pyproject["project"]["name"]}-{cls.FullReportName}-{current_datetime}'
|
full_report_base_name = f'{cls.pyproject["project"]["name"]}-{cls.FullReportName}-{current_datetime}'
|
||||||
FullJUnitReport.write(str(FullReportPath / f'{full_report_base_name}.xml'))
|
FullJUnitReport.write(str(FullReportPath / f"{full_report_base_name}.xml"))
|
||||||
report = junit2html_parser.Junit(FullReportPath/ f'{full_report_base_name}.xml')
|
report = junit2html_parser.Junit(FullReportPath / f"{full_report_base_name}.xml")
|
||||||
html = report.html()
|
html = report.html()
|
||||||
with open(FullReportPath/ f'{full_report_base_name}.html', "wb") as outfile:
|
with open(FullReportPath / f"{full_report_base_name}.html", "wb") as outfile:
|
||||||
outfile.write(html.encode('utf-8'))
|
outfile.write(html.encode("utf-8"))
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|||||||
95
mkdocs.yml
95
mkdocs.yml
@@ -1,19 +1,11 @@
|
|||||||
# 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 <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
|
||||||
|
|
||||||
|
|
||||||
docs_dir: docs
|
docs_dir: docs
|
||||||
site_name: pygitversionhelper
|
site_name: pygitversionhelper
|
||||||
site_url: https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/latest/
|
site_url: https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/latest/
|
||||||
site_description: pygitversionhelper
|
site_description: A simple simple git version helper in python.
|
||||||
site_author: chacha
|
site_author: prune
|
||||||
repo_url: https://chacha.ddns.net/gitea/chacha/pygitversionhelper
|
repo_url: https://chacha.ddns.net/gitea/chacha/pygitversionhelper
|
||||||
use_directory_urls: false
|
use_directory_urls: false
|
||||||
|
copyright: CC BY-NC-SA 4.0
|
||||||
theme:
|
theme:
|
||||||
name: material
|
name: material
|
||||||
features:
|
features:
|
||||||
@@ -21,8 +13,13 @@ theme:
|
|||||||
- navigation.tracking
|
- navigation.tracking
|
||||||
- navigation.tabs
|
- navigation.tabs
|
||||||
- navigation.tabs.sticky
|
- navigation.tabs.sticky
|
||||||
|
- navigation.footer
|
||||||
- toc.integrate
|
- toc.integrate
|
||||||
- navigation.top
|
- navigation.top
|
||||||
|
- navigation.section
|
||||||
|
- content.code.annotate
|
||||||
|
- navigation.prune
|
||||||
|
- toc.follow
|
||||||
palette:
|
palette:
|
||||||
- media: '(prefers-color-scheme: dark)'
|
- media: '(prefers-color-scheme: dark)'
|
||||||
scheme: slate
|
scheme: slate
|
||||||
@@ -40,23 +37,81 @@ theme:
|
|||||||
name: Switch to dark mode
|
name: Switch to dark mode
|
||||||
plugins:
|
plugins:
|
||||||
- search
|
- search
|
||||||
|
- markdownextradata
|
||||||
|
- mermaid2
|
||||||
- localsearch
|
- localsearch
|
||||||
- autorefs
|
|
||||||
- mkdocstrings:
|
- mkdocstrings:
|
||||||
default_handler: python
|
default_handler: python
|
||||||
handlers:
|
handlers:
|
||||||
python:
|
python:
|
||||||
selection:
|
options:
|
||||||
filters:
|
filters:
|
||||||
- '!^_(?!_init__)'
|
- '!^_[^_]'
|
||||||
inherited_members: true
|
inherited_members: true
|
||||||
rendering:
|
|
||||||
show_root_heading: false
|
|
||||||
show_root_toc_entry: false
|
|
||||||
show_root_full_path: false
|
|
||||||
show_if_no_docstring: true
|
show_if_no_docstring: true
|
||||||
show_signature_annotations: true
|
show_signature_annotations: true
|
||||||
show_source: false
|
show_source: false
|
||||||
heading_level: 2
|
|
||||||
group_by_category: true
|
|
||||||
show_category_heading: true
|
show_category_heading: true
|
||||||
|
group_by_category: true
|
||||||
|
docstring_section_style: spacy
|
||||||
|
show_root_full_path: false
|
||||||
|
merge_init_into_class: true
|
||||||
|
separate_signature: true
|
||||||
|
- with-pdf:
|
||||||
|
cover_subtitle: User Manual
|
||||||
|
cover_logo: C:\Users\chacha\git\pygitversionhelper\docs-static\Library.jpg
|
||||||
|
verbose: false
|
||||||
|
exclude_pages:
|
||||||
|
- LICENSE
|
||||||
|
output_path: C:\Users\chacha\git\pygitversionhelper\helpers-results\doc_gen\site\pdf\manual.pdf
|
||||||
|
markdown_extensions:
|
||||||
|
- def_list
|
||||||
|
- tables
|
||||||
|
- attr_list
|
||||||
|
- abbr
|
||||||
|
- pymdownx.blocks.admonition:
|
||||||
|
types:
|
||||||
|
- new
|
||||||
|
- settings
|
||||||
|
- note
|
||||||
|
- abstract
|
||||||
|
- info
|
||||||
|
- tip
|
||||||
|
- success
|
||||||
|
- question
|
||||||
|
- warning
|
||||||
|
- failure
|
||||||
|
- danger
|
||||||
|
- bug
|
||||||
|
- example
|
||||||
|
- quote
|
||||||
|
- pymdownx.blocks.definition
|
||||||
|
- pymdownx.blocks.details
|
||||||
|
- pymdownx.blocks.tab
|
||||||
|
- pymdownx.blocks.html
|
||||||
|
- pymdownx.betterem:
|
||||||
|
smart_enable: all
|
||||||
|
- pymdownx.caret
|
||||||
|
- pymdownx.critic
|
||||||
|
- pymdownx.details
|
||||||
|
- pymdownx.inlinehilite
|
||||||
|
- pymdownx.snippets
|
||||||
|
- pymdownx.highlight:
|
||||||
|
anchor_linenums: true
|
||||||
|
line_spans: __span
|
||||||
|
pygments_lang_class: true
|
||||||
|
- pymdownx.keys
|
||||||
|
- pymdownx.mark
|
||||||
|
- pymdownx.progressbar
|
||||||
|
- pymdownx.smartsymbols
|
||||||
|
- pymdownx.tasklist:
|
||||||
|
custom_checkbox: true
|
||||||
|
- pymdownx.tilde
|
||||||
|
- footnotes
|
||||||
|
- pymdownx.superfences
|
||||||
|
- pymdownx.emoji:
|
||||||
|
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||||
|
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||||
|
extra:
|
||||||
|
branch: master
|
||||||
|
repository: pygitversionhelper
|
||||||
|
|||||||
@@ -7,17 +7,15 @@
|
|||||||
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=63", "wheel", "setuptools-git-versioning<2"]
|
requires = ["setuptools>=63", "wheel", "setuptools_scm"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[tool.setuptools-git-versioning]
|
[tool.setuptools_scm]
|
||||||
enabled = true
|
version_scheme= "post-release"
|
||||||
dev_template = "{tag}.post{ccount}"
|
|
||||||
tag_filter = "^\\d+\\.\\d+\\.\\d+$"
|
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "pygitversionhelper"
|
name = "pygitversionhelper"
|
||||||
description = "pygitversionhelper"
|
description = "A simple simple git version helper in python."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.9"
|
requires-python = ">=3.9"
|
||||||
keywords = ["chacha","chacha","template","pygitversionhelper"]
|
keywords = ["chacha","chacha","template","pygitversionhelper"]
|
||||||
@@ -51,16 +49,17 @@ where = ["src"]
|
|||||||
"pygitversionhelper.data" = ["*.*"]
|
"pygitversionhelper.data" = ["*.*"]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper"
|
Homepage = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/"
|
||||||
Documentation = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/wiki"
|
Documentation = "https://chacha.ddns.net/mkdocs-web/chacha/pygitversionhelper/master/latest/"
|
||||||
Tracker = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/issues"
|
Tracker = "https://chacha.ddns.net/gitea/chacha/pygitversionhelper/issues"
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
test = ["junitparser>=2.8","junit2html>=30.1","xmlrunner>=1.7","mypy>=0.99" ]
|
test = ["junitparser>=2.8","junit2html>=30.1","xmlrunner>=1.7","mypy>=0.99" ]
|
||||||
coverage-check = ["coverage>=7.0"]
|
coverage-check = ["coverage>=7.0"]
|
||||||
|
complexity-check = ["radon>=5.1"]
|
||||||
quality-check = ["pylint>=2.15","pylint-json2html>=0.4","pandas>=1.5"]
|
quality-check = ["pylint>=2.15","pylint-json2html>=0.4","pandas>=1.5"]
|
||||||
type-check = ["mypy[reports]>=0.99" ]
|
type-check = ["mypy[reports]>=0.99" ]
|
||||||
doc-gen = ["mkdocs>=1.4.0", "mkdocs-material>=8.5", "mkdocs-localsearch>=0.9.0", "mkdocstrings[python]>=0.19", "mkdocs-with-pdf>=0.9.3","pyyaml>=6.0"]
|
doc-gen = ["mkdocs>=1.4.0", "mkdocs-material>=8.5","mkdocs-pymdownx-material-extras", "mkdocs-localsearch>=0.9.0", "mkdocstrings[python]>=0.19", "mkdocs-with-pdf>=0.9.3","pyyaml>=6.0","pymdown-extensions>=9","mkdocs-markdownextradata-plugin","mkdocs-mermaid2-plugin"]
|
||||||
|
|
||||||
#[project.scripts]
|
#[project.scripts]
|
||||||
#my-script = "my_package.module:function"
|
#my-script = "my_package.module:function"
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ from importlib.metadata import version, PackageNotFoundError
|
|||||||
|
|
||||||
try: # pragma: no cover
|
try: # pragma: no cover
|
||||||
__version__ = version("pygitversionhelper")
|
__version__ = version("pygitversionhelper")
|
||||||
except PackageNotFoundError: # pragma: no cover
|
except PackageNotFoundError: # pragma: no cover
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.warn("can not read __version__, assuming local test context, setting it to ?.?.?")
|
warnings.warn("can not read __version__, assuming local test context, setting it to ?.?.?")
|
||||||
__version__ = "?.?.?"
|
__version__ = "?.?.?"
|
||||||
|
|
||||||
|
|||||||
7
src/pygitversionhelper/data/__init__.py
Normal file
7
src/pygitversionhelper/data/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# pygitversionhelper (c) by chacha
|
||||||
|
#
|
||||||
|
# pygitversionhelper 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 <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -4,4 +4,4 @@
|
|||||||
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported License.
|
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported License.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the license along with this
|
# You should have received a copy of the license along with this
|
||||||
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user