From e55a7f3ba117f223ffafeaa2eeb4eeca94f880ad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 16:33:07 +0200 Subject: [PATCH 01/16] docstring/util/step --- spcd/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spcd/util.py b/spcd/util.py index a73b251..70bfa0c 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -45,6 +45,7 @@ def split() -> None: def step(text: str) -> None: + """Increment the step number of the current build process.""" env.SPCD_STEP += 1 log.info(env.SPCD_DOWN) log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}") From bf7da671dc93ec5b18e0b8297d136ecc1fd1a61c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 16:34:47 +0200 Subject: [PATCH 02/16] docstring/util/split --- spcd/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spcd/util.py b/spcd/util.py index 70bfa0c..951b59c 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -41,6 +41,7 @@ def shut(text: str) -> None: def split() -> None: + """Separate previous log outputs from the ones following.""" log.info(env.SPCD_SPLT) From 2576b0eba1b634bb66bbcf50ac0583b4cb22601e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:02:06 +0200 Subject: [PATCH 03/16] add hatch --- spcd/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spcd/__init__.py b/spcd/__init__.py index a6f35d0..0c43601 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -59,6 +59,7 @@ def install_python_packages() -> None: run("pip", "install", "--upgrade", "pip") split() packages = [ + "hatch", "mypy", "pelican", "pytest", From 87b39b44866fa7b27b2fe9ffc96026a759cedab9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:13:04 +0200 Subject: [PATCH 04/16] docstring/util/frame,shut --- spcd/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spcd/util.py b/spcd/util.py index 951b59c..8f460e8 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -33,10 +33,12 @@ def cat(file: str) -> None: def frame(text: str) -> None: + """Open a new frame in the log output.""" log.info(f"{env.SPCD_OPEN}{text}") def shut(text: str) -> None: + """Close current frame in the log output.""" log.info(f"{env.SPCD_SHUT}{text}") From 42166a2c4eb8083f9218900e7b23d3c0837059c1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:16:34 +0200 Subject: [PATCH 05/16] docstring/util/browse,cat --- spcd/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spcd/util.py b/spcd/util.py index 8f460e8..962d6fe 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -14,6 +14,7 @@ def add_url_path(url: str, extra_path: str) -> str: def browse(root: str) -> None: + """Frame the browsing of a root directory in the log output.""" paths = [] for directory, _, files in os.walk(root): for file in files: @@ -27,6 +28,7 @@ def browse(root: str) -> None: def cat(file: str) -> None: + """Frame the content of a file in the log output.""" frame(file) log.info(fs.read_file_text(file).rstrip()) shut(file) From 29c701b3d564b66d1e1f768d538a08836df14d52 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:18:41 +0200 Subject: [PATCH 06/16] docstring/util/url --- spcd/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spcd/util.py b/spcd/util.py index 962d6fe..f4710b2 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -8,6 +8,7 @@ from rwx.log import stream as log def add_url_path(url: str, extra_path: str) -> str: + """Append an extra segment to an existing URL.""" parts = urlparse(url) parts = parts._replace(path=str(Path(parts.path) / extra_path)) return urlunparse(parts) From 247f15586e41ab4d567f20c88d0aef5d47102c0c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:20:41 +0200 Subject: [PATCH 07/16] docstring/util --- spcd/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spcd/util.py b/spcd/util.py index f4710b2..9ea9dca 100644 --- a/spcd/util.py +++ b/spcd/util.py @@ -1,3 +1,5 @@ +"""Basic utilities.""" + import os from pathlib import Path from urllib.parse import urlparse, urlunparse From 6619f791ea573581fd8310126fab9aa5352e6524 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:37:19 +0200 Subject: [PATCH 08/16] docstring/ci --- spcd/ci.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spcd/ci.py b/spcd/ci.py index 4e22f01..7417869 100644 --- a/spcd/ci.py +++ b/spcd/ci.py @@ -1,3 +1,5 @@ +"""Continuous Integration.""" + from spcd.project import Project from spcd.projects import Projects From 57a171ae0d5760c8209de3f7391544e18c629c24 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:38:23 +0200 Subject: [PATCH 09/16] docstring/cmd --- spcd/cmd.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spcd/cmd.py b/spcd/cmd.py index 7cf0a0e..1cd4e7f 100644 --- a/spcd/cmd.py +++ b/spcd/cmd.py @@ -1,3 +1,5 @@ +"""Commands available for workflows.""" + import os from pathlib import Path From b41478a7474de2f8ef17e52aede23aabe6eb9d9a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:44:07 +0200 Subject: [PATCH 10/16] docstring/cmd --- spcd/cmd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spcd/cmd.py b/spcd/cmd.py index 1cd4e7f..a1108ee 100644 --- a/spcd/cmd.py +++ b/spcd/cmd.py @@ -11,10 +11,12 @@ from spcd.util import browse def spcd_browse_workspace() -> None: + """Browse the current workspace for the project.""" browse(project.root) def spcd_build_project() -> None: + """Perform the actual building process.""" for extension in ["py", "sh"]: path = Path(project.root) / f"build.{extension}" if path.exists(): @@ -25,12 +27,14 @@ def spcd_build_project() -> None: def spcd_check_project() -> None: + """Check the project for anything wrong.""" ps.run("ruff", "check") def spcd_synchronize( target: str | None = None, source: str | None = None ) -> None: + """Synchronize output towards a target.""" if not target: user = "cd" host = env.SPCD_PROJECT_PATH From ba59b1618f6453542b648dfd5e896e3706cc24d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:50:34 +0200 Subject: [PATCH 11/16] docstring/spcd/init --- spcd/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spcd/__init__.py b/spcd/__init__.py index 0c43601..5028389 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -19,6 +19,7 @@ COMMANDS_PREFIX = "spcd-" def clone_project_branch() -> None: + """Clone project on triggering branch into the current workspace.""" if not projects.environment.get("GITLAB_CI"): step("Clone project branch") log.info(projects) @@ -41,6 +42,7 @@ def clone_project_branch() -> None: def install_commands(path: str) -> None: + """Make commands callable in the operating system.""" step("Install commands") user = Path("/usr/local/bin") for command in [ @@ -54,6 +56,7 @@ def install_commands(path: str) -> None: def install_python_packages() -> None: + """Upgrade pip then install extra Python packages.""" step("Install Python packages") log.info("pip") run("pip", "install", "--upgrade", "pip") @@ -74,6 +77,7 @@ def install_python_packages() -> None: def list_environment_variables() -> None: + """List accessible variables and their public contents.""" step("List environment variables") for variable, value in sorted(projects.environment.items()): if variable not in ["SPCD", "SPCD_SSH_KEY"]: @@ -100,6 +104,7 @@ def main(main: str) -> None: def set_ssh() -> None: + """Set things up to enable access to targets through SSH.""" step("Set SSH") # get variables ssh_hosts = projects.environment.get("SPCD_SSH_HOSTS") From dddad18357e381676dfe655a1cef3f3947127854 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 17:56:35 +0200 Subject: [PATCH 12/16] docstring/spcd/init/main --- spcd/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spcd/__init__.py b/spcd/__init__.py index 5028389..4cf789e 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -87,6 +87,7 @@ def list_environment_variables() -> None: def main(main: str) -> None: + """Entry point to initialize environment or run a specific command.""" paths = environ["PATH"].split(pathsep) if env.SPCD_PYTHON_VENV_BINARIES not in paths: environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths]) From f54c9d598b2fa79d6b415a49b00f2f21193cb152 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 18:03:55 +0200 Subject: [PATCH 13/16] docstring/str --- spcd/project.py | 3 ++- spcd/projects.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spcd/project.py b/spcd/project.py index f45303e..7d900d6 100644 --- a/spcd/project.py +++ b/spcd/project.py @@ -1,4 +1,4 @@ -"""CI project.""" +"""Continuous Integration project.""" from __future__ import annotations @@ -43,6 +43,7 @@ class Project: self.url = add_url_path(projects.url, self.name) def __str__(self: Project) -> str: + """List branch, name, root & url.""" return f"""\ branch = {self.branch} name = {self.name} diff --git a/spcd/projects.py b/spcd/projects.py index ca5d9e1..3a02672 100644 --- a/spcd/projects.py +++ b/spcd/projects.py @@ -1,4 +1,4 @@ -"""CI projects.""" +"""Continuous Integration projects.""" from __future__ import annotations @@ -32,6 +32,7 @@ class Projects: self.url = add_url_path(value, self.group) def __str__(self: Projects) -> str: + """List group, name & url.""" return f"""\ group = {self.group} name = {self.name} From 7dd1dc6dcf1fcb6761cd89a9f851f03f1ca5c651 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 18:15:24 +0200 Subject: [PATCH 14/16] docstring/init --- spcd/project.py | 1 + spcd/projects.py | 1 + 2 files changed, 2 insertions(+) diff --git a/spcd/project.py b/spcd/project.py index 7d900d6..8c658ac 100644 --- a/spcd/project.py +++ b/spcd/project.py @@ -26,6 +26,7 @@ ROOT = [ class Project: def __init__(self: Project, projects: Projects) -> None: + """Set projects, branch, name, root & url.""" self.projects = projects # branch for variable in BRANCH: diff --git a/spcd/projects.py b/spcd/projects.py index 3a02672..c95ad27 100644 --- a/spcd/projects.py +++ b/spcd/projects.py @@ -19,6 +19,7 @@ SERVER_URL = [ class Projects: def __init__(self: Projects) -> None: + """Set environment, group, name & url.""" self.environment = os.environ # group, name for variable in GROUP_AND_NAME: From e9e377901865914b7ac3b2ef73f9e82d0c315abe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 18:17:50 +0200 Subject: [PATCH 15/16] docstring/class --- spcd/project.py | 1 + spcd/projects.py | 1 + 2 files changed, 2 insertions(+) diff --git a/spcd/project.py b/spcd/project.py index 8c658ac..68b6b8a 100644 --- a/spcd/project.py +++ b/spcd/project.py @@ -25,6 +25,7 @@ ROOT = [ class Project: + """Current project.""" def __init__(self: Project, projects: Projects) -> None: """Set projects, branch, name, root & url.""" self.projects = projects diff --git a/spcd/projects.py b/spcd/projects.py index c95ad27..3c4fa69 100644 --- a/spcd/projects.py +++ b/spcd/projects.py @@ -18,6 +18,7 @@ SERVER_URL = [ class Projects: + """Other projects.""" def __init__(self: Projects) -> None: """Set environment, group, name & url.""" self.environment = os.environ From 94e85a8f3641327742a7cad3b665307961e56978 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 19 Aug 2024 18:18:16 +0200 Subject: [PATCH 16/16] ruff/format --- spcd/project.py | 1 + spcd/projects.py | 1 + 2 files changed, 2 insertions(+) diff --git a/spcd/project.py b/spcd/project.py index 68b6b8a..de8b164 100644 --- a/spcd/project.py +++ b/spcd/project.py @@ -26,6 +26,7 @@ ROOT = [ class Project: """Current project.""" + def __init__(self: Project, projects: Projects) -> None: """Set projects, branch, name, root & url.""" self.projects = projects diff --git a/spcd/projects.py b/spcd/projects.py index 3c4fa69..c1f2403 100644 --- a/spcd/projects.py +++ b/spcd/projects.py @@ -19,6 +19,7 @@ SERVER_URL = [ class Projects: """Other projects.""" + def __init__(self: Projects) -> None: """Set environment, group, name & url.""" self.environment = os.environ