Compare commits

..

No commits in common. "94e85a8f3641327742a7cad3b665307961e56978" and "a376f1b1489f8b8438bd1fba2471a3d9aa6095da" have entirely different histories.

6 changed files with 2 additions and 34 deletions

View file

@ -19,7 +19,6 @@ 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)
@ -42,7 +41,6 @@ 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 [
@ -56,13 +54,11 @@ 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")
split()
packages = [
"hatch",
"mypy",
"pelican",
"pytest",
@ -77,7 +73,6 @@ 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"]:
@ -87,7 +82,6 @@ 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])
@ -105,7 +99,6 @@ 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")

View file

@ -1,5 +1,3 @@
"""Continuous Integration."""
from spcd.project import Project
from spcd.projects import Projects

View file

@ -1,5 +1,3 @@
"""Commands available for workflows."""
import os
from pathlib import Path
@ -11,12 +9,10 @@ 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():
@ -27,14 +23,12 @@ 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

View file

@ -1,4 +1,4 @@
"""Continuous Integration project."""
"""CI project."""
from __future__ import annotations
@ -25,10 +25,7 @@ ROOT = [
class Project:
"""Current project."""
def __init__(self: Project, projects: Projects) -> None:
"""Set projects, branch, name, root & url."""
self.projects = projects
# branch
for variable in BRANCH:
@ -46,7 +43,6 @@ 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}

View file

@ -1,4 +1,4 @@
"""Continuous Integration projects."""
"""CI projects."""
from __future__ import annotations
@ -18,10 +18,7 @@ SERVER_URL = [
class Projects:
"""Other projects."""
def __init__(self: Projects) -> None:
"""Set environment, group, name & url."""
self.environment = os.environ
# group, name
for variable in GROUP_AND_NAME:
@ -35,7 +32,6 @@ 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}

View file

@ -1,5 +1,3 @@
"""Basic utilities."""
import os
from pathlib import Path
from urllib.parse import urlparse, urlunparse
@ -10,14 +8,12 @@ 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)
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:
@ -31,29 +27,24 @@ 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)
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}")
def split() -> None:
"""Separate previous log outputs from the ones following."""
log.info(env.SPCD_SPLT)
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}")