initial template commit
This commit is contained in:
46
.gitignore
vendored
Normal file
46
.gitignore
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# unitest:
|
||||
site
|
||||
docs
|
||||
helpers-results
|
||||
.coverage
|
||||
/.mypy_cache/
|
||||
.coverage
|
||||
.mypy_cache
|
||||
test/tmp
|
||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>{{project_name}}</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
13
.pydevproject
Normal file
13
.pydevproject
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/${PROJECT_DIR_NAME}/src</path>
|
||||
<path>/${PROJECT_DIR_NAME}</path>
|
||||
</pydev_pathproperty>
|
||||
|
||||
</pydev_project>
|
||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
2
.settings/org.eclipse.core.runtime.prefs
Normal file
2
.settings/org.eclipse.core.runtime.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
line.separator=\n
|
||||
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
# 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 debian:bullseye-slim
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y python3.9 python3-virtualenv python3-pip git python3.9-venv weasyprint
|
||||
|
||||
RUN python3 -m pip install --upgrade pip
|
||||
RUN python3 -m pip install --upgrade virtualenv
|
||||
RUN python3 -m pip install --upgrade setuptools wheel build
|
||||
728
Jenkinsfile
vendored
Normal file
728
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,728 @@
|
||||
// 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/>.
|
||||
|
||||
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:
|
||||
// use to send email if workflow problem
|
||||
def _MaintainerName = "CHACHA"
|
||||
def _MaintainerEmail = "1000CHACHA0001@gmail.com"
|
||||
// SCM credential ID
|
||||
def _SCMCredentials = "7fbf4db8-eb36-447c-b2e4-44da4535295f"
|
||||
// toogle PreRelease flag on Gitea release system
|
||||
def _bPreRelease = false
|
||||
// toogle Draft flag on Gitea release system => If False, TAG is not created
|
||||
def _bDraft = false
|
||||
// release content / changelog management
|
||||
def _bAutoChangelog = true //Not supported yet
|
||||
def _ReleaseContent_Title = "# _CI/CD Automatic Release_"
|
||||
def bPushMasterOnPypi = false
|
||||
// full rebuild toogle
|
||||
def _bFullRebuilt = true
|
||||
def _MkDocsWebURL = "dabauto--mkdocs-web.dmz.chacha.home/mkdocs-web/"
|
||||
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 /!\
|
||||
String determineRepoUserName() {
|
||||
return scm.getUserRemoteConfigs()[0].getUrl().tokenize('/')[3].split("\\.")[0]
|
||||
}
|
||||
|
||||
// commands Helper: /!\ Made for GITEA /!\
|
||||
String determineRepoName() {
|
||||
return scm.getUserRemoteConfigs()[0].getUrl().tokenize('/')[4].split("\\.")[0]
|
||||
}
|
||||
|
||||
// commands Helper: /!\ Made for GITEA /!\
|
||||
String ExtractGiteaBaseUrl(inUrl) {
|
||||
def pattern = ~/(.*)((?<=\/)[^\/]+\/)([^\/\.]+(?:\.git)?)\/?$/
|
||||
assert pattern instanceof java.util.regex.Pattern
|
||||
|
||||
def matcher = inUrl =~ pattern
|
||||
assert matcher instanceof java.util.regex.Matcher
|
||||
|
||||
assert matcher.find()
|
||||
assert matcher.size() == 1
|
||||
return matcher[0][1]
|
||||
}
|
||||
|
||||
String ExtractBaseVersion(inVersion) {
|
||||
def pattern = ~/^(?<version>[0-9]+\.[0-9]+\.[0-9]+)(?<prerelease>(?:(?:a|b|rc)[0-9]*)?[\.\-_](?:dev|post)\d*)?$/
|
||||
assert pattern instanceof java.util.regex.Pattern
|
||||
|
||||
def matcher = inVersion =~ pattern
|
||||
assert matcher instanceof java.util.regex.Matcher
|
||||
|
||||
assert matcher.find()
|
||||
assert matcher.size() == 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 {
|
||||
|
||||
// for Docker based build (preferable)
|
||||
agent { dockerfile true }
|
||||
|
||||
// other builds might fall back to generic mode
|
||||
//agent { any }
|
||||
// or even require a specific machine
|
||||
//agent {node {label 'FOO-CIAgent' }}
|
||||
|
||||
options {
|
||||
// enable if the build is using external resource
|
||||
// or any other reason needing it to be exclusive
|
||||
// => enabled by default, disable is if more performance needed
|
||||
disableConcurrentBuilds()
|
||||
}
|
||||
|
||||
environment {
|
||||
// TERM env variable is needed to make processses think we are on a real terminal
|
||||
TERM="xterm"
|
||||
// HOME env variable is needed to allow pip install packages as users
|
||||
HOME="$env.WORKSPACE"
|
||||
// _GIT_BRANCH env variable is needed to get the branch only (and not origin/XXXX), without fetching it
|
||||
_GIT_BRANCH=sh (
|
||||
script: "echo ${GIT_BRANCH} | sed -e 's|origin/||g'",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
// those 2 env var are for conveniance, get from scm url (which **NEED TO BE GITEA**)
|
||||
_PROJECT_USER_NAME=determineRepoUserName()
|
||||
_PROJECT_NAME=determineRepoName()
|
||||
_GITEA_BASE_URL=ExtractGiteaBaseUrl("$GIT_URL")
|
||||
PY_PROJECT_NAME = "__NOTSET__"
|
||||
PY_PROJECT_VERSION = "__NOTSET__"
|
||||
PY_PROJECT_VERSION_STRIPPED = "__NOTSET__"
|
||||
CHANGELOG = "__NOTSET__"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage("Prepare") {
|
||||
steps {
|
||||
script {
|
||||
if (_bFullRebuilt) {
|
||||
// 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
|
||||
sh("find ~/. -name . -o -prune -exec rm -rf -- {} +")
|
||||
}
|
||||
else {
|
||||
sh("find ~/. -name . ! -path './TEST_ENV/*' ! -path './BUILD_ENV/*' -o -prune -exec rm -rf -- {} +")
|
||||
}
|
||||
if(_GIT_BRANCH!="master") {
|
||||
_bPreRelease = true
|
||||
}
|
||||
}
|
||||
// displaying env vars, mainly for debugging purpose
|
||||
echo("GIT_BRANCH:. . . . . . . . . . . $GIT_BRANCH")
|
||||
echo("_GIT_BRANCH: . . . . . . . . . . $_GIT_BRANCH")
|
||||
echo("GIT_URL: . . . . . . . . . . . . $GIT_URL ")
|
||||
echo("_GITEA_BASE_URL: . . . . . . . . $_GITEA_BASE_URL")
|
||||
echo("GIT_COMMIT:. . . . . . . . . . . $GIT_COMMIT ")
|
||||
echo("_PROJECT_USER_NAME:. . . . . . . $_PROJECT_USER_NAME")
|
||||
echo("_PROJECT_NAME: . . . . . . . . . $_PROJECT_NAME")
|
||||
echo("_MaintainerEmail:. . . . . . . . $_MaintainerEmail")
|
||||
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 TEST_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")
|
||||
sh(". ~/BUILD_ENV/bin/activate && pip install --upgrade 'copier==8.*' jinja2-slug toml")
|
||||
|
||||
sh(". ~/TEST_ENV/bin/activate && pip install --upgrade pip")
|
||||
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install --upgrade pip")
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install simple_rest_client requests twine packaging")
|
||||
|
||||
script {
|
||||
if(_PROJECT_NAME!="pygitversionhelper") {
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install pygitversionhelper")
|
||||
}
|
||||
if(_PROJECT_NAME!="pychangelogfactory") {
|
||||
sh(". ~/TOOLS_ENV/bin/activate && pip install pychangelogfactory")
|
||||
}
|
||||
}
|
||||
sh("git config --global user.email $_MaintainerEmail")
|
||||
sh("git config --global user.name $_MaintainerName")
|
||||
sh("git config --global init.defaultBranch master")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
stage("GetCode") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
// manually checkout the repository, with All branches and tags
|
||||
// => because we might need them for version and changelog computing
|
||||
checkout([ $class: "GitSCM",
|
||||
branches: [[name: GIT_BRANCH]],
|
||||
extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']],
|
||||
userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]])
|
||||
script {
|
||||
|
||||
withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||
sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git")
|
||||
}
|
||||
|
||||
CHANGELOG = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|import re
|
||||
|
|
||||
|try:
|
||||
| from pychangelogfactory import ChangelogFactory
|
||||
|except ImportError:
|
||||
| from src.pychangelogfactory import ChangelogFactory
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|
|
||||
|LastTag=gitversionhelper.tag.getLastTag(same_branch=True)
|
||||
|CommitHistory=gitversionhelper.commit.getMessagesSinceTag(LastTag, merged_output=True, ignore_merged=True)
|
||||
|Changelog = ChangelogFactory(CommitHistory).RenderFullChangelog(include_unknown=True)
|
||||
|print(Changelog.replace("\\n","\\n\\n"))
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true).trim()
|
||||
|
||||
if(_GIT_BRANCH=="master") {
|
||||
if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty()) {
|
||||
|
||||
BUMPED_VERSION = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|import re
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|lastcommit=gitversionhelper.commit.getLast(same_branch=True)
|
||||
|msg=gitversionhelper.commit.getMessage(lastcommit)
|
||||
|
|
||||
|_match=re.search(r"\\s*(?:#)?\\s*(?<=new-tag:)(?:\\s*)(?P<TAG>\\S*)",msg)
|
||||
|print(_match.group("TAG"),end="")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true).trim()
|
||||
|
||||
if(BUMPED_VERSION.isEmpty()) {
|
||||
echo "master push/merge must have an explicit tag release number, stopping pipeline"
|
||||
currentBuild.getRawBuild().getExecutor().doStop()
|
||||
}
|
||||
else {
|
||||
echo "new-tag requested in commit message: $BUMPED_VERSION"
|
||||
|
||||
sh("git tag $BUMPED_VERSION")
|
||||
sh("git push origin --tags")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
latestTag = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|try:
|
||||
| from pygitversionhelper import gitversionhelper
|
||||
|except ImportError:
|
||||
| from src.pygitversionhelper import gitversionhelper
|
||||
|
|
||||
|print(gitversionhelper.tag.getLastTag(same_branch=True),end ="")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true)
|
||||
echo("latestTag:. . . . . . . . . . . . $latestTag ")
|
||||
|
||||
// get current (or bumped) version number from git history
|
||||
PY_PROJECT_VERSION = sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|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 ="")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true)
|
||||
echo("PY_PROJECT_VERSION: . . . . . . . . . $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
|
||||
// => 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
|
||||
sh("rm -Rf ~/_gitrepo || true")
|
||||
|
||||
sh(script: """#!/bin/sh -
|
||||
|. ~/BUILD_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|import dunamai
|
||||
|
|
||||
|# override default dunamai version pattern to make leading 'v' optionnal
|
||||
|dunamai.VERSION_SOURCE_PATTERN = r'''
|
||||
| (?x) (?# ignore whitespace)
|
||||
| ^v?((?P<epoch>\\d+)!)?(?P<base>\\d+(\\.\\d+)*) (?# v1.2.3 or v1!2000.1.2)
|
||||
| ([-._]?((?P<stage>[a-zA-Z]+)[-._]?(?P<revision>\\d+)?))? (?# b0)
|
||||
| (\\+(?P<tagged_metadata>.+))?\$ (?# +linux)
|
||||
|'''.strip()
|
||||
|
|
||||
|import copier
|
||||
|copier.run_copy("./", "../_gitrepo",vcs_ref="HEAD",use_prereleases=True,defaults=True,cleanup_on_error=False,unsafe=True)
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin())
|
||||
|
||||
// we can not remove the directory because Jenkins is inside...
|
||||
// => so we painfully remove the inside stuff
|
||||
sh("find ~/gitrepo/ -mindepth 1 -type f -exec rm {} \\;")
|
||||
sh("find ~/gitrepo/ -mindepth 1 -type d -empty -delete")
|
||||
|
||||
sh("cp -a ~/_gitrepo/. ~/gitrepo")
|
||||
sh("git init")
|
||||
sh("git add .")
|
||||
sh("git commit -m \"init repo\"")
|
||||
sh("git tag ${PY_PROJECT_VERSION}")
|
||||
}
|
||||
|
||||
|
||||
PY_PROJECT_NAME = sh(script: """#!/bin/sh -
|
||||
|. ~/BUILD_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|import toml
|
||||
|
|
||||
|with open("pyproject.toml") as pyproject:
|
||||
| pyproject_data = toml.load(pyproject)
|
||||
| print(pyproject_data["project"]["name"], end ="")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".stripMargin(),
|
||||
returnStdout: true)
|
||||
|
||||
echo("PY_PROJECT_NAME: . . . . . . . . . $PY_PROJECT_NAME")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("BuildPackage") {
|
||||
steps {
|
||||
// no need for a build-env: setuptools is already creating one
|
||||
dir("gitrepo") {
|
||||
script {
|
||||
// actually doing the package build
|
||||
sh(". ~/BUILD_ENV/bin/activate && python -m build .")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Install") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
script {
|
||||
// searching for the built package
|
||||
def wheelPath = findFiles(glob: "**/dist/*.whl")[0]
|
||||
echo "wheel artifact path: $wheelPath"
|
||||
// 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,complexity-check]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("CheckCode") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
sh(". ~/TEST_ENV/bin/activate && python -m chacha_cicd_helper --typecheck --qualitycheck")
|
||||
script {
|
||||
def jsonObj = readJSON file: "helpers-results/cl_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 chacha_cicd_helper --complexitycheck")
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
dir("gitrepo") {
|
||||
publishCoverage adapters: [cobertura(mergeToOneReport: true, path: "helpers-results/cl_types_check/cobertura.xml")]
|
||||
junit 'helpers-results/cl_types_check/junit.xml'
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/cl_quality_check",
|
||||
reportFiles: "report.html",
|
||||
reportName: "quality-report",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/cl_types_check",
|
||||
reportFiles: "index.html",
|
||||
reportName: "types_check",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("PlotMetrics") {
|
||||
steps {
|
||||
|
||||
plot([ csvFileName: 'plot-df7f03dc-8146-11ed-a1eb-0242ac120002.csv',
|
||||
csvSeries: [[ file: 'gitrepo/helpers-results/cl_quality_check/metrics_GlobalScore.csv', inclusionFlag: 'OFF', url: '']],
|
||||
group: 'metrics',
|
||||
title: 'code quality score',
|
||||
style: 'line',
|
||||
keepRecords: true,
|
||||
numBuilds: '',
|
||||
yaxisMaximum: '10',
|
||||
yaxisMinimum: '0'])
|
||||
|
||||
plot([ csvFileName: 'plot-c731cc84-8145-11ed-a1eb-0242ac120002.csv',
|
||||
csvSeries: [[ file: 'gitrepo/helpers-results/cl_quality_check/metrics_rawpercent.csv', inclusionFlag: 'OFF', url: '']],
|
||||
group: 'metrics',
|
||||
title: 'code composition (%)',
|
||||
style: 'stackedArea',
|
||||
keepRecords: true,
|
||||
numBuilds: '',
|
||||
yaxisMaximum: '1',
|
||||
yaxisMinimum: '0'])
|
||||
|
||||
plot([ csvFileName: 'plot-cac33982-8145-11ed-a1eb-0242ac120002.csv',
|
||||
csvSeries: [[ file: 'gitrepo/helpers-results/cl_quality_check/metrics_Statistics.csv', inclusionFlag: 'OFF', url: '']],
|
||||
group: 'metrics',
|
||||
title: 'general statistics',
|
||||
style: 'line',
|
||||
keepRecords: true,
|
||||
numBuilds: ''])
|
||||
|
||||
plot([ csvFileName: 'plot-cddaced2-8145-11ed-a1eb-0242ac120002.csv',
|
||||
csvSeries: [[ file: 'gitrepo/helpers-results/cl_quality_check/metrics_MessagesCat.csv', inclusionFlag: 'OFF', url: '']],
|
||||
group: 'metrics',
|
||||
title: 'quality warnings',
|
||||
style: 'stackedArea',
|
||||
keepRecords: true,
|
||||
numBuilds: ''])
|
||||
|
||||
plot([ csvFileName: 'plot-4ceb9ee2-ca78-11ed-afa1-0242ac120002.csv',
|
||||
csvSeries: [[ file: 'gitrepo/helpers-results/cl_complexity_check/MI.csv', inclusionFlag: 'INCLUDE_BY_STRING',exclusionValues: 'MeanMaintainability', url: '']],
|
||||
group: 'metrics',
|
||||
title: 'maintainability',
|
||||
style: 'stackedArea',
|
||||
keepRecords: true,
|
||||
numBuilds: ''])
|
||||
}
|
||||
}
|
||||
|
||||
stage("RunUnitTests") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
sh(". ~/TEST_ENV/bin/activate && python -m chacha_cicd_helper --unittest --coveragecheck")
|
||||
script {
|
||||
unit_test_full_name__html=findFiles(glob: "helpers-results/cl_unit_test_full/*.html")[0].getName()
|
||||
println unit_test_full_name__html
|
||||
unit_test_full_name__xml=findFiles(glob: "helpers-results/cl_unit_test_full/*.xml")[0].getName()
|
||||
println unit_test_full_name__xml
|
||||
|
||||
coverage_report_path = "helpers-results/cl_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/cl_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")}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
dir("gitrepo") {
|
||||
junit 'helpers-results/cl_unit_test/*.xml'
|
||||
// using cobertura format (= coverage xml format)
|
||||
publishCoverage adapters: [cobertura(mergeToOneReport: true, path: "helpers-results/cl_unit_test_coverage/test_coverage.xml")]
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/cl_unit_test_coverage",
|
||||
reportFiles: "index.html",
|
||||
reportName: "coverage-report-html",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/cl_unit_test_full",
|
||||
reportFiles: unit_test_full_name__html,
|
||||
reportName: "test-reports-full",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("GenDOC") {
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
sh(". ~/TEST_ENV/bin/activate && python -m chacha_cicd_helper --docgen --docgenpdf")
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
dir("gitrepo") {
|
||||
publishHTML([
|
||||
reportDir: "helpers-results/cl_doc_gen/site",
|
||||
reportFiles: "index.html",
|
||||
reportName: "doc-html",
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("PostRelease") {
|
||||
environment {
|
||||
def GITEA_LOGIN_TOKEN=credentials("GiteaCHACHAPush")
|
||||
}
|
||||
steps {
|
||||
dir("gitrepo") {
|
||||
script {
|
||||
def CurrentDateTime=java.time.LocalDateTime.now()
|
||||
withCredentials([string( credentialsId: _MkDocsWebCredentials,variable: 'MKDOCSTOKEN' )]) {
|
||||
sh(script: """#!/bin/sh -
|
||||
|. ~/TOOLS_ENV/bin/activate
|
||||
|exec python - << '__EOWRAPPER__'
|
||||
|
|
||||
|import json
|
||||
|import glob
|
||||
|import requests
|
||||
|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
|
||||
|
|
||||
|class GiteaRepoCommits(Resource):
|
||||
| actions = {
|
||||
| 'get': {'method': 'GET', 'url': '/repos/{}/{}//git/commits/{}'},
|
||||
|}
|
||||
|
|
||||
|class GiteaRepoReleases(Resource):
|
||||
| actions = {
|
||||
| 'get': {'method': 'GET', 'url': '/repos/{}/{}/releases'},
|
||||
| 'post': {'method': 'POST', 'url': '/repos/{}/{}/releases'},
|
||||
|}
|
||||
|
|
||||
|class GiteaRepoReleaseAssets(Resource):
|
||||
| actions = {
|
||||
| 'get': {'method': 'GET', 'url': '/repos/{}/{}/releases/{}/assets'},
|
||||
| 'post': {'method': 'POST', 'url': '/repos/{}/{}/releases/{}/assets'},
|
||||
|}
|
||||
|
|
||||
|class GiteaRepoReleaseAssetAttachments(Resource):
|
||||
| actions = {
|
||||
| 'get': {'method': 'GET', 'url': '/repos/{}/{}/releases/{}/assets/{}'},
|
||||
|}
|
||||
|
|
||||
|class _GiteaApi(API):
|
||||
| def __init__(self,**args):
|
||||
| super().__init__(**args)
|
||||
| self.add_resource(resource_name="commits", resource_class = GiteaRepoCommits)
|
||||
| self.add_resource(resource_name="releases", resource_class = GiteaRepoReleases)
|
||||
| self.add_resource(resource_name="assets", resource_class = GiteaRepoReleaseAssets)
|
||||
| self.add_resource(resource_name="attachments", resource_class = GiteaRepoReleaseAssetAttachments)
|
||||
|
|
||||
|GiteaApi = _GiteaApi(
|
||||
| api_root_url=urljoin('${_GITEA_BASE_URL}','api/v1/'),
|
||||
| headers={"Authorization":"token ${GITEA_LOGIN_TOKEN_PSW}"},
|
||||
|)
|
||||
|
|
||||
|
|
||||
|ReleaseContent = "${_ReleaseContent_Title}" + "\\n" \\
|
||||
| + "\\n" \\
|
||||
| + "Reference documentation: [mkdocs page](https://chacha.ddns.net/mkdocs-web/${_PROJECT_USER_NAME}/${PY_PROJECT_NAME}/${_GIT_BRANCH}/${PY_PROJECT_VERSION_STRIPPED}/) "
|
||||
|
|
||||
|Changelog='''${CHANGELOG}'''
|
||||
|
|
||||
|ReleaseContent = ReleaseContent + "\\n"+ "\\n"+ "## Changelog:\\n" + Changelog
|
||||
|
|
||||
|if not Changelog:
|
||||
| ReleaseContent = ReleaseContent + "code/project maintainance"
|
||||
|
|
||||
|data={
|
||||
| "body": ReleaseContent,
|
||||
| "draft": bool("${_bDraft}"=="true"),
|
||||
| "name": "${PY_PROJECT_NAME}_${CurrentDateTime}",
|
||||
| "prerelease": bool("${_bPreRelease}"=="true"),
|
||||
| "tag_name": "${PY_PROJECT_VERSION}",
|
||||
| "target_commitish": "${GIT_COMMIT}",
|
||||
|}
|
||||
|new_release_id = GiteaApi.releases.post("${_PROJECT_USER_NAME}","${PY_PROJECT_NAME}",json=data).body['id']
|
||||
|
|
||||
|data = {
|
||||
| "name": "Wheel Package",
|
||||
| 'attachment': (glob.glob('dist/*.whl')[0], open(glob.glob('dist/*.whl')[0], 'rb')),
|
||||
|}
|
||||
|GiteaApi.assets.post("${_PROJECT_USER_NAME}","${PY_PROJECT_NAME}",new_release_id,files=data)
|
||||
|
|
||||
|data = {
|
||||
| "name": "Documentation (pdf)",
|
||||
| 'attachment': ("${PY_PROJECT_NAME}_${PY_PROJECT_VERSION}_UserManual.pdf", open("helpers-results/cl_doc_gen/site/pdf/manual.pdf", 'rb')),
|
||||
|}
|
||||
|GiteaApi.assets.post("${_PROJECT_USER_NAME}","${PY_PROJECT_NAME}",new_release_id,files=data)
|
||||
|
|
||||
|shutil.make_archive("doc", 'zip', "helpers-results/cl_doc_gen/site")
|
||||
|reqData={
|
||||
| "SECRET": "${MKDOCSTOKEN}",
|
||||
| "USER": "${_PROJECT_USER_NAME}",
|
||||
| "PACKAGE": "${PY_PROJECT_NAME}",
|
||||
| "BRANCH": "${_GIT_BRANCH}",
|
||||
| "VERSION": "${PY_PROJECT_VERSION}",
|
||||
|}
|
||||
|files = {'DATA': open('doc.zip','rb')}
|
||||
|response=requests.post("http://${_MkDocsWebURL}/API.php?REQ=pushDoc",data=reqData,files=files)
|
||||
|if response.status_code != 200:
|
||||
| raise RuntimeError(f"Wrong server response: {response.status_code}")
|
||||
|
|
||||
|__EOWRAPPER__
|
||||
""".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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
failure {
|
||||
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
|
||||
to: _MaintainerEmail,
|
||||
subject: 'Build failed in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
|
||||
}
|
||||
unstable {
|
||||
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
|
||||
to: _MaintainerEmail,
|
||||
subject: 'Unstable build in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
|
||||
}
|
||||
changed {
|
||||
emailext body: 'Check console output at $BUILD_URL to view the results.',
|
||||
to: _MaintainerEmail,
|
||||
subject: 'Jenkins build is back to normal: $PROJECT_NAME - #$BUILD_NUMBER'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
175
LICENSE.md
Normal file
175
LICENSE.md
Normal file
@@ -0,0 +1,175 @@
|
||||
# License
|
||||
|
||||
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
**Using Creative Commons Public Licenses**
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
|
||||
|
||||
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
|
||||
|
||||
## Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
### Section 1 – Definitions.
|
||||
|
||||
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. __BY-NC-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
|
||||
|
||||
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
k. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
|
||||
l. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
m. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
n. __You__ means the individual or entity exercising the Licensed Rights under this Public License. __Your__ has a corresponding meaning.
|
||||
|
||||
### Section 2 – Scope.
|
||||
|
||||
a. ___License grant.___
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
||||
|
||||
B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
|
||||
|
||||
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. __Term.__ The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. __Downstream recipients.__
|
||||
|
||||
A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
|
||||
C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. ___Other rights.___
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
||||
|
||||
### Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. ___Attribution.___
|
||||
|
||||
1. If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
b. ___ShareAlike.___
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
|
||||
### Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
### Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
|
||||
|
||||
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
### Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
### Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
### Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
>
|
||||
> Creative Commons may be contacted at creativecommons.org
|
||||
53
README.md
Normal file
53
README.md
Normal file
@@ -0,0 +1,53 @@
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
# Python project template
|
||||
|
||||
A nice template to start blank python projets.
|
||||
|
||||
This template automate a lot of handy things and allow CI/CD automatic releases generation.
|
||||
|
||||
It is also collectings data to feed Jenkins build.
|
||||
|
||||
Checkout [Latest Documentation](https://chacha.ddns.net/mkdocs-web/chacha/{{repository}}/{{branch}}/latest/).
|
||||
|
||||
## Features
|
||||
|
||||
### Generic pipeline skeleton:
|
||||
- Prepare
|
||||
- GetCode
|
||||
- BuildPackage
|
||||
- Install
|
||||
- CheckCode
|
||||
- PlotMetrics
|
||||
- RunUnitTests
|
||||
- GenDOC
|
||||
- PostRelease
|
||||
|
||||
### CI/CD Environment
|
||||
- Jenkins
|
||||
- Gitea (with patch for dynamic Readme variables: https://chacha.ddns.net/gitea/chacha/GiteaMarkupVariable)
|
||||
- Docker
|
||||
- MkDocsWeb
|
||||
|
||||
### CI/CD Helper libs
|
||||
- VirtualEnv
|
||||
- Changelog generation based on commits
|
||||
- copier
|
||||
- pylint + pylint_json2html
|
||||
- mypy
|
||||
- unittest + xmlrunner + junitparser + junit2htmlreport
|
||||
- mkdocs
|
||||
|
||||
### Python project
|
||||
- Full .toml implementation
|
||||
- .whl automatic generation
|
||||
- dynamic versionning using git repository
|
||||
- embedded unit-test
|
||||
17
RUN_complexity.launch
Normal file
17
RUN_complexity.launch
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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="/pyrestresource/helpers_proxy"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="2"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:pyrestresource/helpers_proxy}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--complexitycheck"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pyrestresource"/>
|
||||
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
17
RUN_mkdocs.launch
Normal file
17
RUN_mkdocs.launch
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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="/pyrestresource/helpers_proxy"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="2"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:pyrestresource/helpers_proxy}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--docgen --docgenpdf"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pyrestresource"/>
|
||||
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
17
RUN_quality.launch
Normal file
17
RUN_quality.launch
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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="/pyrestresource/helpers_proxy"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="2"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:pyrestresource/helpers_proxy}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--typecheck --qualitycheck"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pyrestresource"/>
|
||||
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
17
RUN_unittest.launch
Normal file
17
RUN_unittest.launch
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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="/pyrestresource/helpers_proxy"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="2"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:pyrestresource/helpers_proxy}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--unittest --coveragecheck"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
|
||||
<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="pyrestresource"/>
|
||||
<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
BIN
docs-static/Library.jpg
Normal file
BIN
docs-static/Library.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
16
docs-static/usage.md
Normal file
16
docs-static/usage.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Usage
|
||||
|
||||
## Pulvinar dolor
|
||||
Donec dapibus est fermentum justo volutpat condimentum. Integer quis nunc neque. Donec dictum vehicula justo, in facilisis ex tincidunt in.
|
||||
Vivamus sollicitudin sem dui, id mollis orci facilisis ut. Proin sed pulvinar dolor. Donec volutpat commodo urna imperdiet pulvinar. Fusce eget aliquam risus.
|
||||
Vivamus viverra luctus ex, in finibus mi. Nullam elementum dapibus mollis. Ut suscipit volutpat ex, quis feugiat lacus consectetur eu.
|
||||
|
||||
## Condimentum faucibus
|
||||
Quisque auctor egestas sem, luctus suscipit ex maximus vitae. Duis facilisis augue et condimentum faucibus.
|
||||
Donec cursus, enim a sagittis egestas, lectus lorem eleifend libero, at tincidunt leo magna at libero.
|
||||
Nunc eros velit, suscipit luctus tempor vel, finibus et est. Curabitur efficitur pretium pulvinar.
|
||||
Donec urna lectus, vulputate quis turpis sed, placerat congue urna. Phasellus aliquet fermentum quam, non auctor elit porta nec. Morbi eu ligula at nisl ultricies condimentum vitae id ante.
|
||||
|
||||
## Aliquam lacinia
|
||||
In volutpat lorem ex, et fringilla nibh faucibus quis. Mauris et arcu elementum, auctor dui vitae, egestas arcu. Duis sit amet aliquam quam.
|
||||
Phasellus a odio turpis. Etiam tristique mi eu enim varius, eget facilisis est vestibulum. Aliquam lacinia nec purus sed luctus. Cras at laoreet erat.
|
||||
5
helpers_proxy/__main__.py
Normal file
5
helpers_proxy/__main__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from chacha_cicd_helper.__main__ import fct_main
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
fct_main(sys.argv[1:])
|
||||
112
mkdocs.yml
Normal file
112
mkdocs.yml
Normal file
@@ -0,0 +1,112 @@
|
||||
docs_dir: docs
|
||||
site_name: 'pyrestresource'
|
||||
site_url: 'https://chacha.ddns.net/mkdocs-web/chacha/pyrestresource/latest/'
|
||||
site_description: 'pyrestresource'
|
||||
site_author: 'chacha'
|
||||
repo_url: 'https://chacha.ddns.net/gitea/chacha/pyrestresource'
|
||||
use_directory_urls: false
|
||||
copyright: 'CC BY-NC-SA 4.0'
|
||||
theme:
|
||||
name: material
|
||||
features:
|
||||
- navigation.instant
|
||||
- navigation.tracking
|
||||
- navigation.tabs
|
||||
- navigation.tabs.sticky
|
||||
- navigation.footer
|
||||
- navigation.path
|
||||
- navigation.top
|
||||
- navigation.section
|
||||
- content.code.annotate
|
||||
- navigation.expand
|
||||
- toc.follow
|
||||
palette:
|
||||
- media: '(prefers-color-scheme: dark)'
|
||||
scheme: slate
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to system preference
|
||||
- media: (prefers-color-scheme)
|
||||
toggle:
|
||||
icon: material/brightness-auto
|
||||
name: Switch to light mode
|
||||
- media: '(prefers-color-scheme: light)'
|
||||
scheme: default
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Switch to dark mode
|
||||
plugins:
|
||||
- search
|
||||
- markdownextradata
|
||||
- mermaid2
|
||||
- localsearch
|
||||
- mkdocstrings:
|
||||
default_handler: python
|
||||
handlers:
|
||||
python:
|
||||
options:
|
||||
filters:
|
||||
- '!^_[^_]'
|
||||
inherited_members: false
|
||||
show_if_no_docstring: true
|
||||
show_signature_annotations: true
|
||||
show_source: false
|
||||
show_category_heading: true
|
||||
group_by_category: true
|
||||
show_root_full_path: false
|
||||
merge_init_into_class: true
|
||||
separate_signature: true
|
||||
heading_level: 2
|
||||
docstring_section_style: spacy
|
||||
show_root_toc_entry: false
|
||||
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: pyrestresource
|
||||
67
pyproject.toml
Normal file
67
pyproject.toml
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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/>.
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=63", "wheel", "setuptools_scm"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools_scm]
|
||||
version_scheme= "post-release"
|
||||
|
||||
[project]
|
||||
name = "pyrestresource"
|
||||
description = "pyrestresource"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
keywords = ["chacha","chacha","template","pyrestresource"]
|
||||
license = { file = "LICENSE.md" }
|
||||
|
||||
authors = [
|
||||
{name="chacha",email="1000CHACHA0001@gmail.com"},
|
||||
]
|
||||
maintainers = [
|
||||
{name="chacha",email="1000CHACHA0001@gmail.com"},
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
]
|
||||
dependencies = [
|
||||
'importlib-metadata; python_version<"3.9"',
|
||||
'packaging'
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[tool.setuptools]
|
||||
platforms = ["any"]
|
||||
include-package-data = true
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"pyrestresource.data" = ["*.*"]
|
||||
"pyrestresource" = ["py.typed"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://chacha.ddns.net/gitea/chacha/pyrestresource"
|
||||
Documentation = "https://chacha.ddns.net/mkdocs-web/chacha/pyrestresource/master/latest/"
|
||||
Tracker = "https://chacha.ddns.net/gitea/chacha/pyrestresource/issues"
|
||||
|
||||
[project.optional-dependencies]
|
||||
test = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
coverage-check = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
complexity-check = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
quality-check = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
type-check = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
doc-gen = ["chacha_cicd_helper@git+https://chacha.ddns.net/gitea/chacha/chacha_cicd_helper.git@master"]
|
||||
|
||||
# [project.scripts]
|
||||
# my-script = "my_package.module:function"
|
||||
|
||||
36
src/pyrestresource/__init__.py
Normal file
36
src/pyrestresource/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# pyrestresource (c) by chacha
|
||||
#
|
||||
# pyrestresource 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/>.
|
||||
|
||||
"""
|
||||
Main module __init__ file.
|
||||
"""
|
||||
|
||||
from importlib.metadata import version, distribution, PackageNotFoundError
|
||||
import warnings
|
||||
|
||||
from .test_module import test_function
|
||||
|
||||
try: # pragma: no cover
|
||||
__version__ = version("pyrestresource")
|
||||
except PackageNotFoundError: # pragma: no cover
|
||||
warnings.warn("can not read __version__, assuming local test context, setting it to ?.?.?")
|
||||
__version__ = "?.?.?"
|
||||
|
||||
try: # pragma: no cover
|
||||
dist = distribution("pyrestresource")
|
||||
__Summuary__ = dist.metadata["Summary"]
|
||||
except PackageNotFoundError: # pragma: no cover
|
||||
warnings.warn('can not read dist.metadata["Summary"], assuming local test context, setting it to <pyrestresource description>')
|
||||
__Summuary__ = "pyrestresource description"
|
||||
|
||||
try: # pragma: no cover
|
||||
dist = distribution("pyrestresource")
|
||||
__Name__ = dist.metadata["Name"]
|
||||
except PackageNotFoundError: # pragma: no cover
|
||||
warnings.warn('can not read dist.metadata["Name"], assuming local test context, setting it to <pyrestresource>')
|
||||
__Name__ = "pyrestresource"
|
||||
0
src/pyrestresource/data/.keep
Normal file
0
src/pyrestresource/data/.keep
Normal file
7
src/pyrestresource/data/__init__.py
Normal file
7
src/pyrestresource/data/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# pyrestresource (c) by chacha
|
||||
#
|
||||
# pyrestresource 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/>.
|
||||
1
src/pyrestresource/py.typed
Normal file
1
src/pyrestresource/py.typed
Normal file
@@ -0,0 +1 @@
|
||||
# PlaceHolder
|
||||
43
src/pyrestresource/test_module.py
Normal file
43
src/pyrestresource/test_module.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# pyrestresource (c) by chacha
|
||||
#
|
||||
# pyrestresource 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/>.
|
||||
|
||||
"""Phasellus tellus lectus, volutpat eu dapibus ut, suscipit vel augue.
|
||||
|
||||
Tips:
|
||||
Aliquam non leo vel libero sagittis viverra. Quisque lobortis nunc sit amet augue euismod laoreet.
|
||||
Note:
|
||||
Maecenas volutpat porttitor pretium. Aliquam suscipit quis nisi non imperdiet.
|
||||
Note:
|
||||
Vivamus et efficitur lorem, eget imperdiet tortor. Integer vel interdum sem.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING: # Only imports the below statements during type checking
|
||||
pass
|
||||
|
||||
def test_function(testvar: int) -> int:
|
||||
""" A test function that return testvar+1 and print "Hello world !"
|
||||
|
||||
Proin eget sapien eget ipsum efficitur mollis nec ac nibh.
|
||||
|
||||
Note:
|
||||
Morbi id lectus maximus, condimentum nunc eget, porta felis. In tristique velit tortor.
|
||||
|
||||
Args:
|
||||
testvar: any integer
|
||||
|
||||
Returns:
|
||||
testvar+1
|
||||
"""
|
||||
print("Hello world !")
|
||||
return testvar+1
|
||||
7
test/__init__.py
Normal file
7
test/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# pyrestresource (c) by chacha
|
||||
#
|
||||
# pyrestresource 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/>.
|
||||
35
test/test_test_module.py
Normal file
35
test/test_test_module.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# pyrestresource (c) by chacha
|
||||
#
|
||||
# pyrestresource 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/>.
|
||||
|
||||
import unittest
|
||||
from os import chdir
|
||||
from io import StringIO
|
||||
from contextlib import redirect_stdout,redirect_stderr
|
||||
from pathlib import Path
|
||||
|
||||
print(__name__)
|
||||
print(__package__)
|
||||
|
||||
from src import pyrestresource
|
||||
|
||||
testdir_path = Path(__file__).parent.resolve()
|
||||
chdir(testdir_path.parent.resolve())
|
||||
|
||||
class Testtest_module(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
chdir(testdir_path.parent.resolve())
|
||||
|
||||
def test_version(self):
|
||||
self.assertNotEqual(pyrestresource.__version__,"?.?.?")
|
||||
|
||||
def test_test_module(self):
|
||||
|
||||
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
|
||||
self.assertEqual(pyrestresource.test_function(41),42)
|
||||
self.assertEqual(len(capted_stderr.getvalue()),0)
|
||||
self.assertEqual(capted_stdout.getvalue().strip(),"Hello world !")
|
||||
Reference in New Issue
Block a user