diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 7145c1e..10059db 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -36,7 +36,7 @@ jobs: python3 -m pip install -r requirement-uv.txt uv sync --frozen --no-install-project export PYTHONPATH=$(pwd) - uv run scripts/run_tests.py + uv run scripts/common/py/run_tests.py uv run scripts/multi_build.py - name: Publish Artifacts uses: actions/upload-artifact@v3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 034dcef..df7c8e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ job-build: - python3 -m pip install -r requirement-uv.txt --break-system-packages - uv sync --frozen --no-install-project - export PYTHONPATH=$(pwd) - - uv run scripts/run_tests.py + - uv run scripts/common/py/run_tests.py - uv run scripts/multi_build.py artifacts: paths: diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..52289d9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "scripts/common"] + path = scripts/common + url = git@github.com:seppzer0/scripts diff --git a/scripts/common b/scripts/common new file mode 160000 index 0000000..783f5b0 --- /dev/null +++ b/scripts/common @@ -0,0 +1 @@ +Subproject commit 783f5b0166891973497b1cd03652fd0e72284c2f diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py deleted file mode 100644 index 819911e..0000000 --- a/scripts/generate_docs.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -Script to generate class diagrams of all packages in plantuml (.puml) format. -""" - -import os -import shutil -import subprocess -from pathlib import Path - -ROOTPATH: Path = Path(__file__).absolute().parents[1] -DOCSPATH: Path = ROOTPATH / "docs" / "architecture" -APPPATH: Path = ROOTPATH / "builder" - - -def run_cmd(cmd: str) -> subprocess.CompletedProcess: - """Launch the specified command in specific wrapping.""" - return subprocess.run(cmd, shell=True, check=True) - - -def clean_dir() -> None: - """Create a clean docs directory.""" - shutil.rmtree(DOCSPATH, ignore_errors=True) - os.makedirs(DOCSPATH) - - -def generate_docs() -> None: - """Generate .puml files.""" - for elem in os.listdir(APPPATH): - full_path = APPPATH / elem - if full_path.is_dir() and "__init__.py" in os.listdir(full_path): - package_docs_path = DOCSPATH / elem - os.makedirs(package_docs_path, exist_ok=True) - run_cmd(f"pyreverse {APPPATH / elem} -o puml -d {package_docs_path}") - # edit "class" into "interface" for interfaces - if elem == "interfaces": - data = "" - with open(package_docs_path / "classes.puml", "r") as f: - data = f.read() - data = data.replace("class ", "interface ") - with open(package_docs_path / "classes.puml", "w") as f: - f.write(data) - - -def main() -> None: - clean_dir() - generate_docs() - - -if __name__ == "__main__": - main() diff --git a/scripts/get_version.py b/scripts/get_version.py deleted file mode 100644 index eadc180..0000000 --- a/scripts/get_version.py +++ /dev/null @@ -1,11 +0,0 @@ -from pathlib import Path - - -def main() -> None: - rootpath = Path(__file__).absolute().parents[1] - with open(rootpath / "pyproject.toml", encoding="utf-8") as f: - print(f.read().split('version = "')[1].split('"')[0]) - - -if __name__ == "__main__": - main() diff --git a/scripts/get_version.sh b/scripts/get_version.sh deleted file mode 100644 index cdceeb3..0000000 --- a/scripts/get_version.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# -# This is an SH version of get_version.py, usually used for cases when Python interpreter is unavailable. -# - -cat $(dirname $(realpath "$0"))/../pyproject.toml | grep "version = " | cut -d'"' -f 2 diff --git a/scripts/run_tests.py b/scripts/run_tests.py deleted file mode 100644 index 3af5aea..0000000 --- a/scripts/run_tests.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import subprocess -from pathlib import Path -from subprocess import CompletedProcess - -ROOTPATH: Path = Path(__file__).absolute().parents[1] - - -class Tester: - """Single class for all types of tests.""" - - @staticmethod - def _launch_cmd(cmd: str) -> CompletedProcess: - """Launch specified command.""" - return subprocess.run(cmd, shell=True, check=True) - - def pyright_check(self) -> None: - """Run typing checks with Pyright.""" - print("\n=== Pyright checks: Start ===") - self._launch_cmd("uv run python -m pyright") - print("=== Pyright checks: Finish ===") - - def pytest_check(self) -> None: - """Run unit tests with Pytest and coverage checks.""" - os.environ["PYTHONPATH"] = str(ROOTPATH) - print("\n=== Pytest checks: Start ===") - self._launch_cmd("uv run python -m pytest -vv tests/ --cov") - print("=== Pytest checks: Finish ===") - - def bandit_check(self) -> None: - """Run SAST with Bandit.""" - fmts = ("json", "html") - for fmt in fmts: - self._launch_cmd(f"uv run python -m bandit -r -f {fmt} {ROOTPATH} -o report.{fmt}") - - -def main() -> None: - os.chdir(ROOTPATH) - t = Tester() - t.pyright_check() - t.pytest_check() - #t.bandit_check() - - -if __name__ == "__main__": - main() diff --git a/uv.lock b/uv.lock index 16f962a..42b9b92 100644 --- a/uv.lock +++ b/uv.lock @@ -189,11 +189,11 @@ wheels = [ [[package]] name = "idna" -version = "3.8" +version = "3.9" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/e8/ac/e349c5e6d4543326c6883ee9491e3921e0d07b55fdf3cce184b40d63e72a/idna-3.8.tar.gz", hash = "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603", size = 189467 } +sdist = { url = "https://files.pythonhosted.org/packages/00/6f/93e724eafe34e860d15d37a4f72a1511dd37c43a76a8671b22a15029d545/idna-3.9.tar.gz", hash = "sha256:e5c5dafde284f26e9e0f28f6ea2d6400abd5ca099864a67f576f3981c6476124", size = 191636 } wheels = [ - { url = "https://files.pythonhosted.org/packages/22/7e/d71db821f177828df9dea8c42ac46473366f191be53080e552e628aad991/idna-3.8-py3-none-any.whl", hash = "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac", size = 66894 }, + { url = "https://files.pythonhosted.org/packages/6d/15/61933d1999bc5ad8cad612d67f02fa5b16a423076ea0816e39c2e797af12/idna-3.9-py3-none-any.whl", hash = "sha256:69297d5da0cc9281c77efffb4e730254dd45943f45bbfb461de5991713989b1e", size = 71671 }, ] [[package]] @@ -327,11 +327,11 @@ wheels = [ [[package]] name = "platformdirs" -version = "4.3.2" +version = "4.3.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/75/a0/d7cab8409cdc7d39b037c85ac46d92434fb6595432e069251b38e5c8dd0e/platformdirs-4.3.2.tar.gz", hash = "sha256:9e5e27a08aa095dd127b9f2e764d74254f482fef22b0970773bfba79d091ab8c", size = 21276 } +sdist = { url = "https://files.pythonhosted.org/packages/f5/19/f7bee3a71decedd8d7bc4d3edb7970b8e899f3caef257b0f0d623f2f7b11/platformdirs-4.3.3.tar.gz", hash = "sha256:d4e0b7d8ec176b341fb03cb11ca12d0276faa8c485f9cd218f613840463fc2c0", size = 21304 } wheels = [ - { url = "https://files.pythonhosted.org/packages/da/8b/d497999c4017b80678017ddce745cf675489c110681ad3c84a55eddfd3e7/platformdirs-4.3.2-py3-none-any.whl", hash = "sha256:eb1c8582560b34ed4ba105009a4badf7f6f85768b30126f351328507b2beb617", size = 18417 }, + { url = "https://files.pythonhosted.org/packages/69/e6/7c8e8c326903bd97c6c0c47e0a3c5de815faaae986cab7defdeddf5fddcd/platformdirs-4.3.3-py3-none-any.whl", hash = "sha256:50a5450e2e84f44539718293cbb1da0a0885c9d14adf21b77bae4e66fc99d9b5", size = 18437 }, ] [[package]] @@ -436,14 +436,14 @@ wheels = [ [[package]] name = "pyright" -version = "1.1.379" +version = "1.1.380" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/14/62/fd6f13c417087b8e941c3d7cbc37fcf5ec62b6ae7031837194c0926cb704/pyright-1.1.379.tar.gz", hash = "sha256:6f426cb6443786fa966b930c23ad1941c8cb9fe672e4589daea8d80bb34193ea", size = 17481 } +sdist = { url = "https://files.pythonhosted.org/packages/fa/bc/3bb71d02125dae6730d64bb32571c0eda5e5d86483b198b7f6dd82c49c6f/pyright-1.1.380.tar.gz", hash = "sha256:e6ceb1a5f7e9f03106e0aa1d6fbb4d97735a5e7ffb59f3de6b2db590baf935b2", size = 17487 } wheels = [ - { url = "https://files.pythonhosted.org/packages/1e/4b/98bb2d6eb98ca35fa5fe90d787c3181310ed153c996af3a7f158487b9a87/pyright-1.1.379-py3-none-any.whl", hash = "sha256:01954811ac71db8646f50de1577576dc275ffb891a9e7324350e676cf6df323f", size = 18221 }, + { url = "https://files.pythonhosted.org/packages/c9/fc/527c58a3b66d5a16dbb124e1c40cf9f207147f5a36f224fb29eb786a0763/pyright-1.1.380-py3-none-any.whl", hash = "sha256:a6404392053d8848bacc7aebcbd9d318bb46baf1a1a000359305481920f43879", size = 18219 }, ] [[package]]