Compare commits
No commits in common. "94e85a8f3641327742a7cad3b665307961e56978" and "a376f1b1489f8b8438bd1fba2471a3d9aa6095da" have entirely different histories.
94e85a8f36
...
a376f1b148
6 changed files with 2 additions and 34 deletions
|
@ -19,7 +19,6 @@ COMMANDS_PREFIX = "spcd-"
|
||||||
|
|
||||||
|
|
||||||
def clone_project_branch() -> None:
|
def clone_project_branch() -> None:
|
||||||
"""Clone project on triggering branch into the current workspace."""
|
|
||||||
if not projects.environment.get("GITLAB_CI"):
|
if not projects.environment.get("GITLAB_CI"):
|
||||||
step("Clone project branch")
|
step("Clone project branch")
|
||||||
log.info(projects)
|
log.info(projects)
|
||||||
|
@ -42,7 +41,6 @@ def clone_project_branch() -> None:
|
||||||
|
|
||||||
|
|
||||||
def install_commands(path: str) -> None:
|
def install_commands(path: str) -> None:
|
||||||
"""Make commands callable in the operating system."""
|
|
||||||
step("Install commands")
|
step("Install commands")
|
||||||
user = Path("/usr/local/bin")
|
user = Path("/usr/local/bin")
|
||||||
for command in [
|
for command in [
|
||||||
|
@ -56,13 +54,11 @@ def install_commands(path: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def install_python_packages() -> None:
|
def install_python_packages() -> None:
|
||||||
"""Upgrade pip then install extra Python packages."""
|
|
||||||
step("Install Python packages")
|
step("Install Python packages")
|
||||||
log.info("pip")
|
log.info("pip")
|
||||||
run("pip", "install", "--upgrade", "pip")
|
run("pip", "install", "--upgrade", "pip")
|
||||||
split()
|
split()
|
||||||
packages = [
|
packages = [
|
||||||
"hatch",
|
|
||||||
"mypy",
|
"mypy",
|
||||||
"pelican",
|
"pelican",
|
||||||
"pytest",
|
"pytest",
|
||||||
|
@ -77,7 +73,6 @@ def install_python_packages() -> None:
|
||||||
|
|
||||||
|
|
||||||
def list_environment_variables() -> None:
|
def list_environment_variables() -> None:
|
||||||
"""List accessible variables and their public contents."""
|
|
||||||
step("List environment variables")
|
step("List environment variables")
|
||||||
for variable, value in sorted(projects.environment.items()):
|
for variable, value in sorted(projects.environment.items()):
|
||||||
if variable not in ["SPCD", "SPCD_SSH_KEY"]:
|
if variable not in ["SPCD", "SPCD_SSH_KEY"]:
|
||||||
|
@ -87,7 +82,6 @@ def list_environment_variables() -> None:
|
||||||
|
|
||||||
|
|
||||||
def main(main: str) -> None:
|
def main(main: str) -> None:
|
||||||
"""Entry point to initialize environment or run a specific command."""
|
|
||||||
paths = environ["PATH"].split(pathsep)
|
paths = environ["PATH"].split(pathsep)
|
||||||
if env.SPCD_PYTHON_VENV_BINARIES not in paths:
|
if env.SPCD_PYTHON_VENV_BINARIES not in paths:
|
||||||
environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths])
|
environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths])
|
||||||
|
@ -105,7 +99,6 @@ def main(main: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def set_ssh() -> None:
|
def set_ssh() -> None:
|
||||||
"""Set things up to enable access to targets through SSH."""
|
|
||||||
step("Set SSH")
|
step("Set SSH")
|
||||||
# get variables
|
# get variables
|
||||||
ssh_hosts = projects.environment.get("SPCD_SSH_HOSTS")
|
ssh_hosts = projects.environment.get("SPCD_SSH_HOSTS")
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
"""Continuous Integration."""
|
|
||||||
|
|
||||||
from spcd.project import Project
|
from spcd.project import Project
|
||||||
from spcd.projects import Projects
|
from spcd.projects import Projects
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
"""Commands available for workflows."""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -11,12 +9,10 @@ from spcd.util import browse
|
||||||
|
|
||||||
|
|
||||||
def spcd_browse_workspace() -> None:
|
def spcd_browse_workspace() -> None:
|
||||||
"""Browse the current workspace for the project."""
|
|
||||||
browse(project.root)
|
browse(project.root)
|
||||||
|
|
||||||
|
|
||||||
def spcd_build_project() -> None:
|
def spcd_build_project() -> None:
|
||||||
"""Perform the actual building process."""
|
|
||||||
for extension in ["py", "sh"]:
|
for extension in ["py", "sh"]:
|
||||||
path = Path(project.root) / f"build.{extension}"
|
path = Path(project.root) / f"build.{extension}"
|
||||||
if path.exists():
|
if path.exists():
|
||||||
|
@ -27,14 +23,12 @@ def spcd_build_project() -> None:
|
||||||
|
|
||||||
|
|
||||||
def spcd_check_project() -> None:
|
def spcd_check_project() -> None:
|
||||||
"""Check the project for anything wrong."""
|
|
||||||
ps.run("ruff", "check")
|
ps.run("ruff", "check")
|
||||||
|
|
||||||
|
|
||||||
def spcd_synchronize(
|
def spcd_synchronize(
|
||||||
target: str | None = None, source: str | None = None
|
target: str | None = None, source: str | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Synchronize output towards a target."""
|
|
||||||
if not target:
|
if not target:
|
||||||
user = "cd"
|
user = "cd"
|
||||||
host = env.SPCD_PROJECT_PATH
|
host = env.SPCD_PROJECT_PATH
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Continuous Integration project."""
|
"""CI project."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
@ -25,10 +25,7 @@ ROOT = [
|
||||||
|
|
||||||
|
|
||||||
class Project:
|
class Project:
|
||||||
"""Current project."""
|
|
||||||
|
|
||||||
def __init__(self: Project, projects: Projects) -> None:
|
def __init__(self: Project, projects: Projects) -> None:
|
||||||
"""Set projects, branch, name, root & url."""
|
|
||||||
self.projects = projects
|
self.projects = projects
|
||||||
# branch
|
# branch
|
||||||
for variable in BRANCH:
|
for variable in BRANCH:
|
||||||
|
@ -46,7 +43,6 @@ class Project:
|
||||||
self.url = add_url_path(projects.url, self.name)
|
self.url = add_url_path(projects.url, self.name)
|
||||||
|
|
||||||
def __str__(self: Project) -> str:
|
def __str__(self: Project) -> str:
|
||||||
"""List branch, name, root & url."""
|
|
||||||
return f"""\
|
return f"""\
|
||||||
branch = {self.branch}
|
branch = {self.branch}
|
||||||
name = {self.name}
|
name = {self.name}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Continuous Integration projects."""
|
"""CI projects."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
@ -18,10 +18,7 @@ SERVER_URL = [
|
||||||
|
|
||||||
|
|
||||||
class Projects:
|
class Projects:
|
||||||
"""Other projects."""
|
|
||||||
|
|
||||||
def __init__(self: Projects) -> None:
|
def __init__(self: Projects) -> None:
|
||||||
"""Set environment, group, name & url."""
|
|
||||||
self.environment = os.environ
|
self.environment = os.environ
|
||||||
# group, name
|
# group, name
|
||||||
for variable in GROUP_AND_NAME:
|
for variable in GROUP_AND_NAME:
|
||||||
|
@ -35,7 +32,6 @@ class Projects:
|
||||||
self.url = add_url_path(value, self.group)
|
self.url = add_url_path(value, self.group)
|
||||||
|
|
||||||
def __str__(self: Projects) -> str:
|
def __str__(self: Projects) -> str:
|
||||||
"""List group, name & url."""
|
|
||||||
return f"""\
|
return f"""\
|
||||||
group = {self.group}
|
group = {self.group}
|
||||||
name = {self.name}
|
name = {self.name}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
"""Basic utilities."""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import urlparse, urlunparse
|
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:
|
def add_url_path(url: str, extra_path: str) -> str:
|
||||||
"""Append an extra segment to an existing URL."""
|
|
||||||
parts = urlparse(url)
|
parts = urlparse(url)
|
||||||
parts = parts._replace(path=str(Path(parts.path) / extra_path))
|
parts = parts._replace(path=str(Path(parts.path) / extra_path))
|
||||||
return urlunparse(parts)
|
return urlunparse(parts)
|
||||||
|
|
||||||
|
|
||||||
def browse(root: str) -> None:
|
def browse(root: str) -> None:
|
||||||
"""Frame the browsing of a root directory in the log output."""
|
|
||||||
paths = []
|
paths = []
|
||||||
for directory, _, files in os.walk(root):
|
for directory, _, files in os.walk(root):
|
||||||
for file in files:
|
for file in files:
|
||||||
|
@ -31,29 +27,24 @@ def browse(root: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def cat(file: str) -> None:
|
def cat(file: str) -> None:
|
||||||
"""Frame the content of a file in the log output."""
|
|
||||||
frame(file)
|
frame(file)
|
||||||
log.info(fs.read_file_text(file).rstrip())
|
log.info(fs.read_file_text(file).rstrip())
|
||||||
shut(file)
|
shut(file)
|
||||||
|
|
||||||
|
|
||||||
def frame(text: str) -> None:
|
def frame(text: str) -> None:
|
||||||
"""Open a new frame in the log output."""
|
|
||||||
log.info(f"{env.SPCD_OPEN}{text}")
|
log.info(f"{env.SPCD_OPEN}{text}")
|
||||||
|
|
||||||
|
|
||||||
def shut(text: str) -> None:
|
def shut(text: str) -> None:
|
||||||
"""Close current frame in the log output."""
|
|
||||||
log.info(f"{env.SPCD_SHUT}{text}")
|
log.info(f"{env.SPCD_SHUT}{text}")
|
||||||
|
|
||||||
|
|
||||||
def split() -> None:
|
def split() -> None:
|
||||||
"""Separate previous log outputs from the ones following."""
|
|
||||||
log.info(env.SPCD_SPLT)
|
log.info(env.SPCD_SPLT)
|
||||||
|
|
||||||
|
|
||||||
def step(text: str) -> None:
|
def step(text: str) -> None:
|
||||||
"""Increment the step number of the current build process."""
|
|
||||||
env.SPCD_STEP += 1
|
env.SPCD_STEP += 1
|
||||||
log.info(env.SPCD_DOWN)
|
log.info(env.SPCD_DOWN)
|
||||||
log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}")
|
log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}")
|
||||||
|
|
Loading…
Reference in a new issue