dev #4
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,5 +41,6 @@ docs
|
||||
helpers-results
|
||||
.coverage
|
||||
/.mypy_cache/
|
||||
test/tmp
|
||||
.coverage
|
||||
.mypy_cache
|
||||
42
README.md
42
README.md
@@ -8,46 +8,4 @@
|
||||
|
||||

|
||||
|
||||
# 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
|
||||
@@ -9,6 +9,7 @@
|
||||
"""Main module"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Union
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
@@ -33,7 +34,7 @@ logging.getLogger().setLevel(logging.INFO)
|
||||
class chacha_cicd_helper_args(Tap):
|
||||
"""class that describe cmd arguments"""
|
||||
|
||||
projectpath: str = os.getcwd()
|
||||
projectpath: Union[str, None] = None
|
||||
typecheck: bool = False
|
||||
unittest: bool = False
|
||||
coveragecheck: bool = False
|
||||
@@ -98,7 +99,9 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-complex
|
||||
if args.complexitycheck is True:
|
||||
helpers.append(cl_complexity_check)
|
||||
|
||||
project_rootdir_path = Path(args.projectpath)
|
||||
project_rootdir_path = Path(os.getcwd()) if args.projectpath is None else Path(args.projectpath)
|
||||
|
||||
print(f"Working directory: {project_rootdir_path}")
|
||||
|
||||
with open(project_rootdir_path / "pyproject.toml", mode="rb") as fp:
|
||||
pyproject = tomli.load(fp)
|
||||
|
||||
@@ -27,14 +27,12 @@ class cl_helper_base(ABC):
|
||||
|
||||
project_rootdir_path: Path = Path()
|
||||
pyproject: dict = {}
|
||||
current_dir: Path = Path()
|
||||
|
||||
@classmethod
|
||||
def set_context(cls, project_rootdir_path: Path, pyproject: dict) -> None:
|
||||
"""method to set contextual fields"""
|
||||
cls.project_rootdir_path = project_rootdir_path
|
||||
cls.pyproject = pyproject
|
||||
cls.current_dir = Path(__file__).parent.absolute()
|
||||
|
||||
@classmethod
|
||||
def get_result_dir(cls) -> Union[None, Path]:
|
||||
@@ -95,4 +93,4 @@ class cl_helper_withresults_base(cl_helper_base):
|
||||
"""retrieve the results directory"""
|
||||
if cls.helper_results_dir is None:
|
||||
cls.helper_results_dir = Path(cls.__name__)
|
||||
return Path(__file__).parent.parent.absolute() / "helpers-results" / cls.helper_results_dir
|
||||
return cls.project_rootdir_path / "helpers-results" / cls.helper_results_dir
|
||||
|
||||
@@ -39,6 +39,7 @@ class Test_main(unittest.TestCase):
|
||||
@unittest.skip
|
||||
def test_help_print(self):
|
||||
with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr:
|
||||
with self.assertRaises(SystemExit):
|
||||
fct_main(["-h", "-pp", str(testdir_path.parent.resolve())])
|
||||
fct_main(["--typecheck"])
|
||||
# fct_main(["-h", "-pp", str(testdir_path.parent.resolve())])
|
||||
print(capted_stdout.getvalue())
|
||||
print(capted_stderr.getvalue())
|
||||
|
||||
Reference in New Issue
Block a user