wexample-runner 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wexample_runner/__init__.py +0 -0
- wexample_runner/py.typed +0 -0
- wexample_runner/runner/__init__.py +0 -0
- wexample_runner/runner/abstract_runner.py +61 -0
- wexample_runner/runner/docker_runner.py +170 -0
- wexample_runner/runner/local_runner.py +38 -0
- wexample_runner/runner/ssh_runner.py +102 -0
- wexample_runner/runner_config.py +28 -0
- wexample_runner/runner_registry.py +49 -0
- wexample_runner/runner_result.py +19 -0
- wexample_runner-0.0.3.dist-info/METADATA +165 -0
- wexample_runner-0.0.3.dist-info/RECORD +14 -0
- wexample_runner-0.0.3.dist-info/WHEEL +4 -0
- wexample_runner-0.0.3.dist-info/entry_points.txt +4 -0
|
File without changes
|
wexample_runner/py.typed
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AbstractRunner(ABC):
|
|
7
|
+
"""Base class for all runners.
|
|
8
|
+
|
|
9
|
+
A runner is an execution environment that can build, start, stop, and
|
|
10
|
+
destroy itself, and execute commands within it.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, ephemeral: bool = False) -> None:
|
|
14
|
+
self.ephemeral = ephemeral
|
|
15
|
+
|
|
16
|
+
# --- Context manager (ephemeral support) ---
|
|
17
|
+
def __enter__(self) -> AbstractRunner:
|
|
18
|
+
self.ensure_running()
|
|
19
|
+
return self
|
|
20
|
+
|
|
21
|
+
def __exit__(self, *args) -> None:
|
|
22
|
+
self.stop()
|
|
23
|
+
if self.ephemeral:
|
|
24
|
+
self.destroy()
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def is_built(self) -> bool:
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
# --- Properties ---
|
|
31
|
+
@property
|
|
32
|
+
def is_running(self) -> bool:
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
# --- Lifecycle ---
|
|
36
|
+
def build(self) -> None:
|
|
37
|
+
"""Prepare the environment (build image, check connectivity, etc.). No-op if already built."""
|
|
38
|
+
|
|
39
|
+
def destroy(self) -> None:
|
|
40
|
+
"""Completely remove the environment."""
|
|
41
|
+
|
|
42
|
+
def ensure_running(self) -> None:
|
|
43
|
+
"""Build and start the environment if not already running."""
|
|
44
|
+
self.build()
|
|
45
|
+
self.start()
|
|
46
|
+
|
|
47
|
+
# --- Execution ---
|
|
48
|
+
@abstractmethod
|
|
49
|
+
def execute(
|
|
50
|
+
self,
|
|
51
|
+
cmd: list[str] | str,
|
|
52
|
+
workdir: str | None = None,
|
|
53
|
+
env: dict[str, str] | None = None,
|
|
54
|
+
) -> RunnerResult:
|
|
55
|
+
"""Execute a command in this environment and return the result."""
|
|
56
|
+
|
|
57
|
+
def start(self) -> None:
|
|
58
|
+
"""Start the environment. No-op if already running."""
|
|
59
|
+
|
|
60
|
+
def stop(self) -> None:
|
|
61
|
+
"""Stop the environment without destroying it."""
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from wexample_runner.runner.abstract_runner import AbstractRunner
|
|
6
|
+
from wexample_runner.runner_result import RunnerResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DockerRunner(AbstractRunner):
|
|
10
|
+
"""Execute commands inside a Docker container.
|
|
11
|
+
|
|
12
|
+
Manages the full lifecycle: image build, container creation, start, stop, destroy.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
image_name: str,
|
|
18
|
+
dockerfile_path: Path | str | None = None,
|
|
19
|
+
volumes: dict[str, str] | None = None,
|
|
20
|
+
env: dict[str, str] | None = None,
|
|
21
|
+
container_name: str | None = None,
|
|
22
|
+
workdir: str = "/var/www/html",
|
|
23
|
+
ephemeral: bool = False,
|
|
24
|
+
user: str | None = None,
|
|
25
|
+
) -> None:
|
|
26
|
+
super().__init__(ephemeral=ephemeral)
|
|
27
|
+
self.image_name = image_name
|
|
28
|
+
self.dockerfile_path = Path(dockerfile_path) if dockerfile_path else None
|
|
29
|
+
self.volumes = volumes or {}
|
|
30
|
+
self.env = env or {}
|
|
31
|
+
self.workdir = workdir
|
|
32
|
+
self.user = user
|
|
33
|
+
self._container_name = container_name or self._build_container_name()
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def container_name(self) -> str:
|
|
37
|
+
return self._container_name
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def is_built(self) -> bool:
|
|
41
|
+
from wexample_helpers.helpers.docker import docker_image_exists
|
|
42
|
+
|
|
43
|
+
return docker_image_exists(self.image_name)
|
|
44
|
+
|
|
45
|
+
# --- Properties ---
|
|
46
|
+
@property
|
|
47
|
+
def is_running(self) -> bool:
|
|
48
|
+
from wexample_helpers.helpers.docker import docker_container_is_running
|
|
49
|
+
|
|
50
|
+
return docker_container_is_running(self.container_name)
|
|
51
|
+
|
|
52
|
+
# --- Lifecycle ---
|
|
53
|
+
def build(self) -> None:
|
|
54
|
+
from wexample_helpers.helpers.docker import (
|
|
55
|
+
docker_build_image,
|
|
56
|
+
docker_image_exists,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
if self.dockerfile_path and not docker_image_exists(self.image_name):
|
|
60
|
+
docker_build_image(self.image_name, self.dockerfile_path)
|
|
61
|
+
|
|
62
|
+
def destroy(self) -> None:
|
|
63
|
+
from wexample_helpers.helpers.docker import (
|
|
64
|
+
docker_container_exists,
|
|
65
|
+
docker_image_exists,
|
|
66
|
+
docker_remove_container,
|
|
67
|
+
docker_remove_image,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if docker_container_exists(self.container_name):
|
|
71
|
+
self.stop()
|
|
72
|
+
docker_remove_container(self.container_name)
|
|
73
|
+
|
|
74
|
+
if docker_image_exists(self.image_name):
|
|
75
|
+
docker_remove_image(self.image_name)
|
|
76
|
+
|
|
77
|
+
# --- Execution ---
|
|
78
|
+
def execute(
|
|
79
|
+
self,
|
|
80
|
+
cmd: list[str] | str,
|
|
81
|
+
workdir: str | None = None,
|
|
82
|
+
env: dict[str, str] | None = None,
|
|
83
|
+
) -> RunnerResult:
|
|
84
|
+
import subprocess
|
|
85
|
+
|
|
86
|
+
from wexample_helpers.helpers.shell import shell_run
|
|
87
|
+
|
|
88
|
+
if isinstance(cmd, str):
|
|
89
|
+
cmd = ["sh", "-c", cmd]
|
|
90
|
+
|
|
91
|
+
docker_cmd = ["docker", "exec"]
|
|
92
|
+
|
|
93
|
+
if self.user:
|
|
94
|
+
docker_cmd += ["--user", self.user]
|
|
95
|
+
|
|
96
|
+
effective_workdir = workdir or self.workdir
|
|
97
|
+
if effective_workdir:
|
|
98
|
+
docker_cmd += ["-w", effective_workdir]
|
|
99
|
+
|
|
100
|
+
effective_env = {**self.env, **(env or {})}
|
|
101
|
+
for key, value in effective_env.items():
|
|
102
|
+
docker_cmd += ["-e", f"{key}={value}"]
|
|
103
|
+
|
|
104
|
+
docker_cmd += [self.container_name] + cmd
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
result = shell_run(cmd=docker_cmd, check=False, capture=True)
|
|
108
|
+
return RunnerResult(
|
|
109
|
+
stdout=result.stdout or "",
|
|
110
|
+
stderr=result.stderr or "",
|
|
111
|
+
exit_code=result.returncode,
|
|
112
|
+
)
|
|
113
|
+
except subprocess.CalledProcessError as e:
|
|
114
|
+
return RunnerResult(
|
|
115
|
+
stdout=e.stdout or "",
|
|
116
|
+
stderr=e.stderr or "",
|
|
117
|
+
exit_code=e.returncode,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# --- Utilities ---
|
|
121
|
+
def rebase_path(self, host_path: str | Path) -> str:
|
|
122
|
+
"""Rebase a host path to its equivalent inside the container.
|
|
123
|
+
|
|
124
|
+
Example:
|
|
125
|
+
host: /home/user/project/src/MyFile.php
|
|
126
|
+
mount: /home/user/project → /var/www/html
|
|
127
|
+
result: /var/www/html/src/MyFile.php
|
|
128
|
+
"""
|
|
129
|
+
host_path = Path(host_path).resolve()
|
|
130
|
+
mount_host = Path(list(self.volumes.keys())[0]).resolve()
|
|
131
|
+
container_root = list(self.volumes.values())[0]
|
|
132
|
+
relative = host_path.relative_to(mount_host)
|
|
133
|
+
return f"{container_root.rstrip('/')}/{relative}"
|
|
134
|
+
|
|
135
|
+
def start(self) -> None:
|
|
136
|
+
import os
|
|
137
|
+
|
|
138
|
+
from wexample_helpers.helpers.docker import (
|
|
139
|
+
docker_container_exists,
|
|
140
|
+
docker_container_is_running,
|
|
141
|
+
docker_run_container,
|
|
142
|
+
docker_start_container,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
if docker_container_exists(self.container_name):
|
|
146
|
+
if not docker_container_is_running(self.container_name):
|
|
147
|
+
docker_start_container(self.container_name)
|
|
148
|
+
else:
|
|
149
|
+
user = f"{os.getuid()}:{os.getgid()}"
|
|
150
|
+
docker_run_container(
|
|
151
|
+
self.container_name,
|
|
152
|
+
self.image_name,
|
|
153
|
+
volumes=self.volumes,
|
|
154
|
+
user=user,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def stop(self) -> None:
|
|
158
|
+
from wexample_helpers.helpers.docker import (
|
|
159
|
+
docker_container_is_running,
|
|
160
|
+
docker_stop_container,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
if docker_container_is_running(self.container_name):
|
|
164
|
+
docker_stop_container(self.container_name)
|
|
165
|
+
|
|
166
|
+
def _build_container_name(self) -> str:
|
|
167
|
+
from wexample_helpers.helpers.docker import docker_build_name_from_path
|
|
168
|
+
|
|
169
|
+
anchor = list(self.volumes.keys())[0] if self.volumes else self.image_name
|
|
170
|
+
return docker_build_name_from_path(root_path=anchor, image_name=self.image_name)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from wexample_runner.runner.abstract_runner import AbstractRunner
|
|
4
|
+
from wexample_runner.runner_result import RunnerResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LocalRunner(AbstractRunner):
|
|
8
|
+
"""Execute commands on the local machine via subprocess."""
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def is_built(self) -> bool:
|
|
12
|
+
return True
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def is_running(self) -> bool:
|
|
16
|
+
return True
|
|
17
|
+
|
|
18
|
+
def execute(
|
|
19
|
+
self,
|
|
20
|
+
cmd: list[str] | str,
|
|
21
|
+
workdir: str | None = None,
|
|
22
|
+
env: dict[str, str] | None = None,
|
|
23
|
+
) -> RunnerResult:
|
|
24
|
+
from wexample_helpers.helpers.shell import shell_run
|
|
25
|
+
|
|
26
|
+
result = shell_run(
|
|
27
|
+
cmd=cmd,
|
|
28
|
+
cwd=workdir,
|
|
29
|
+
env=env,
|
|
30
|
+
check=False,
|
|
31
|
+
capture=True,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return RunnerResult(
|
|
35
|
+
stdout=result.stdout or "",
|
|
36
|
+
stderr=result.stderr or "",
|
|
37
|
+
exit_code=result.returncode,
|
|
38
|
+
)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from wexample_runner.runner.abstract_runner import AbstractRunner
|
|
4
|
+
from wexample_runner.runner_result import RunnerResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SshRunner(AbstractRunner):
|
|
8
|
+
"""Execute commands on a remote server via SSH (using paramiko).
|
|
9
|
+
|
|
10
|
+
Supports key-based and password authentication.
|
|
11
|
+
The connection is opened on start() and closed on stop().
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
host: str,
|
|
17
|
+
user: str = "root",
|
|
18
|
+
port: int = 22,
|
|
19
|
+
key_path: str | None = None,
|
|
20
|
+
password: str | None = None,
|
|
21
|
+
ephemeral: bool = False,
|
|
22
|
+
) -> None:
|
|
23
|
+
super().__init__(ephemeral=ephemeral)
|
|
24
|
+
self.host = host
|
|
25
|
+
self.user = user
|
|
26
|
+
self.port = port
|
|
27
|
+
self.key_path = key_path
|
|
28
|
+
self.password = password
|
|
29
|
+
self._client = None
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def is_built(self) -> bool:
|
|
33
|
+
return True
|
|
34
|
+
|
|
35
|
+
# --- Properties ---
|
|
36
|
+
@property
|
|
37
|
+
def is_running(self) -> bool:
|
|
38
|
+
return (
|
|
39
|
+
self._client is not None
|
|
40
|
+
and self._client.get_transport() is not None
|
|
41
|
+
and self._client.get_transport().is_active()
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# --- Lifecycle ---
|
|
45
|
+
def build(self) -> None:
|
|
46
|
+
"""No build step needed for SSH — connectivity is checked on start()."""
|
|
47
|
+
|
|
48
|
+
def destroy(self) -> None:
|
|
49
|
+
"""No remote resources to destroy — just close the connection."""
|
|
50
|
+
self.stop()
|
|
51
|
+
|
|
52
|
+
# --- Execution ---
|
|
53
|
+
def execute(
|
|
54
|
+
self,
|
|
55
|
+
cmd: list[str] | str,
|
|
56
|
+
workdir: str | None = None,
|
|
57
|
+
env: dict[str, str] | None = None,
|
|
58
|
+
) -> RunnerResult:
|
|
59
|
+
if self._client is None:
|
|
60
|
+
raise RuntimeError(
|
|
61
|
+
"SshRunner is not started. Call start() or use as context manager."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if isinstance(cmd, list):
|
|
65
|
+
import shlex
|
|
66
|
+
|
|
67
|
+
cmd = shlex.join(cmd)
|
|
68
|
+
|
|
69
|
+
if workdir:
|
|
70
|
+
cmd = f"cd {shlex.quote(workdir)} && {cmd}"
|
|
71
|
+
|
|
72
|
+
if env:
|
|
73
|
+
env_prefix = " ".join(f"{k}={shlex.quote(v)}" for k, v in env.items())
|
|
74
|
+
cmd = f"{env_prefix} {cmd}"
|
|
75
|
+
|
|
76
|
+
_, stdout, stderr = self._client.exec_command(cmd)
|
|
77
|
+
exit_code = stdout.channel.recv_exit_status()
|
|
78
|
+
|
|
79
|
+
return RunnerResult(
|
|
80
|
+
stdout=stdout.read().decode("utf-8", errors="replace"),
|
|
81
|
+
stderr=stderr.read().decode("utf-8", errors="replace"),
|
|
82
|
+
exit_code=exit_code,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def start(self) -> None:
|
|
86
|
+
import paramiko
|
|
87
|
+
|
|
88
|
+
client = paramiko.SSHClient()
|
|
89
|
+
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
90
|
+
client.connect(
|
|
91
|
+
hostname=self.host,
|
|
92
|
+
port=self.port,
|
|
93
|
+
username=self.user,
|
|
94
|
+
key_filename=self.key_path,
|
|
95
|
+
password=self.password,
|
|
96
|
+
)
|
|
97
|
+
self._client = client
|
|
98
|
+
|
|
99
|
+
def stop(self) -> None:
|
|
100
|
+
if self._client is not None:
|
|
101
|
+
self._client.close()
|
|
102
|
+
self._client = None
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class RunnerConfig:
|
|
9
|
+
"""Declarative configuration for a runner attached to a workdir.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
dockerfile: Path to the Dockerfile, relative to the workdir root.
|
|
13
|
+
Convention: .wex/docker/Dockerfile.{runner_name}
|
|
14
|
+
image_name: Docker image name. Defaults to "wex-{runner_name}".
|
|
15
|
+
mount_path: Host path to mount inside the container.
|
|
16
|
+
Defaults to the workdir's own path.
|
|
17
|
+
container_workdir: Working directory inside the container.
|
|
18
|
+
volumes: Additional volume mappings {host: container}.
|
|
19
|
+
ephemeral: If True, destroy the container after each runner_exec call.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
dockerfile: str | Path
|
|
23
|
+
|
|
24
|
+
container_workdir: str = "/var/www/html"
|
|
25
|
+
ephemeral: bool = False
|
|
26
|
+
image_name: str = ""
|
|
27
|
+
mount_path: str | Path | None = None
|
|
28
|
+
volumes: dict[str, str] = field(default_factory=dict)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from wexample_runner.abstract_runner import AbstractRunner
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RunnerRegistry:
|
|
10
|
+
"""Global registry of named runners.
|
|
11
|
+
|
|
12
|
+
Allows packages to register runners by name and retrieve them later,
|
|
13
|
+
providing a central place to inspect the state of all known environments.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
_runners: dict[str, AbstractRunner] = {}
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def all(cls) -> dict[str, AbstractRunner]:
|
|
20
|
+
return dict(cls._runners)
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def get(cls, name: str) -> AbstractRunner | None:
|
|
24
|
+
return cls._runners.get(name)
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def get_or_raise(cls, name: str) -> AbstractRunner:
|
|
28
|
+
runner = cls.get(name)
|
|
29
|
+
if runner is None:
|
|
30
|
+
raise KeyError(f"No runner registered under name '{name}'.")
|
|
31
|
+
return runner
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def register(cls, name: str, runner: AbstractRunner) -> None:
|
|
35
|
+
cls._runners[name] = runner
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def status(cls) -> list[dict]:
|
|
39
|
+
"""Return a list of dicts describing the state of each registered runner."""
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
"name": name,
|
|
43
|
+
"type": type(runner).__name__,
|
|
44
|
+
"is_built": runner.is_built,
|
|
45
|
+
"is_running": runner.is_running,
|
|
46
|
+
"ephemeral": runner.ephemeral,
|
|
47
|
+
}
|
|
48
|
+
for name, runner in cls._runners.items()
|
|
49
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class RunnerResult:
|
|
8
|
+
exit_code: int
|
|
9
|
+
stderr: str
|
|
10
|
+
stdout: str
|
|
11
|
+
|
|
12
|
+
def is_success(self) -> bool:
|
|
13
|
+
return self.exit_code == 0
|
|
14
|
+
|
|
15
|
+
def raise_on_error(self) -> None:
|
|
16
|
+
if not self.is_success():
|
|
17
|
+
raise RuntimeError(
|
|
18
|
+
f"Command failed (exit {self.exit_code}):\n{self.stderr or self.stdout}"
|
|
19
|
+
)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wexample-runner
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Generic runner abstraction for executing commands in different environments (local, Docker, SSH).
|
|
5
|
+
Author-Email: weeger <contact@wexample.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Project-URL: homepage, https://github.com/wexample/python-runner
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: paramiko>=3.0.0
|
|
13
|
+
Requires-Dist: wexample-helpers>=0.7.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# runner
|
|
20
|
+
|
|
21
|
+
Version: 0.0.3
|
|
22
|
+
|
|
23
|
+
Generic runner abstraction for executing commands in different environments (local, Docker, SSH).
|
|
24
|
+
|
|
25
|
+
## Table of Contents
|
|
26
|
+
|
|
27
|
+
- [Tests](#tests)
|
|
28
|
+
- [Suite Integration](#suite-integration)
|
|
29
|
+
- [Dependencies](#dependencies)
|
|
30
|
+
- [Versioning](#versioning)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
- [Suite Integration](#suite-integration)
|
|
33
|
+
- [Suite Signature](#suite-signature)
|
|
34
|
+
- [Roadmap](#roadmap)
|
|
35
|
+
- [Status Compatibility](#status-compatibility)
|
|
36
|
+
- [Useful Links](#useful-links)
|
|
37
|
+
- [Migration Notes](#migration-notes)
|
|
38
|
+
|
|
39
|
+
## Tests
|
|
40
|
+
|
|
41
|
+
This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
First, install the required testing dependencies:
|
|
46
|
+
```bash
|
|
47
|
+
.venv/bin/python -m pip install pytest pytest-cov
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Basic Usage
|
|
51
|
+
|
|
52
|
+
Run all tests with coverage:
|
|
53
|
+
```bash
|
|
54
|
+
.venv/bin/python -m pytest --cov --cov-report=html
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Common Commands
|
|
58
|
+
```bash
|
|
59
|
+
# Run tests with coverage for a specific module
|
|
60
|
+
.venv/bin/python -m pytest --cov=your_module
|
|
61
|
+
|
|
62
|
+
# Show which lines are not covered
|
|
63
|
+
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
|
|
64
|
+
|
|
65
|
+
# Generate an HTML coverage report
|
|
66
|
+
.venv/bin/python -m pytest --cov=your_module --cov-report=html
|
|
67
|
+
|
|
68
|
+
# Combine terminal and HTML reports
|
|
69
|
+
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
|
|
70
|
+
|
|
71
|
+
# Run specific test file with coverage
|
|
72
|
+
.venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Viewing HTML Reports
|
|
76
|
+
|
|
77
|
+
After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
|
|
78
|
+
|
|
79
|
+
### Coverage Threshold
|
|
80
|
+
|
|
81
|
+
To enforce a minimum coverage percentage:
|
|
82
|
+
```bash
|
|
83
|
+
.venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This will cause the test suite to fail if coverage drops below 80%.
|
|
87
|
+
|
|
88
|
+
## Integration in the Suite
|
|
89
|
+
|
|
90
|
+
This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
|
|
91
|
+
|
|
92
|
+
### Related Packages
|
|
93
|
+
|
|
94
|
+
The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
|
|
95
|
+
|
|
96
|
+
Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
|
|
97
|
+
|
|
98
|
+
## Dependencies
|
|
99
|
+
|
|
100
|
+
- paramiko: >=3.0.0
|
|
101
|
+
- wexample-helpers: >=0.7.0
|
|
102
|
+
|
|
103
|
+
## Versioning & Compatibility Policy
|
|
104
|
+
|
|
105
|
+
Wexample packages follow **Semantic Versioning** (SemVer):
|
|
106
|
+
|
|
107
|
+
- **MAJOR**: Breaking changes
|
|
108
|
+
- **MINOR**: New features, backward compatible
|
|
109
|
+
- **PATCH**: Bug fixes, backward compatible
|
|
110
|
+
|
|
111
|
+
We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
116
|
+
|
|
117
|
+
Free to use in both personal and commercial projects.
|
|
118
|
+
|
|
119
|
+
## Integration in the Suite
|
|
120
|
+
|
|
121
|
+
This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
|
|
122
|
+
|
|
123
|
+
### Related Packages
|
|
124
|
+
|
|
125
|
+
The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
|
|
126
|
+
|
|
127
|
+
Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
|
|
128
|
+
|
|
129
|
+
# About us
|
|
130
|
+
|
|
131
|
+
[Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
|
|
132
|
+
|
|
133
|
+
This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
|
|
134
|
+
|
|
135
|
+
Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
|
|
136
|
+
|
|
137
|
+
## Known Limitations & Roadmap
|
|
138
|
+
|
|
139
|
+
Current limitations and planned features are tracked in the GitHub issues.
|
|
140
|
+
|
|
141
|
+
See the [project roadmap](https://github.com/wexample/python-runner/issues) for upcoming features and improvements.
|
|
142
|
+
|
|
143
|
+
## Status & Compatibility
|
|
144
|
+
|
|
145
|
+
**Maturity**: Production-ready
|
|
146
|
+
|
|
147
|
+
**Python Support**: >=3.10
|
|
148
|
+
|
|
149
|
+
**OS Support**: Linux, macOS, Windows
|
|
150
|
+
|
|
151
|
+
**Status**: Actively maintained
|
|
152
|
+
|
|
153
|
+
## Useful Links
|
|
154
|
+
|
|
155
|
+
- **Homepage**: https://github.com/wexample/python-runner
|
|
156
|
+
- **Documentation**: [docs.wexample.com](https://docs.wexample.com)
|
|
157
|
+
- **Issue Tracker**: https://github.com/wexample/python-runner/issues
|
|
158
|
+
- **Discussions**: https://github.com/wexample/python-runner/discussions
|
|
159
|
+
- **PyPI**: [pypi.org/project/runner](https://pypi.org/project/runner/)
|
|
160
|
+
|
|
161
|
+
## Migration Notes
|
|
162
|
+
|
|
163
|
+
When upgrading between major versions, refer to the migration guides in the documentation.
|
|
164
|
+
|
|
165
|
+
Breaking changes are clearly documented with upgrade paths and examples.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
wexample_runner-0.0.3.dist-info/METADATA,sha256=8OAYFSLjlu3wMQolvhzAYwDpf8BXrXmxly5n5cIBUs0,5991
|
|
2
|
+
wexample_runner-0.0.3.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
|
|
3
|
+
wexample_runner-0.0.3.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
+
wexample_runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
wexample_runner/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
wexample_runner/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
wexample_runner/runner/abstract_runner.py,sha256=n0vKbAXDbuvTJ-oQGlLmQx0pipTkKf5hIDTmsYb_udI,1637
|
|
8
|
+
wexample_runner/runner/docker_runner.py,sha256=Bh0Vdpg48QC-8Lo6YPt9rLK8vNT5hAgtHnq4RBhy8DE,5571
|
|
9
|
+
wexample_runner/runner/local_runner.py,sha256=-ijSPs8BjJj2zWU9tzb9Ifdlqdh1QTQYW1eogWrGC0I,937
|
|
10
|
+
wexample_runner/runner/ssh_runner.py,sha256=flaDqstChTlTISkWrMoSSVML9YUiLVLAVqBfi2wcgJg,2920
|
|
11
|
+
wexample_runner/runner_config.py,sha256=1fXz2fqqxQOObzHaWpl6WRF-88JFD_taX2ku97KVq-E,1042
|
|
12
|
+
wexample_runner/runner_registry.py,sha256=lzIOG_HRoLeRBtwiCc8uJxZhqw9BusO0IzNtjDNcVCI,1442
|
|
13
|
+
wexample_runner/runner_result.py,sha256=elCht9CnUuPP__H5H56accw7iAF3lznXggKPnSqmMjI,432
|
|
14
|
+
wexample_runner-0.0.3.dist-info/RECORD,,
|