From 019dfed113f60e75566e0b228878eaf576b6478c Mon Sep 17 00:00:00 2001 From: cclecle Date: Thu, 28 Sep 2023 00:07:31 +0100 Subject: [PATCH 1/3] try to fix wrong directory --- README.md | 42 ------------------------------ src/chacha_cicd_helper/__main__.py | 7 +++-- test/test_main.py | 7 ++--- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 82c6bd2..47609a0 100644 --- a/README.md +++ b/README.md @@ -8,46 +8,4 @@ ![](docs-static/Library.jpg) -# 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 \ No newline at end of file diff --git a/src/chacha_cicd_helper/__main__.py b/src/chacha_cicd_helper/__main__.py index d1dc30e..c06c0f2 100644 --- a/src/chacha_cicd_helper/__main__.py +++ b/src/chacha_cicd_helper/__main__.py @@ -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) diff --git a/test/test_main.py b/test/test_main.py index 7366247..6ba064b 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -36,9 +36,10 @@ class Test_main(unittest.TestCase): self.assertIn(f"usage: {chacha_cicd_helper.__Name__}", capted_stdout.getvalue()) self.assertEqual(capted_stderr.getvalue(), "") - @unittest.skip + # @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()) -- 2.47.3 From 7f10031e6d3c51ec9d6d5c0686a1624ef335bbdc Mon Sep 17 00:00:00 2001 From: cclecle Date: Thu, 28 Sep 2023 00:18:06 +0100 Subject: [PATCH 2/3] fix project path --- src/chacha_cicd_helper/helper_base.py | 4 +--- test/test_main.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/chacha_cicd_helper/helper_base.py b/src/chacha_cicd_helper/helper_base.py index 02e868a..8c6e29b 100644 --- a/src/chacha_cicd_helper/helper_base.py +++ b/src/chacha_cicd_helper/helper_base.py @@ -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 diff --git a/test/test_main.py b/test/test_main.py index 6ba064b..90a7a1d 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -36,7 +36,7 @@ class Test_main(unittest.TestCase): self.assertIn(f"usage: {chacha_cicd_helper.__Name__}", capted_stdout.getvalue()) self.assertEqual(capted_stderr.getvalue(), "") - # @unittest.skip + @unittest.skip def test_help_print(self): with redirect_stdout(StringIO()) as capted_stdout, redirect_stderr(StringIO()) as capted_stderr: fct_main(["--typecheck"]) -- 2.47.3 From d6622474738d3ca5b114914bed9fc83e7dea7599 Mon Sep 17 00:00:00 2001 From: cclecle Date: Thu, 28 Sep 2023 23:39:09 +0100 Subject: [PATCH 3/3] ignore temp test directory from git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 221ee37..0c22fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,6 @@ docs helpers-results .coverage /.mypy_cache/ +test/tmp .coverage .mypy_cache \ No newline at end of file -- 2.47.3