Compare commits
No commits in common. "main" and "dev" have entirely different histories.
4 changed files with 31 additions and 124 deletions
37
readme.md
37
readme.md
|
@ -54,10 +54,9 @@ Picture it…
|
||||||
* [X] installing Git to clone
|
* [X] installing Git to clone
|
||||||
* [X] this project
|
* [X] this project
|
||||||
* [X] its parent framework
|
* [X] its parent framework
|
||||||
* [X] installing Python
|
* [X] installing both Python
|
||||||
* [X] system environment
|
* [X] system environment
|
||||||
* [X] virtual environment
|
* [X] virtual environment
|
||||||
* [ ] managed version
|
|
||||||
* [X] generating a Python module to switch context
|
* [X] generating a Python module to switch context
|
||||||
|
|
||||||
#### Python
|
#### Python
|
||||||
|
@ -96,16 +95,30 @@ Handle project workflows in a unified way:
|
||||||
* [ ] SourceHut
|
* [ ] SourceHut
|
||||||
|
|
||||||
* whatever the Operating System container
|
* whatever the Operating System container
|
||||||
| System | Latest | Previous |
|
* [X] Alma
|
||||||
|:---------|:---------------------------|:---------------------------|
|
* [X] 9
|
||||||
| Alma | * [X] 9 | * [X] 8 |
|
* [X] 8
|
||||||
| Alpine | * [X] 3.20 | * [X] 3.19 |
|
* [X] Alpine
|
||||||
| Arch | * [X] 20240818 (.0.255804) | * [X] 20240101 (.0.204074) |
|
* [X] 3.20
|
||||||
| Debian | * [X] Bookworm (12) | * [ ] Bullseye (11) |
|
* [X] 3.19
|
||||||
| Fedora | * [X] 40 | * [X] 39 |
|
* [X] Arch
|
||||||
| OpenSUSE | * [ ] 15.6 | * [ ] 15.5 |
|
* [X] 20240818 (.0.255804)
|
||||||
| Rocky | * [X] 9 | * [X] 8 |
|
* [X] 20240101 (.0.204074)
|
||||||
| Ubuntu | * [X] Noble (24.04) | * [ ] Jammy (22.04) |
|
* [X] Debian
|
||||||
|
* [X] Bookworm (12)
|
||||||
|
* [ ] Bullseye (11)
|
||||||
|
* [X] Fedora
|
||||||
|
* [X] 40
|
||||||
|
* [X] 39
|
||||||
|
* [ ] OpenSUSE
|
||||||
|
* [ ] 15.6
|
||||||
|
* [ ] 15.5
|
||||||
|
* [X] Rocky
|
||||||
|
* [X] 9
|
||||||
|
* [X] 8
|
||||||
|
* [X] Ubuntu
|
||||||
|
* [X] Noble (24.04)
|
||||||
|
* [ ] Jammy (22.04)
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from rwx import fs
|
||||||
from rwx.log import stream as log
|
from rwx.log import stream as log
|
||||||
from rwx.ps import run
|
from rwx.ps import run
|
||||||
|
|
||||||
from spcd import act, cmd
|
from spcd import cmd
|
||||||
from spcd.ci import project, projects
|
from spcd.ci import project, projects
|
||||||
from spcd.shell import env
|
from spcd.shell import env
|
||||||
from spcd.util import browse, cat, split, step
|
from spcd.util import browse, cat, split, step
|
||||||
|
@ -44,45 +44,6 @@ def clone_project_branch() -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_actions() -> None:
|
|
||||||
"""Make actions usable in workflows."""
|
|
||||||
step("Install actions")
|
|
||||||
name = "action.yaml"
|
|
||||||
root = project.root / "act"
|
|
||||||
vpy = Path(env.SPCD_PYTHON_VENV_BINARIES) / "python"
|
|
||||||
for action in ["action", "synchronize"]:
|
|
||||||
log.info(action)
|
|
||||||
directory = root / action
|
|
||||||
fs.make_directory(directory)
|
|
||||||
match action:
|
|
||||||
case "action":
|
|
||||||
inputs = """\
|
|
||||||
arg_1:
|
|
||||||
required: true
|
|
||||||
arg_2:
|
|
||||||
required: true
|
|
||||||
arg_3:
|
|
||||||
required: true
|
|
||||||
arg_4:
|
|
||||||
default: '"placeholder"'
|
|
||||||
"""
|
|
||||||
case "synchronize":
|
|
||||||
inputs = """\
|
|
||||||
source:
|
|
||||||
default: out
|
|
||||||
required: false
|
|
||||||
"""
|
|
||||||
yaml = f"""\
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- run: {vpy} -m spcd {action}
|
|
||||||
inputs:
|
|
||||||
{inputs}"""
|
|
||||||
fs.write(directory / name, yaml)
|
|
||||||
cat(directory / name)
|
|
||||||
|
|
||||||
|
|
||||||
def install_commands(path: Path) -> None:
|
def install_commands(path: Path) -> None:
|
||||||
"""Make commands callable in the operating system.
|
"""Make commands callable in the operating system.
|
||||||
|
|
||||||
|
@ -149,15 +110,9 @@ def main(main_file: Path) -> None:
|
||||||
path, *arguments = sys.argv
|
path, *arguments = sys.argv
|
||||||
name = Path(path).name
|
name = Path(path).name
|
||||||
if name == "__main__.py":
|
if name == "__main__.py":
|
||||||
if arguments:
|
|
||||||
name, *arguments = arguments
|
|
||||||
f = getattr(act, name)
|
|
||||||
f(*arguments)
|
|
||||||
else:
|
|
||||||
list_environment_variables()
|
list_environment_variables()
|
||||||
clone_project_branch()
|
clone_project_branch()
|
||||||
set_ssh()
|
set_ssh()
|
||||||
install_actions()
|
|
||||||
install_commands(main_file)
|
install_commands(main_file)
|
||||||
install_python_packages()
|
install_python_packages()
|
||||||
else:
|
else:
|
||||||
|
|
60
spcd/act.py
60
spcd/act.py
|
@ -1,60 +0,0 @@
|
||||||
"""Actions available for workflows."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from ast import literal_eval
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from rwx import ps
|
|
||||||
from rwx.log import stream as log
|
|
||||||
|
|
||||||
from spcd.ci import project, projects
|
|
||||||
from spcd.shell import env
|
|
||||||
|
|
||||||
PREFIX = "INPUT_"
|
|
||||||
|
|
||||||
|
|
||||||
def action() -> None:
|
|
||||||
"""Display action inputs."""
|
|
||||||
for variable, value in parse_inputs().items():
|
|
||||||
log.info("%s = %s", variable, value)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_inputs() -> dict[str, object]:
|
|
||||||
"""Parse inputs as a dictionary.
|
|
||||||
|
|
||||||
:return: name & value pairs
|
|
||||||
:rtype: dict[str, object]
|
|
||||||
"""
|
|
||||||
inputs = {}
|
|
||||||
for variable, value in sorted(projects.environment.items()):
|
|
||||||
if variable.startswith(PREFIX):
|
|
||||||
name = variable.removeprefix(PREFIX).lower()
|
|
||||||
inputs[name] = literal_eval(value)
|
|
||||||
return inputs
|
|
||||||
|
|
||||||
|
|
||||||
def synchronize(source: str | None = None, target: str | None = None) -> None:
|
|
||||||
"""Synchronize output towards a target.
|
|
||||||
|
|
||||||
:param source: where to deploy from
|
|
||||||
:type source: str | None
|
|
||||||
:param target: where to deploy to
|
|
||||||
:type target: str | None
|
|
||||||
"""
|
|
||||||
if not target:
|
|
||||||
user = "cd"
|
|
||||||
host = env.SPCD_PROJECT_PATH
|
|
||||||
root = (
|
|
||||||
Path(os.sep) / user / projects.group / project.name / project.branch
|
|
||||||
)
|
|
||||||
target = f"{user}@{host}:{root}"
|
|
||||||
if not source:
|
|
||||||
source = "out"
|
|
||||||
ps.run(
|
|
||||||
"rsync",
|
|
||||||
"--archive",
|
|
||||||
"--delete-before",
|
|
||||||
"--verbose",
|
|
||||||
f"{source}/",
|
|
||||||
f"{target}/",
|
|
||||||
)
|
|
|
@ -27,7 +27,6 @@ def spcd_build_project() -> None:
|
||||||
def spcd_check_project() -> None:
|
def spcd_check_project() -> None:
|
||||||
"""Check the project for anything wrong."""
|
"""Check the project for anything wrong."""
|
||||||
ps.run("ruff", "check")
|
ps.run("ruff", "check")
|
||||||
ps.run("ruff", "format", "--diff")
|
|
||||||
|
|
||||||
|
|
||||||
def spcd_synchronize(
|
def spcd_synchronize(
|
||||||
|
|
Loading…
Reference in a new issue