Compare commits

..

No commits in common. "main" and "dev" have entirely different histories.
main ... dev

4 changed files with 31 additions and 124 deletions

View file

@ -54,10 +54,9 @@ Picture it…
* [X] installing Git to clone
* [X] this project
* [X] its parent framework
* [X] installing Python
* [X] installing both Python
* [X] system environment
* [X] virtual environment
* [ ] managed version
* [X] generating a Python module to switch context
#### Python
@ -96,16 +95,30 @@ Handle project workflows in a unified way:
* [ ] SourceHut
* whatever the Operating System container
| System | Latest | Previous |
|:---------|:---------------------------|:---------------------------|
| Alma | * [X] 9 | * [X] 8 |
| Alpine | * [X] 3.20 | * [X] 3.19 |
| Arch | * [X] 20240818 (.0.255804) | * [X] 20240101 (.0.204074) |
| Debian | * [X] Bookworm (12) | * [ ] Bullseye (11) |
| Fedora | * [X] 40 | * [X] 39 |
| OpenSUSE | * [ ] 15.6 | * [ ] 15.5 |
| Rocky | * [X] 9 | * [X] 8 |
| Ubuntu | * [X] Noble (24.04) | * [ ] Jammy (22.04) |
* [X] Alma
* [X] 9
* [X] 8
* [X] Alpine
* [X] 3.20
* [X] 3.19
* [X] Arch
* [X] 20240818 (.0.255804)
* [X] 20240101 (.0.204074)
* [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

View file

@ -10,7 +10,7 @@ from rwx import fs
from rwx.log import stream as log
from rwx.ps import run
from spcd import act, cmd
from spcd import cmd
from spcd.ci import project, projects
from spcd.shell import env
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:
"""Make commands callable in the operating system.
@ -149,17 +110,11 @@ def main(main_file: Path) -> None:
path, *arguments = sys.argv
name = Path(path).name
if name == "__main__.py":
if arguments:
name, *arguments = arguments
f = getattr(act, name)
f(*arguments)
else:
list_environment_variables()
clone_project_branch()
set_ssh()
install_actions()
install_commands(main_file)
install_python_packages()
list_environment_variables()
clone_project_branch()
set_ssh()
install_commands(main_file)
install_python_packages()
else:
f = getattr(cmd, name.replace("-", "_"))
f(*arguments)

View file

@ -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}/",
)

View file

@ -27,7 +27,6 @@ def spcd_build_project() -> None:
def spcd_check_project() -> None:
"""Check the project for anything wrong."""
ps.run("ruff", "check")
ps.run("ruff", "format", "--diff")
def spcd_synchronize(