tangled
alpha
login
or
join now
rwx.work
/
spcd
0
fork
atom
Shell to Python Continuous Deployment
spcd.rwx.work
0
fork
atom
overview
issues
pulls
pipelines
lint
tilde.link
1 year ago
dfd42191
128c2ef9
+17
-14
4 changed files
expand all
collapse all
unified
split
pyproject.toml
spcd
__init__.py
act.py
cmd.py
+1
-1
pyproject.toml
reviewed
···
18
18
description = "Shell to Python Continuous Deployment"
19
19
dynamic = ["version"]
20
20
keywords = []
21
21
-
license-files = { paths = ["license.md"] }
21
21
+
license-files = ["license.md"]
22
22
name = "spcd"
23
23
readme = "readme.md"
24
24
requires-python = ">= 3.11"
+5
-5
spcd/__init__.py
reviewed
···
16
16
from spcd.util import browse, cat, split, step
17
17
18
18
COMMANDS_PREFIX = "spcd-"
19
19
+
ENTRY_POINT = "__main__.py"
19
20
20
21
21
22
def clone_project_branch() -> None:
···
50
51
name = "action.yaml"
51
52
root = project.root / "act"
52
53
vpy = Path(env.SPCD_PYTHON_VENV_BINARIES) / "python"
53
53
-
for action in ["action", "synchronize"]:
54
54
+
for action in ("action", "synchronize"):
54
55
log.info(action)
55
56
directory = root / action
56
57
fs.make_directory(directory)
···
91
92
"""
92
93
step("Install commands")
93
94
user = Path("/usr/local/bin")
94
94
-
for command in [
95
95
+
for command in (
95
96
"browse-workspace",
96
97
"build-project",
97
98
"check-project",
98
99
"synchronize",
99
99
-
]:
100
100
+
):
100
101
log.info(command)
101
102
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
102
103
···
147
148
if env.SPCD_PYTHON_VENV_BINARIES not in paths:
148
149
environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths])
149
150
path, *arguments = sys.argv
150
150
-
name = Path(path).name
151
151
-
if name == "__main__.py":
151
151
+
if (name := Path(path).name) == ENTRY_POINT:
152
152
if arguments:
153
153
name, *arguments = arguments
154
154
f = getattr(act, name)
+2
spcd/act.py
reviewed
···
1
1
"""Actions available for workflows."""
2
2
3
3
+
from __future__ import annotations
4
4
+
3
5
import os
4
6
from ast import literal_eval
5
7
from pathlib import Path
+9
-8
spcd/cmd.py
reviewed
···
1
1
"""Commands available for workflows."""
2
2
3
3
-
import os
3
3
+
from __future__ import annotations
4
4
+
5
5
+
from os import sep
4
6
from pathlib import Path
5
7
6
8
from rwx import ps
···
17
19
18
20
def spcd_build_project() -> None:
19
21
"""Perform the actual building process."""
20
20
-
for extension in ["py", "sh"]:
22
22
+
for extension in ("py", "sh"):
21
23
path = project.root / f"build.{extension}"
22
24
if path.exists():
23
25
ps.run(str(path))
···
31
33
32
34
33
35
def spcd_synchronize(
34
34
-
source: str | None = None, target: str | None = None
36
36
+
source: str | None = None,
37
37
+
target: str | None = None,
35
38
) -> None:
36
39
"""Synchronize output towards a target.
37
40
···
43
46
if not target:
44
47
user = "cd"
45
48
host = env.SPCD_PROJECT_PATH
46
46
-
root = (
47
47
-
Path(os.sep) / user / projects.group / project.name / project.branch
48
48
-
)
49
49
+
root = Path(sep) / user / projects.group / project.name / project.branch
49
50
target = f"{user}@{host}:{root}"
50
51
if not source:
51
52
source = "out"
···
54
55
"--archive",
55
56
"--delete-before",
56
57
"--verbose",
57
57
-
f"{source}/",
58
58
-
f"{target}/",
58
58
+
f"{source}{sep}",
59
59
+
f"{target}{sep}",
59
60
)