diff --git a/Dockerfile b/Dockerfile index f58d2be..f7f4188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer # Add any system dependencies for the developer/build environment here RUN apt-get update -y && apt-get install -y --no-install-recommends \ - graphviz environment-modules wget \ + graphviz environment-modules wget file \ && cd /tmp \ && wget https://github.com/apptainer/apptainer/releases/download/v1.3.3/apptainer_1.3.3_amd64.deb \ && apt install -y ./apptainer_1.3.3_amd64.deb \ diff --git a/pyproject.toml b/pyproject.toml index 6441f42..5607638 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -174,6 +174,7 @@ commands = [ src = ["src", "tests"] line-length = 88 lint.select = [ + "ANN", # flake8-annotations - https://docs.astral.sh/ruff/rules/#flake8-annotations-ann "B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b "C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 "E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e @@ -190,3 +191,5 @@ lint.select = [ # See https://github.com/DiamondLightSource/python-copier-template/issues/154 # Remove this line to forbid private member access in tests "tests/**/*" = ["SLF001"] +# Managed by the copier template; left unannotated to avoid divergence +".github/pages/make_switcher.py" = ["ANN"] diff --git a/src/deploy_tools/__main__.py b/src/deploy_tools/__main__.py index a24be0c..4a609f4 100644 --- a/src/deploy_tools/__main__.py +++ b/src/deploy_tools/__main__.py @@ -1,4 +1,5 @@ import logging +import sys from pathlib import Path from typing import Annotated @@ -6,6 +7,7 @@ from . import __version__ from .compare import compare_to_snapshot +from .errors import DeployToolsError from .models.schema import generate_schema from .sync import synchronise from .validate import validate_and_test_configuration @@ -203,7 +205,14 @@ def common( def main() -> None: - app() + try: + app() + except DeployToolsError as exc: + # Expected, actionable failures carry a complete user-facing message, so present + # just that and exit non-zero. Any other exception propagates to Typer's + # excepthook and surfaces as a full traceback, as befits an unexpected bug. + typer.secho(f"Error: {exc}", fg=typer.colors.RED, err=True) + sys.exit(1) if __name__ == "__main__": diff --git a/src/deploy_tools/app_builder.py b/src/deploy_tools/app_builder.py index 26ee889..913ebc0 100644 --- a/src/deploy_tools/app_builder.py +++ b/src/deploy_tools/app_builder.py @@ -7,6 +7,7 @@ from deploy_tools.models.binary_app import BinaryApp, HashType from .apptainer import create_sif_file +from .errors import DeployToolsError from .layout import ModuleBuildLayout from .models.apptainer_app import ApptainerApp from .models.module import Application, Module @@ -16,7 +17,7 @@ ALL_READ_EXECUTE_PERMISSIONS = 0o555 -class AppBuilderError(Exception): +class AppBuilderError(DeployToolsError): """Raised when building an application's files fails.""" @@ -27,7 +28,7 @@ def __init__(self, templater: Templater, build_layout: ModuleBuildLayout) -> Non self._templater = templater self._build_layout = build_layout - def create_application_files(self, app: Application, module: Module): + def create_application_files(self, app: Application, module: Module) -> None: """Create the entrypoint and supporting files for an application. The files produced depend on the application type (Apptainer, shell or binary). diff --git a/src/deploy_tools/apptainer.py b/src/deploy_tools/apptainer.py index 5581fda..d183ea4 100644 --- a/src/deploy_tools/apptainer.py +++ b/src/deploy_tools/apptainer.py @@ -1,8 +1,10 @@ -import subprocess from pathlib import Path +from .errors import DeployToolsError +from .external_tools import run_command -class ApptainerError(Exception): + +class ApptainerError(DeployToolsError): """Raised when building an Apptainer SIF file fails.""" @@ -27,4 +29,4 @@ def create_sif_file( ) commands = ["apptainer", "pull", output_path, container_url] - subprocess.run(commands, check=True) + run_command(commands, check=True) diff --git a/src/deploy_tools/compare.py b/src/deploy_tools/compare.py index 40ed673..61a0ce9 100644 --- a/src/deploy_tools/compare.py +++ b/src/deploy_tools/compare.py @@ -7,6 +7,7 @@ import yaml from pydantic import TypeAdapter +from .errors import DeployToolsError from .layout import Layout from .models.deployment import ( DefaultVersionsByName, @@ -23,7 +24,7 @@ logger = logging.getLogger(__name__) -class ComparisonError(Exception): +class ComparisonError(DeployToolsError): """Raised when comparing the deployment area to its snapshot fails.""" @@ -182,7 +183,7 @@ def _compare_default_versions(snapshot: Deployment, actual: Deployment) -> None: ) -def _get_dict_diff(d1: dict[str, Any], d2: dict[str, Any]): +def _get_dict_diff(d1: dict[str, Any], d2: dict[str, Any]) -> str: return "\n" + "\n".join( difflib.ndiff( _yaml_dumps(d1).splitlines(), diff --git a/src/deploy_tools/errors.py b/src/deploy_tools/errors.py new file mode 100644 index 0000000..cfa7683 --- /dev/null +++ b/src/deploy_tools/errors.py @@ -0,0 +1,10 @@ +class DeployToolsError(Exception): + """Base class for expected, user-facing deploy-tools errors. + + These represent actionable failure conditions, such as invalid configuration or a + corrupt deployment area, where the exception message is itself the guidance the + operator needs. The CLI catches this base class at the top level and prints the + message without a traceback (see ``deploy_tools.__main__.main``). Any exception that + is *not* a ``DeployToolsError`` is treated as an unexpected bug and surfaces with a + full traceback. + """ diff --git a/src/deploy_tools/external_tools.py b/src/deploy_tools/external_tools.py new file mode 100644 index 0000000..cb72ccf --- /dev/null +++ b/src/deploy_tools/external_tools.py @@ -0,0 +1,51 @@ +import subprocess +from pathlib import Path +from typing import Any + +from .errors import DeployToolsError + + +class ExternalToolError(DeployToolsError): + """Raised when a required external command-line tool is missing or fails.""" + + +def run_command( + command: list[str | Path], + *, + check: bool = False, + capture_output: bool = False, + text: bool = False, +) -> subprocess.CompletedProcess[Any]: + """Run an external command, surfacing tool problems as clean domain errors. + + Wraps ``subprocess.run`` so that a missing executable (or, when ``check`` is set, a + non-zero exit) is reported as an ``ExternalToolError`` rather than a raw + ``FileNotFoundError``/``CalledProcessError`` traceback. + + Args: + command: The command to run, as a list whose first element is the executable. + check: If True, raise when the command exits with a non-zero status. + capture_output: If True, capture the command's stdout and stderr. + text: If True, decode captured output as text rather than bytes. + + Returns: + The ``subprocess.CompletedProcess`` for the finished command. + + Raises: + ExternalToolError: If the executable cannot be found, or ``check`` is set and + the command exits with a non-zero status. + """ + executable = str(command[0]) + try: + return subprocess.run( + command, check=check, capture_output=capture_output, text=text + ) + except FileNotFoundError as exc: + raise ExternalToolError( + f"Required external tool not found: '{executable}'.\n" + f"Ensure it is installed and available on PATH." + ) from exc + except subprocess.CalledProcessError as exc: + raise ExternalToolError( + f"External tool '{executable}' failed with exit status {exc.returncode}." + ) from exc diff --git a/src/deploy_tools/layout.py b/src/deploy_tools/layout.py index 43f0d41..3d8b98d 100644 --- a/src/deploy_tools/layout.py +++ b/src/deploy_tools/layout.py @@ -47,7 +47,7 @@ def get_sif_files_folder(self, name: str, version: str) -> Path: return self.get_module_folder(name, version) / self.SIF_FILES_FOLDER @property - def build_root(self): + def build_root(self) -> Path: """Root path of the build area.""" return self._root diff --git a/src/deploy_tools/models/save_and_load.py b/src/deploy_tools/models/save_and_load.py index f176938..818cd96 100644 --- a/src/deploy_tools/models/save_and_load.py +++ b/src/deploy_tools/models/save_and_load.py @@ -6,6 +6,7 @@ import yaml from pydantic import BaseModel +from ..errors import DeployToolsError from .deployment import ( Deployment, DeploymentSettings, @@ -17,7 +18,7 @@ DEPLOYMENT_SETTINGS = "settings" + YAML_FILE_SUFFIX -class LoadError(Exception): +class LoadError(DeployToolsError): """Raised when configuration files cannot be loaded into the model.""" diff --git a/src/deploy_tools/print_updates.py b/src/deploy_tools/print_updates.py index 9e32483..61bf9b4 100644 --- a/src/deploy_tools/print_updates.py +++ b/src/deploy_tools/print_updates.py @@ -25,7 +25,10 @@ def _print_module_updates(release_changes: ReleaseChanges) -> None: if releases: print(f"Modules to be {action}:") - for release in releases: + # Sort for stable output: release lists follow config load (glob) order. + for release in sorted( + releases, key=lambda r: (r.module.name, r.module.version) + ): print(f"{release.module.name}/{release.module.version}") print() @@ -36,10 +39,10 @@ def _print_module_updates(release_changes: ReleaseChanges) -> None: def _print_version_updates( old_defaults: DefaultVersionsByName, new_defaults: DefaultVersionsByName ) -> None: - module_names = old_defaults.keys() | new_defaults.keys() + module_names: set[str] = old_defaults.keys() | new_defaults.keys() update_messages: list[str] = [] - for name in module_names: + for name in sorted(module_names): old = old_defaults.get(name, "None") new = new_defaults.get(name, "None") if not old == new: diff --git a/src/deploy_tools/snapshot.py b/src/deploy_tools/snapshot.py index 1e4da9b..ad2c254 100644 --- a/src/deploy_tools/snapshot.py +++ b/src/deploy_tools/snapshot.py @@ -3,6 +3,7 @@ from git import Repo +from .errors import DeployToolsError from .layout import Layout from .models.deployment import Deployment, DeploymentSettings from .models.save_and_load import load_from_yaml, save_as_yaml @@ -10,7 +11,7 @@ logger = logging.getLogger(__name__) -class SnapshotError(Exception): +class SnapshotError(DeployToolsError): """Raised when a deployment snapshot is missing or in an unexpected state.""" diff --git a/src/deploy_tools/validate.py b/src/deploy_tools/validate.py index fdbdeb0..84bdd53 100644 --- a/src/deploy_tools/validate.py +++ b/src/deploy_tools/validate.py @@ -1,11 +1,12 @@ import logging -import subprocess from pathlib import Path from tempfile import TemporaryDirectory from natsort import natsorted from .build import build +from .errors import DeployToolsError +from .external_tools import run_command from .layout import Layout from .models.changes import DeploymentChanges, ReleaseChanges from .models.deployment import ( @@ -25,7 +26,7 @@ SCRIPT_INDICATOR_PHRASE = "shell script" -class ValidationError(Exception): +class ValidationError(DeployToolsError): """Raised when the deployment configuration fails validation.""" @@ -242,9 +243,7 @@ def _is_shell_script(file: Path) -> bool: This uses the output of the Linux 'file' command, which is dependent on the shebang line as well as the OS. Both are controlled in our deployment. """ - result = subprocess.run( - ["file", f"{file.absolute()}"], capture_output=True, text=True - ) + result = run_command(["file", str(file.absolute())], capture_output=True, text=True) return SCRIPT_INDICATOR_PHRASE in result.stdout @@ -257,12 +256,12 @@ def _check_bash_syntax(file: Path) -> None: This is also unable to check that all required functions and tools are available, so some typos are likely to pass. """ - result = subprocess.run( - ["bash", "-n", f"{file.absolute()}"], + result = run_command( + ["bash", "-n", str(file.absolute())], capture_output=True, text=True, ) - if result.stderr: + if result.returncode != 0: raise ValidationError( f"Output script {file.absolute()} is invalid with errors:\n{result.stderr}" ) diff --git a/tests/configs/golden-master/01-initial/apps/0.1.yaml b/tests/configs/golden-master/01-initial/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/01-initial/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/01-initial/deps/0.2.yaml b/tests/configs/golden-master/01-initial/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/01-initial/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/01-initial/settings.yaml b/tests/configs/golden-master/01-initial/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/01-initial/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/01-initial/updatable/1.0.yaml b/tests/configs/golden-master/01-initial/updatable/1.0.yaml new file mode 100644 index 0000000..f2d2d15 --- /dev/null +++ b/tests/configs/golden-master/01-initial/updatable/1.0.yaml @@ -0,0 +1,21 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + value: Set at initial deployment + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + # allow_updates lets a later sync change this version's configuration in place, + # without bumping the version number. + allow_updates: true diff --git a/tests/configs/golden-master/01-initial/versions/1.0.yaml b/tests/configs/golden-master/01-initial/versions/1.0.yaml new file mode 100644 index 0000000..7558531 --- /dev/null +++ b/tests/configs/golden-master/01-initial/versions/1.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "1.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/02-added/apps/0.1.yaml b/tests/configs/golden-master/02-added/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/02-added/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/02-added/deps/0.2.yaml b/tests/configs/golden-master/02-added/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/02-added/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/02-added/settings.yaml b/tests/configs/golden-master/02-added/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/02-added/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/02-added/updatable/1.0.yaml b/tests/configs/golden-master/02-added/updatable/1.0.yaml new file mode 100644 index 0000000..f2d2d15 --- /dev/null +++ b/tests/configs/golden-master/02-added/updatable/1.0.yaml @@ -0,0 +1,21 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + value: Set at initial deployment + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + # allow_updates lets a later sync change this version's configuration in place, + # without bumping the version number. + allow_updates: true diff --git a/tests/configs/golden-master/02-added/versions/1.0.yaml b/tests/configs/golden-master/02-added/versions/1.0.yaml new file mode 100644 index 0000000..7558531 --- /dev/null +++ b/tests/configs/golden-master/02-added/versions/1.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "1.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/02-added/versions/2.0.yaml b/tests/configs/golden-master/02-added/versions/2.0.yaml new file mode 100644 index 0000000..ff7bc94 --- /dev/null +++ b/tests/configs/golden-master/02-added/versions/2.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/02-added/versions/2.1rc1.yaml b/tests/configs/golden-master/02-added/versions/2.1rc1.yaml new file mode 100644 index 0000000..64cd4ee --- /dev/null +++ b/tests/configs/golden-master/02-added/versions/2.1rc1.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.1rc1" + description: Module demonstrating multiple versions and default-version selection + + # Excluded from automatic default selection, so the default stays at the latest + # stable version even though this prerelease sorts higher. + exclude_from_defaults: true + + applications: [] diff --git a/tests/configs/golden-master/03-updated/apps/0.1.yaml b/tests/configs/golden-master/03-updated/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/03-updated/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/03-updated/deps/0.2.yaml b/tests/configs/golden-master/03-updated/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/03-updated/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/03-updated/settings.yaml b/tests/configs/golden-master/03-updated/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/03-updated/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/03-updated/updatable/1.0.yaml b/tests/configs/golden-master/03-updated/updatable/1.0.yaml new file mode 100644 index 0000000..72dc3cd --- /dev/null +++ b/tests/configs/golden-master/03-updated/updatable/1.0.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + # Changing this value (permitted by allow_updates) triggers an in-place update. + value: Updated in a later sync + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + allow_updates: true diff --git a/tests/configs/golden-master/03-updated/versions/1.0.yaml b/tests/configs/golden-master/03-updated/versions/1.0.yaml new file mode 100644 index 0000000..7558531 --- /dev/null +++ b/tests/configs/golden-master/03-updated/versions/1.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "1.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/03-updated/versions/2.0.yaml b/tests/configs/golden-master/03-updated/versions/2.0.yaml new file mode 100644 index 0000000..ff7bc94 --- /dev/null +++ b/tests/configs/golden-master/03-updated/versions/2.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/03-updated/versions/2.1rc1.yaml b/tests/configs/golden-master/03-updated/versions/2.1rc1.yaml new file mode 100644 index 0000000..64cd4ee --- /dev/null +++ b/tests/configs/golden-master/03-updated/versions/2.1rc1.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.1rc1" + description: Module demonstrating multiple versions and default-version selection + + # Excluded from automatic default selection, so the default stays at the latest + # stable version even though this prerelease sorts higher. + exclude_from_defaults: true + + applications: [] diff --git a/tests/configs/golden-master/04-deprecated/apps/0.1.yaml b/tests/configs/golden-master/04-deprecated/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/04-deprecated/deps/0.2.yaml b/tests/configs/golden-master/04-deprecated/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/04-deprecated/settings.yaml b/tests/configs/golden-master/04-deprecated/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/04-deprecated/updatable/1.0.yaml b/tests/configs/golden-master/04-deprecated/updatable/1.0.yaml new file mode 100644 index 0000000..72dc3cd --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/updatable/1.0.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + # Changing this value (permitted by allow_updates) triggers an in-place update. + value: Updated in a later sync + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + allow_updates: true diff --git a/tests/configs/golden-master/04-deprecated/versions/1.0.yaml b/tests/configs/golden-master/04-deprecated/versions/1.0.yaml new file mode 100644 index 0000000..2a4216d --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/versions/1.0.yaml @@ -0,0 +1,10 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "1.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] + +deprecated: true diff --git a/tests/configs/golden-master/04-deprecated/versions/2.0.yaml b/tests/configs/golden-master/04-deprecated/versions/2.0.yaml new file mode 100644 index 0000000..ff7bc94 --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/versions/2.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/04-deprecated/versions/2.1rc1.yaml b/tests/configs/golden-master/04-deprecated/versions/2.1rc1.yaml new file mode 100644 index 0000000..32d5389 --- /dev/null +++ b/tests/configs/golden-master/04-deprecated/versions/2.1rc1.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.1rc1" + description: Module demonstrating multiple versions and default-version selection + + # Excluded from automatic default selection, so the default stays at the latest + # stable version even though this prerelease sorts higher. + exclude_from_defaults: true + + applications: [] + +deprecated: true diff --git a/tests/configs/golden-master/05-restored/apps/0.1.yaml b/tests/configs/golden-master/05-restored/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/05-restored/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/05-restored/deps/0.2.yaml b/tests/configs/golden-master/05-restored/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/05-restored/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/05-restored/settings.yaml b/tests/configs/golden-master/05-restored/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/05-restored/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/05-restored/updatable/1.0.yaml b/tests/configs/golden-master/05-restored/updatable/1.0.yaml new file mode 100644 index 0000000..72dc3cd --- /dev/null +++ b/tests/configs/golden-master/05-restored/updatable/1.0.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + # Changing this value (permitted by allow_updates) triggers an in-place update. + value: Updated in a later sync + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + allow_updates: true diff --git a/tests/configs/golden-master/05-restored/versions/1.0.yaml b/tests/configs/golden-master/05-restored/versions/1.0.yaml new file mode 100644 index 0000000..2a4216d --- /dev/null +++ b/tests/configs/golden-master/05-restored/versions/1.0.yaml @@ -0,0 +1,10 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "1.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] + +deprecated: true diff --git a/tests/configs/golden-master/05-restored/versions/2.0.yaml b/tests/configs/golden-master/05-restored/versions/2.0.yaml new file mode 100644 index 0000000..ff7bc94 --- /dev/null +++ b/tests/configs/golden-master/05-restored/versions/2.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/05-restored/versions/2.1rc1.yaml b/tests/configs/golden-master/05-restored/versions/2.1rc1.yaml new file mode 100644 index 0000000..64cd4ee --- /dev/null +++ b/tests/configs/golden-master/05-restored/versions/2.1rc1.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.1rc1" + description: Module demonstrating multiple versions and default-version selection + + # Excluded from automatic default selection, so the default stays at the latest + # stable version even though this prerelease sorts higher. + exclude_from_defaults: true + + applications: [] diff --git a/tests/configs/golden-master/06-removed/apps/0.1.yaml b/tests/configs/golden-master/06-removed/apps/0.1.yaml new file mode 100644 index 0000000..53930c4 --- /dev/null +++ b/tests/configs/golden-master/06-removed/apps/0.1.yaml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: apps + version: "0.1" + description: Module demonstrating shell and Apptainer applications + + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + + applications: + - app_type: apptainer + + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + + entrypoints: + - name: cowsay-hello + command: cowsay + options: + command_args: Hello + + - app_type: shell + + name: test-echo-module-var + script: + - echo $OTHER_VALUE + + - app_type: shell + + name: test-shell-script + script: + - "echo This is the first line of a shell script" + - "echo and this is the second line." + - "echo Your input is ${1}" diff --git a/tests/configs/golden-master/06-removed/deps/0.2.yaml b/tests/configs/golden-master/06-removed/deps/0.2.yaml new file mode 100644 index 0000000..2556b79 --- /dev/null +++ b/tests/configs/golden-master/06-removed/deps/0.2.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: deps + version: "0.2" + description: Module demonstrating dependencies + + dependencies: + - name: apps + version: "0.1" + # A version-less dependency is valid only for modules not managed by deploy-tools. + - name: external-module + + applications: [] diff --git a/tests/configs/golden-master/06-removed/settings.yaml b/tests/configs/golden-master/06-removed/settings.yaml new file mode 100644 index 0000000..70f6001 --- /dev/null +++ b/tests/configs/golden-master/06-removed/settings.yaml @@ -0,0 +1,3 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json + +default_versions: {} diff --git a/tests/configs/golden-master/06-removed/updatable/1.0.yaml b/tests/configs/golden-master/06-removed/updatable/1.0.yaml new file mode 100644 index 0000000..72dc3cd --- /dev/null +++ b/tests/configs/golden-master/06-removed/updatable/1.0.yaml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: updatable + version: "1.0" + description: Module demonstrating in-place updates (allow_updates) + + env_vars: + - name: UPDATABLE_VALUE + # Changing this value (permitted by allow_updates) triggers an in-place update. + value: Updated in a later sync + + applications: + - app_type: shell + + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + + allow_updates: true diff --git a/tests/configs/golden-master/06-removed/versions/2.0.yaml b/tests/configs/golden-master/06-removed/versions/2.0.yaml new file mode 100644 index 0000000..ff7bc94 --- /dev/null +++ b/tests/configs/golden-master/06-removed/versions/2.0.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.0" + description: Module demonstrating multiple versions and default-version selection + + applications: [] diff --git a/tests/configs/golden-master/06-removed/versions/2.1rc1.yaml b/tests/configs/golden-master/06-removed/versions/2.1rc1.yaml new file mode 100644 index 0000000..64cd4ee --- /dev/null +++ b/tests/configs/golden-master/06-removed/versions/2.1rc1.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/release.json + +module: + name: versions + version: "2.1rc1" + description: Module demonstrating multiple versions and default-version selection + + # Excluded from automatic default selection, so the default stays at the latest + # stable version even though this prerelease sorts higher. + exclude_from_defaults: true + + applications: [] diff --git a/tests/conftest.py b/tests/conftest.py index 77e0c8e..63ebc0e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,23 +8,43 @@ runner = CliRunner() -def run_cli(*args: str | Path): +def run_cli(*args: str | Path) -> str: result = runner.invoke(app, [str(x) for x in args]) if result.exception: raise result.exception assert result.exit_code == 0, result + return result.stdout @pytest.fixture -def schemas(): +def schemas() -> Path: return Path(__file__).parent.parent / "src" / "deploy_tools" / "models" / "schemas" @pytest.fixture -def samples(): +def samples() -> Path: return Path(__file__).parent / "samples" @pytest.fixture -def demo_config(): - return Path(__file__).parent.parent / "src" / "deploy_tools" / "demo_configuration" +def configs() -> Path: + return Path(__file__).parent / "configs" + + +@pytest.fixture +def stub_apptainer_pull(monkeypatch: pytest.MonkeyPatch) -> None: + """Stub the external ``apptainer pull`` so builds need no binary or network. + + Only the external command is replaced; ``create_sif_file``'s own logic (path + validation, parent-directory creation) still runs. The golden-master comparison + ignores ``.sif`` files, so a no-op suffices. Without this, building an Apptainer + module hard-fails on a runner without apptainer or does a real registry pull. + + Args: + monkeypatch: The pytest ``monkeypatch`` fixture. + """ + + def _no_pull(*args: object, **kwargs: object) -> None: + return None + + monkeypatch.setattr("deploy_tools.apptainer.run_command", _no_pull) diff --git a/tests/generate_samples.sh b/tests/generate_samples.sh index 84fbb75..14924c2 100755 --- a/tests/generate_samples.sh +++ b/tests/generate_samples.sh @@ -4,20 +4,74 @@ set -xe THIS_DIR=$(realpath $(dirname ${0})) SAMPLES_DIR=${THIS_DIR}/samples +CONFIGS_DIR=${THIS_DIR}/configs +GM_CONFIGS_DIR=${CONFIGS_DIR}/golden-master TMP_DIR=/tmp/deploy-tools-output rm -rf "${SAMPLES_DIR}" rm -rf "${TMP_DIR}" mkdir -p "${TMP_DIR}" -deploy-tools sync --from-scratch ${TMP_DIR} ${THIS_DIR}/../src/deploy_tools/demo_configuration +# Copy the current state of the deployment area into the samples directory as the golden +# master for the named lifecycle stage. Files that should not be committed are dropped +# from the copy only (not from the live area): .sif images are large and not +# reproducible, and .git/.gitignore belong to the deployment area's own history rather +# than its deployed content. The live area keeps its git repository so that the +# subsequent (non --from-scratch) syncs can run against it. +save_sample () { + local stage=${1} + local stage_dir=${SAMPLES_DIR}/${stage} -# don't keep the sif or git files -rm -rf $(find ${TMP_DIR} -name "*.sif") -rm -rf ${TMP_DIR}/.git* -# also remove binaries -rm ${TMP_DIR}/modules/argocd/*/entrypoints/argocd + mkdir -p "${stage_dir}" + cp -r "${TMP_DIR}" "${stage_dir}" -rm -rf ${SAMPLES_DIR} -mkdir -p ${SAMPLES_DIR} -cp -r ${TMP_DIR} ${SAMPLES_DIR} + local dest=${stage_dir}/$(basename ${TMP_DIR}) + find "${dest}" -name "*.sif" -delete + rm -rf "${dest}"/.git* +} + +# Capture the change summary that 'validate' prints for the upcoming sync. validate is +# read-only and previews the next sync, so it runs against the deployment area in its +# current (pre-sync) state. The 'set -x' trace goes to stderr, so only the summary is +# written to the file. +capture_validate () { + local stage=${1} + shift + mkdir -p "${SAMPLES_DIR}/${stage}" + deploy-tools validate "$@" "${TMP_DIR}" "${GM_CONFIGS_DIR}/${stage}" \ + > "${SAMPLES_DIR}/${stage}/validate.txt" +} + +# The lifecycle stages share a single deployment area and must run in order, as +# each stage builds on the previous deployment state. Only the first sync +# uses --from-scratch. See tests/test_golden_master.py for what each stage demonstrates. + +# Stage 1 +capture_validate 01-initial --from-scratch +deploy-tools sync --from-scratch "${TMP_DIR}" "${GM_CONFIGS_DIR}/01-initial" +save_sample 01-initial + +# Stage 2 +capture_validate 02-added +deploy-tools sync "${TMP_DIR}" "${GM_CONFIGS_DIR}/02-added" +save_sample 02-added + +# Stage 3 +capture_validate 03-updated +deploy-tools sync "${TMP_DIR}" "${GM_CONFIGS_DIR}/03-updated" +save_sample 03-updated + +# Stage 4 +capture_validate 04-deprecated +deploy-tools sync "${TMP_DIR}" "${GM_CONFIGS_DIR}/04-deprecated" +save_sample 04-deprecated + +# Stage 5 +capture_validate 05-restored +deploy-tools sync "${TMP_DIR}" "${GM_CONFIGS_DIR}/05-restored" +save_sample 05-restored + +# Stage 6 +capture_validate 06-removed +deploy-tools sync "${TMP_DIR}" "${GM_CONFIGS_DIR}/06-removed" +save_sample 06-removed diff --git a/tests/samples/01-initial/deploy-tools-output/deployment.yaml b/tests/samples/01-initial/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..368ad14 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/deployment.yaml @@ -0,0 +1,98 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Set at initial deployment + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '1.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '1.0' +settings: + default_versions: {} diff --git a/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/.version b/tests/samples/01-initial/deploy-tools-output/modulefiles/apps/.version similarity index 100% rename from tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/.version rename to tests/samples/01-initial/deploy-tools-output/modulefiles/apps/.version diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/01-initial/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/example-module-deps/.version b/tests/samples/01-initial/deploy-tools-output/modulefiles/deps/.version similarity index 100% rename from tests/samples/deploy-tools-output/modulefiles/example-module-deps/.version rename to tests/samples/01-initial/deploy-tools-output/modulefiles/deps/.version diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/01-initial/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/.version b/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/1.0 b/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/1.0 new file mode 120000 index 0000000..88618ed --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modulefiles/versions/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/cowsay-hello b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello similarity index 96% rename from tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/cowsay-hello rename to tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello index 8e6480e..d43f0d4 100755 --- a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/cowsay-hello +++ b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -7,7 +7,7 @@ set -e # Mounts for container -mounts="/dls_sw:/dls_sw_test:ro" +mounts="" # Additional arguments for apptainer apptainer_args="" # Sif file path diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/test-echo-module-folder b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var similarity index 100% rename from tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/test-echo-module-folder rename to tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/test-shell-script b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script similarity index 100% rename from tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/test-shell-script rename to tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/module.yaml b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/module.yaml similarity index 65% rename from tests/samples/deploy-tools-output/modules/example-module-apps/0.1/module.yaml rename to tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/module.yaml index 5f3ac87..60d6f70 100644 --- a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/module.yaml +++ b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/module.yaml @@ -12,21 +12,13 @@ applications: command_args: Hello host_binaries: [] mounts: [] - - command: ls - name: show-directory - options: - apptainer_args: '' - command_args: -al /dls_sw_test - host_binaries: [] - mounts: [] global_options: apptainer_args: '' command_args: '' host_binaries: [] - mounts: - - /dls_sw:/dls_sw_test:ro + mounts: [] - app_type: shell - name: test-echo-module-folder + name: test-echo-module-var script: - echo $OTHER_VALUE - app_type: shell @@ -36,12 +28,12 @@ applications: - echo and this is the second line. - echo Your input is ${1} dependencies: [] -description: Demonstration of a module configuration folder +description: Module demonstrating shell and Apptainer applications env_vars: - name: OTHER_VALUE - value: Test message OTHER_VALUE from example-module-folder + value: Version 0.1 exclude_from_defaults: false load_script: [] -name: example-module-apps +name: apps unload_script: [] version: '0.1' diff --git a/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/example-module-deps/0.2/module.yaml b/tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/module.yaml similarity index 51% rename from tests/samples/deploy-tools-output/modules/example-module-deps/0.2/module.yaml rename to tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/module.yaml index d65d333..641f01a 100644 --- a/tests/samples/deploy-tools-output/modules/example-module-deps/0.2/module.yaml +++ b/tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/module.yaml @@ -1,14 +1,14 @@ allow_updates: false applications: [] dependencies: -- name: dls-pmac-control +- name: apps version: '0.1' -- name: example-module-apps - version: '0.1' -description: Demonstration of deploy-tools dependencies +- name: external-module + version: null +description: Module demonstrating dependencies env_vars: [] exclude_from_defaults: false load_script: [] -name: example-module-deps +name: deps unload_script: [] version: '0.2' diff --git a/tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-login b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo similarity index 52% rename from tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-login rename to tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo index 71ebeae..a384ba3 100755 --- a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-login +++ b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -4,5 +4,4 @@ if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then set -x fi -argocd login argocd.diamond.ac.uk --grpc-web --sso -kubectl version +echo $UPDATABLE_VALUE diff --git a/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..7c85e7b --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Set at initial deployment +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..a1da9b1 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Set at initial deployment" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/module.yaml b/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/module.yaml new file mode 100644 index 0000000..d77ef37 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '1.0' diff --git a/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/modulefile b/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/modulefile new file mode 100644 index 0000000..e9a94d5 --- /dev/null +++ b/tests/samples/01-initial/deploy-tools-output/modules/versions/1.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/1.0/entrypoints" diff --git a/tests/samples/01-initial/validate.txt b/tests/samples/01-initial/validate.txt new file mode 100644 index 0000000..6e5adaf --- /dev/null +++ b/tests/samples/01-initial/validate.txt @@ -0,0 +1,11 @@ +Modules to be deployed: +apps/0.1 +deps/0.2 +updatable/1.0 +versions/1.0 + +Updated module defaults: +apps None -> 0.1 +deps None -> 0.2 +updatable None -> 1.0 +versions None -> 1.0 diff --git a/tests/samples/02-added/deploy-tools-output/deployment.yaml b/tests/samples/02-added/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..9270aa7 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/deployment.yaml @@ -0,0 +1,124 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Set at initial deployment + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '1.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '1.0' + '2.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '2.0' + 2.1rc1: + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: true + load_script: [] + name: versions + unload_script: [] + version: 2.1rc1 +settings: + default_versions: {} diff --git a/tests/samples/deploy-tools-output/modulefiles/edge-containers-cli/.version b/tests/samples/02-added/deploy-tools-output/modulefiles/apps/.version similarity index 100% rename from tests/samples/deploy-tools-output/modulefiles/edge-containers-cli/.version rename to tests/samples/02-added/deploy-tools-output/modulefiles/apps/.version diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/02-added/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/deps/.version b/tests/samples/02-added/deploy-tools-output/modulefiles/deps/.version new file mode 100644 index 0000000..26a66b4 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/deps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.2 diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/02-added/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/versions/.version b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..5d5fbb6 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 2.0 diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/versions/1.0 b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/1.0 new file mode 120000 index 0000000..88618ed --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.0 b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.0 new file mode 120000 index 0000000..b0c4f47 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.0/modulefile \ No newline at end of file diff --git a/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.1rc1 b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.1rc1 new file mode 120000 index 0000000..10b125b --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modulefiles/versions/2.1rc1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.1rc1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/show-directory b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello similarity index 92% rename from tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/show-directory rename to tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello index 111f5a5..d43f0d4 100755 --- a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/entrypoints/show-directory +++ b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -7,15 +7,15 @@ set -e # Mounts for container -mounts="/dls_sw:/dls_sw_test:ro" +mounts="" # Additional arguments for apptainer apptainer_args="" # Sif file path sif_file="$(dirname $0)/../sif_files/a553018b87553334a94c33cb04eb025c.sif" # Command to run in container -command="ls" +command="cowsay" # Options and arguments to pass to command -command_args="-al /dls_sw_test" +command_args="Hello" # Raise an error if sif file does not exist if [[ ! -f ${sif_file} ]]; then diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/test-echo-module-file b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var similarity index 78% rename from tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/test-echo-module-file rename to tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var index 6da99f6..0a367dd 100755 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/test-echo-module-file +++ b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var @@ -4,4 +4,4 @@ if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then set -x fi -echo $EXAMPLE_VALUE +echo $OTHER_VALUE diff --git a/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script new file mode 100755 index 0000000..6ca6871 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script @@ -0,0 +1,9 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo This is the first line of a shell script +echo and this is the second line. +echo Your input is ${1} diff --git a/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/module.yaml new file mode 100644 index 0000000..60d6f70 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/module.yaml @@ -0,0 +1,39 @@ +allow_updates: false +applications: +- app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] +- app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE +- app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} +dependencies: [] +description: Module demonstrating shell and Apptainer applications +env_vars: +- name: OTHER_VALUE + value: Version 0.1 +exclude_from_defaults: false +load_script: [] +name: apps +unload_script: [] +version: '0.1' diff --git a/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/module.yaml new file mode 100644 index 0000000..641f01a --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/module.yaml @@ -0,0 +1,14 @@ +allow_updates: false +applications: [] +dependencies: +- name: apps + version: '0.1' +- name: external-module + version: null +description: Module demonstrating dependencies +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: deps +unload_script: [] +version: '0.2' diff --git a/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo new file mode 100755 index 0000000..a384ba3 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $UPDATABLE_VALUE diff --git a/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..7c85e7b --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Set at initial deployment +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..a1da9b1 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Set at initial deployment" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/module.yaml new file mode 100644 index 0000000..d77ef37 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '1.0' diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/modulefile b/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/modulefile new file mode 100644 index 0000000..e9a94d5 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/1.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/1.0/entrypoints" diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/module.yaml new file mode 100644 index 0000000..470ad00 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '2.0' diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/modulefile b/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/modulefile new file mode 100644 index 0000000..0b0bd69 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/2.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.0/entrypoints" diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/module.yaml b/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/module.yaml new file mode 100644 index 0000000..490f83e --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: true +load_script: [] +name: versions +unload_script: [] +version: 2.1rc1 diff --git a/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/modulefile b/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/modulefile new file mode 100644 index 0000000..a92b432 --- /dev/null +++ b/tests/samples/02-added/deploy-tools-output/modules/versions/2.1rc1/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.1rc1/entrypoints" diff --git a/tests/samples/02-added/validate.txt b/tests/samples/02-added/validate.txt new file mode 100644 index 0000000..fd11578 --- /dev/null +++ b/tests/samples/02-added/validate.txt @@ -0,0 +1,6 @@ +Modules to be deployed: +versions/2.0 +versions/2.1rc1 + +Updated module defaults: +versions 1.0 -> 2.0 diff --git a/tests/samples/03-updated/deploy-tools-output/deployment.yaml b/tests/samples/03-updated/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..d2064d2 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/deployment.yaml @@ -0,0 +1,124 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Updated in a later sync + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '1.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '1.0' + '2.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '2.0' + 2.1rc1: + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: true + load_script: [] + name: versions + unload_script: [] + version: 2.1rc1 +settings: + default_versions: {} diff --git a/tests/samples/deploy-tools-output/modulefiles/example-module-apps/.version b/tests/samples/03-updated/deploy-tools-output/modulefiles/apps/.version similarity index 100% rename from tests/samples/deploy-tools-output/modulefiles/example-module-apps/.version rename to tests/samples/03-updated/deploy-tools-output/modulefiles/apps/.version diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/03-updated/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/.version b/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/.version new file mode 100644 index 0000000..26a66b4 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.2 diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/.version b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..5d5fbb6 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 2.0 diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/1.0 b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/1.0 new file mode 120000 index 0000000..88618ed --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.0 b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.0 new file mode 120000 index 0000000..b0c4f47 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.0/modulefile \ No newline at end of file diff --git a/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.1rc1 b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.1rc1 new file mode 120000 index 0000000..10b125b --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modulefiles/versions/2.1rc1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.1rc1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/dls-pmac-control b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello similarity index 85% rename from tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/dls-pmac-control rename to tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello index e09f6b4..d43f0d4 100755 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints/dls-pmac-control +++ b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -9,13 +9,13 @@ set -e # Mounts for container mounts="" # Additional arguments for apptainer -apptainer_args="-e" +apptainer_args="" # Sif file path -sif_file="$(dirname $0)/../sif_files/a2c305dc6e8732efbb76b32c89f884f4.sif" +sif_file="$(dirname $0)/../sif_files/a553018b87553334a94c33cb04eb025c.sif" # Command to run in container -command="dls-pmac-control" +command="cowsay" # Options and arguments to pass to command -command_args="" +command_args="Hello" # Raise an error if sif file does not exist if [[ ! -f ${sif_file} ]]; then diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/test-echo-module-file b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var similarity index 78% rename from tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/test-echo-module-file rename to tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var index 6da99f6..0a367dd 100755 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/test-echo-module-file +++ b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var @@ -4,4 +4,4 @@ if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then set -x fi -echo $EXAMPLE_VALUE +echo $OTHER_VALUE diff --git a/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script new file mode 100755 index 0000000..6ca6871 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script @@ -0,0 +1,9 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo This is the first line of a shell script +echo and this is the second line. +echo Your input is ${1} diff --git a/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/module.yaml new file mode 100644 index 0000000..60d6f70 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/module.yaml @@ -0,0 +1,39 @@ +allow_updates: false +applications: +- app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] +- app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE +- app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} +dependencies: [] +description: Module demonstrating shell and Apptainer applications +env_vars: +- name: OTHER_VALUE + value: Version 0.1 +exclude_from_defaults: false +load_script: [] +name: apps +unload_script: [] +version: '0.1' diff --git a/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/module.yaml new file mode 100644 index 0000000..641f01a --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/module.yaml @@ -0,0 +1,14 @@ +allow_updates: false +applications: [] +dependencies: +- name: apps + version: '0.1' +- name: external-module + version: null +description: Module demonstrating dependencies +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: deps +unload_script: [] +version: '0.2' diff --git a/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo new file mode 100755 index 0000000..a384ba3 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $UPDATABLE_VALUE diff --git a/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..8b7a035 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Updated in a later sync +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..b866060 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Updated in a later sync" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/module.yaml new file mode 100644 index 0000000..d77ef37 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '1.0' diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/modulefile new file mode 100644 index 0000000..e9a94d5 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/1.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/1.0/entrypoints" diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/module.yaml new file mode 100644 index 0000000..470ad00 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '2.0' diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/modulefile new file mode 100644 index 0000000..0b0bd69 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.0/entrypoints" diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/module.yaml b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/module.yaml new file mode 100644 index 0000000..490f83e --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: true +load_script: [] +name: versions +unload_script: [] +version: 2.1rc1 diff --git a/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/modulefile b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/modulefile new file mode 100644 index 0000000..a92b432 --- /dev/null +++ b/tests/samples/03-updated/deploy-tools-output/modules/versions/2.1rc1/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.1rc1/entrypoints" diff --git a/tests/samples/03-updated/validate.txt b/tests/samples/03-updated/validate.txt new file mode 100644 index 0000000..f2ea192 --- /dev/null +++ b/tests/samples/03-updated/validate.txt @@ -0,0 +1,4 @@ +Modules to be updated: +updatable/1.0 + +No default version changes diff --git a/tests/samples/04-deprecated/deploy-tools-output/deployment.yaml b/tests/samples/04-deprecated/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..df83de8 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/deployment.yaml @@ -0,0 +1,124 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Updated in a later sync + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '1.0': + deprecated: true + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '1.0' + '2.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '2.0' + 2.1rc1: + deprecated: true + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: true + load_script: [] + name: versions + unload_script: [] + version: 2.1rc1 +settings: + default_versions: {} diff --git a/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/1.0 b/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/1.0 new file mode 120000 index 0000000..88618ed --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/2.1rc1 b/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/2.1rc1 new file mode 120000 index 0000000..10b125b --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/deprecated/modulefiles/versions/2.1rc1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.1rc1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/phoebus/.version b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/apps/.version similarity index 100% rename from tests/samples/deploy-tools-output/modulefiles/phoebus/.version rename to tests/samples/04-deprecated/deploy-tools-output/modulefiles/apps/.version diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/.version b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/.version new file mode 100644 index 0000000..26a66b4 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.2 diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/.version b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..5d5fbb6 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 2.0 diff --git a/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/2.0 b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/2.0 new file mode 120000 index 0000000..b0c4f47 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modulefiles/versions/2.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.0/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/dls-pmac-control b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello similarity index 85% rename from tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/dls-pmac-control rename to tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello index e09f6b4..d43f0d4 100755 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints/dls-pmac-control +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -9,13 +9,13 @@ set -e # Mounts for container mounts="" # Additional arguments for apptainer -apptainer_args="-e" +apptainer_args="" # Sif file path -sif_file="$(dirname $0)/../sif_files/a2c305dc6e8732efbb76b32c89f884f4.sif" +sif_file="$(dirname $0)/../sif_files/a553018b87553334a94c33cb04eb025c.sif" # Command to run in container -command="dls-pmac-control" +command="cowsay" # Options and arguments to pass to command -command_args="" +command_args="Hello" # Raise an error if sif file does not exist if [[ ! -f ${sif_file} ]]; then diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var new file mode 100755 index 0000000..0a367dd --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $OTHER_VALUE diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script new file mode 100755 index 0000000..6ca6871 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script @@ -0,0 +1,9 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo This is the first line of a shell script +echo and this is the second line. +echo Your input is ${1} diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/module.yaml new file mode 100644 index 0000000..60d6f70 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/module.yaml @@ -0,0 +1,39 @@ +allow_updates: false +applications: +- app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] +- app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE +- app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} +dependencies: [] +description: Module demonstrating shell and Apptainer applications +env_vars: +- name: OTHER_VALUE + value: Version 0.1 +exclude_from_defaults: false +load_script: [] +name: apps +unload_script: [] +version: '0.1' diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/module.yaml new file mode 100644 index 0000000..641f01a --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/module.yaml @@ -0,0 +1,14 @@ +allow_updates: false +applications: [] +dependencies: +- name: apps + version: '0.1' +- name: external-module + version: null +description: Module demonstrating dependencies +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: deps +unload_script: [] +version: '0.2' diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo new file mode 100755 index 0000000..a384ba3 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $UPDATABLE_VALUE diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..8b7a035 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Updated in a later sync +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..b866060 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Updated in a later sync" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/module.yaml new file mode 100644 index 0000000..d77ef37 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '1.0' diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/modulefile new file mode 100644 index 0000000..e9a94d5 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/1.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/1.0/entrypoints" diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/module.yaml new file mode 100644 index 0000000..470ad00 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '2.0' diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/modulefile new file mode 100644 index 0000000..0b0bd69 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.0/entrypoints" diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/module.yaml b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/module.yaml new file mode 100644 index 0000000..490f83e --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: true +load_script: [] +name: versions +unload_script: [] +version: 2.1rc1 diff --git a/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/modulefile b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/modulefile new file mode 100644 index 0000000..a92b432 --- /dev/null +++ b/tests/samples/04-deprecated/deploy-tools-output/modules/versions/2.1rc1/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.1rc1/entrypoints" diff --git a/tests/samples/04-deprecated/validate.txt b/tests/samples/04-deprecated/validate.txt new file mode 100644 index 0000000..c26ad18 --- /dev/null +++ b/tests/samples/04-deprecated/validate.txt @@ -0,0 +1,5 @@ +Modules to be deprecated: +versions/1.0 +versions/2.1rc1 + +No default version changes diff --git a/tests/samples/05-restored/deploy-tools-output/deployment.yaml b/tests/samples/05-restored/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..869b8d2 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/deployment.yaml @@ -0,0 +1,124 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Updated in a later sync + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '1.0': + deprecated: true + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '1.0' + '2.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '2.0' + 2.1rc1: + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: true + load_script: [] + name: versions + unload_script: [] + version: 2.1rc1 +settings: + default_versions: {} diff --git a/tests/samples/05-restored/deploy-tools-output/deprecated/modulefiles/versions/1.0 b/tests/samples/05-restored/deploy-tools-output/deprecated/modulefiles/versions/1.0 new file mode 120000 index 0000000..88618ed --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/deprecated/modulefiles/versions/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/.version b/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/.version new file mode 100644 index 0000000..d9b8f92 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.1 diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/.version b/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/.version new file mode 100644 index 0000000..26a66b4 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.2 diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/.version b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..5d5fbb6 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 2.0 diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.0 b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.0 new file mode 120000 index 0000000..b0c4f47 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.0/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.1rc1 b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.1rc1 new file mode 120000 index 0000000..10b125b --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modulefiles/versions/2.1rc1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.1rc1/modulefile \ No newline at end of file diff --git a/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello new file mode 100755 index 0000000..d43f0d4 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -0,0 +1,44 @@ +#! /bin/bash + +# Arguments: +# ${@} = Remaining args to pass to the command + +# Halt on error +set -e + +# Mounts for container +mounts="" +# Additional arguments for apptainer +apptainer_args="" +# Sif file path +sif_file="$(dirname $0)/../sif_files/a553018b87553334a94c33cb04eb025c.sif" +# Command to run in container +command="cowsay" +# Options and arguments to pass to command +command_args="Hello" + +# Raise an error if sif file does not exist +if [[ ! -f ${sif_file} ]]; then + echo "ERROR: sif file ${sif_file} does not exist" 1>&2 + exit 1 +fi + +# add mounts of host binaries into /usr/bin +for i in ; do + binary=$(which $i) + mounts="${mounts},${binary}:/usr/bin/${i}" +done + +# Set up mounts if any have been configured +if [[ ! -z ${mounts} ]]; then + opts="-B ${mounts}" +fi + +opts=${opts}" --env DISPLAY=${DISPLAY}" +opts=${opts}" ${apptainer_args}" + + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi +apptainer exec ${opts} ${sif_file} ${command} ${command_args} "${@}" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var new file mode 100755 index 0000000..0a367dd --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $OTHER_VALUE diff --git a/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script new file mode 100755 index 0000000..6ca6871 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script @@ -0,0 +1,9 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo This is the first line of a shell script +echo and this is the second line. +echo Your input is ${1} diff --git a/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/module.yaml new file mode 100644 index 0000000..60d6f70 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/module.yaml @@ -0,0 +1,39 @@ +allow_updates: false +applications: +- app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] +- app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE +- app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} +dependencies: [] +description: Module demonstrating shell and Apptainer applications +env_vars: +- name: OTHER_VALUE + value: Version 0.1 +exclude_from_defaults: false +load_script: [] +name: apps +unload_script: [] +version: '0.1' diff --git a/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/module.yaml new file mode 100644 index 0000000..641f01a --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/module.yaml @@ -0,0 +1,14 @@ +allow_updates: false +applications: [] +dependencies: +- name: apps + version: '0.1' +- name: external-module + version: null +description: Module demonstrating dependencies +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: deps +unload_script: [] +version: '0.2' diff --git a/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo new file mode 100755 index 0000000..a384ba3 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $UPDATABLE_VALUE diff --git a/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..8b7a035 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Updated in a later sync +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..b866060 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Updated in a later sync" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/module.yaml new file mode 100644 index 0000000..d77ef37 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '1.0' diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/modulefile new file mode 100644 index 0000000..e9a94d5 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/1.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/1.0/entrypoints" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/module.yaml new file mode 100644 index 0000000..470ad00 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '2.0' diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/modulefile new file mode 100644 index 0000000..0b0bd69 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.0/entrypoints" diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/module.yaml b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/module.yaml new file mode 100644 index 0000000..490f83e --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: true +load_script: [] +name: versions +unload_script: [] +version: 2.1rc1 diff --git a/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/modulefile b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/modulefile new file mode 100644 index 0000000..a92b432 --- /dev/null +++ b/tests/samples/05-restored/deploy-tools-output/modules/versions/2.1rc1/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.1rc1/entrypoints" diff --git a/tests/samples/05-restored/validate.txt b/tests/samples/05-restored/validate.txt new file mode 100644 index 0000000..4aef44b --- /dev/null +++ b/tests/samples/05-restored/validate.txt @@ -0,0 +1,4 @@ +Modules to be restored: +versions/2.1rc1 + +No default version changes diff --git a/tests/samples/06-removed/deploy-tools-output/deployment.yaml b/tests/samples/06-removed/deploy-tools-output/deployment.yaml new file mode 100644 index 0000000..c2972e0 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/deployment.yaml @@ -0,0 +1,111 @@ +releases: + apps: + '0.1': + deprecated: false + module: + allow_updates: false + applications: + - app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] + - app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE + - app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} + dependencies: [] + description: Module demonstrating shell and Apptainer applications + env_vars: + - name: OTHER_VALUE + value: Version 0.1 + exclude_from_defaults: false + load_script: [] + name: apps + unload_script: [] + version: '0.1' + deps: + '0.2': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: + - name: apps + version: '0.1' + - name: external-module + version: null + description: Module demonstrating dependencies + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: deps + unload_script: [] + version: '0.2' + updatable: + '1.0': + deprecated: false + module: + allow_updates: true + applications: + - app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE + dependencies: [] + description: Module demonstrating in-place updates (allow_updates) + env_vars: + - name: UPDATABLE_VALUE + value: Updated in a later sync + exclude_from_defaults: false + load_script: [] + name: updatable + unload_script: [] + version: '1.0' + versions: + '2.0': + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: false + load_script: [] + name: versions + unload_script: [] + version: '2.0' + 2.1rc1: + deprecated: false + module: + allow_updates: false + applications: [] + dependencies: [] + description: Module demonstrating multiple versions and default-version selection + env_vars: [] + exclude_from_defaults: true + load_script: [] + name: versions + unload_script: [] + version: 2.1rc1 +settings: + default_versions: {} diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/.version b/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/.version new file mode 100644 index 0000000..d9b8f92 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.1 diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/0.1 b/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/0.1 new file mode 120000 index 0000000..69615f9 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/apps/0.1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/.version b/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/.version new file mode 100644 index 0000000..26a66b4 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 0.2 diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/0.2 b/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/0.2 new file mode 120000 index 0000000..5d82a76 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/deps/0.2 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/.version b/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/.version new file mode 100644 index 0000000..f0d5543 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 1.0 diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/1.0 b/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/1.0 new file mode 120000 index 0000000..bd2fb2b --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/updatable/1.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/updatable/1.0/modulefile \ No newline at end of file diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/.version b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/.version new file mode 100644 index 0000000..5d5fbb6 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/.version @@ -0,0 +1,2 @@ +#%Module1.0 +set ModulesVersion 2.0 diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.0 b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.0 new file mode 120000 index 0000000..b0c4f47 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.0 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.0/modulefile \ No newline at end of file diff --git a/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.1rc1 b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.1rc1 new file mode 120000 index 0000000..10b125b --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modulefiles/versions/2.1rc1 @@ -0,0 +1 @@ +/tmp/deploy-tools-output/modules/versions/2.1rc1/modulefile \ No newline at end of file diff --git a/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello new file mode 100755 index 0000000..d43f0d4 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/cowsay-hello @@ -0,0 +1,44 @@ +#! /bin/bash + +# Arguments: +# ${@} = Remaining args to pass to the command + +# Halt on error +set -e + +# Mounts for container +mounts="" +# Additional arguments for apptainer +apptainer_args="" +# Sif file path +sif_file="$(dirname $0)/../sif_files/a553018b87553334a94c33cb04eb025c.sif" +# Command to run in container +command="cowsay" +# Options and arguments to pass to command +command_args="Hello" + +# Raise an error if sif file does not exist +if [[ ! -f ${sif_file} ]]; then + echo "ERROR: sif file ${sif_file} does not exist" 1>&2 + exit 1 +fi + +# add mounts of host binaries into /usr/bin +for i in ; do + binary=$(which $i) + mounts="${mounts},${binary}:/usr/bin/${i}" +done + +# Set up mounts if any have been configured +if [[ ! -z ${mounts} ]]; then + opts="-B ${mounts}" +fi + +opts=${opts}" --env DISPLAY=${DISPLAY}" +opts=${opts}" ${apptainer_args}" + + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi +apptainer exec ${opts} ${sif_file} ${command} ${command_args} "${@}" diff --git a/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var new file mode 100755 index 0000000..0a367dd --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-echo-module-var @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $OTHER_VALUE diff --git a/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script new file mode 100755 index 0000000..6ca6871 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/entrypoints/test-shell-script @@ -0,0 +1,9 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo This is the first line of a shell script +echo and this is the second line. +echo Your input is ${1} diff --git a/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/module.yaml b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/module.yaml new file mode 100644 index 0000000..60d6f70 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/module.yaml @@ -0,0 +1,39 @@ +allow_updates: false +applications: +- app_type: apptainer + container: + path: docker://ghcr.io/apptainer/lolcow + version: latest + entrypoints: + - command: cowsay + name: cowsay-hello + options: + apptainer_args: '' + command_args: Hello + host_binaries: [] + mounts: [] + global_options: + apptainer_args: '' + command_args: '' + host_binaries: [] + mounts: [] +- app_type: shell + name: test-echo-module-var + script: + - echo $OTHER_VALUE +- app_type: shell + name: test-shell-script + script: + - echo This is the first line of a shell script + - echo and this is the second line. + - echo Your input is ${1} +dependencies: [] +description: Module demonstrating shell and Apptainer applications +env_vars: +- name: OTHER_VALUE + value: Version 0.1 +exclude_from_defaults: false +load_script: [] +name: apps +unload_script: [] +version: '0.1' diff --git a/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/modulefile b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/modulefile new file mode 100644 index 0000000..9aefe70 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/apps/0.1/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## apps - Module demonstrating shell and Apptainer applications +## +module-whatis "Module demonstrating shell and Apptainer applications" + +if { [module-info mode load] } { + if { [is-loaded apps] } { + module unload apps + } +} + +setenv OTHER_VALUE "Version 0.1" + +prepend-path PATH "/tmp/deploy-tools-output/modules/apps/0.1/entrypoints" diff --git a/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/module.yaml b/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/module.yaml new file mode 100644 index 0000000..641f01a --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/module.yaml @@ -0,0 +1,14 @@ +allow_updates: false +applications: [] +dependencies: +- name: apps + version: '0.1' +- name: external-module + version: null +description: Module demonstrating dependencies +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: deps +unload_script: [] +version: '0.2' diff --git a/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/modulefile b/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/modulefile new file mode 100644 index 0000000..56e1061 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/deps/0.2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 +## +## deps - Module demonstrating dependencies +## +module-whatis "Module demonstrating dependencies" + +if { [module-info mode load] } { + if { [is-loaded deps] } { + module unload deps + } +} + +module load apps/0.1 +module load external-module + +prepend-path PATH "/tmp/deploy-tools-output/modules/deps/0.2/entrypoints" diff --git a/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo new file mode 100755 index 0000000..a384ba3 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/entrypoints/test-updatable-echo @@ -0,0 +1,7 @@ +#! /bin/bash + +if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then + set -x +fi + +echo $UPDATABLE_VALUE diff --git a/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/module.yaml b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/module.yaml new file mode 100644 index 0000000..8b7a035 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/module.yaml @@ -0,0 +1,16 @@ +allow_updates: true +applications: +- app_type: shell + name: test-updatable-echo + script: + - echo $UPDATABLE_VALUE +dependencies: [] +description: Module demonstrating in-place updates (allow_updates) +env_vars: +- name: UPDATABLE_VALUE + value: Updated in a later sync +exclude_from_defaults: false +load_script: [] +name: updatable +unload_script: [] +version: '1.0' diff --git a/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/modulefile b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/modulefile new file mode 100644 index 0000000..b866060 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/updatable/1.0/modulefile @@ -0,0 +1,15 @@ +#%Module1.0 +## +## updatable - Module demonstrating in-place updates (allow_updates) +## +module-whatis "Module demonstrating in-place updates (allow_updates)" + +if { [module-info mode load] } { + if { [is-loaded updatable] } { + module unload updatable + } +} + +setenv UPDATABLE_VALUE "Updated in a later sync" + +prepend-path PATH "/tmp/deploy-tools-output/modules/updatable/1.0/entrypoints" diff --git a/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/module.yaml b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/module.yaml new file mode 100644 index 0000000..470ad00 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: false +load_script: [] +name: versions +unload_script: [] +version: '2.0' diff --git a/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/modulefile b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/modulefile new file mode 100644 index 0000000..0b0bd69 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.0/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.0/entrypoints" diff --git a/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/module.yaml b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/module.yaml new file mode 100644 index 0000000..490f83e --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/module.yaml @@ -0,0 +1,10 @@ +allow_updates: false +applications: [] +dependencies: [] +description: Module demonstrating multiple versions and default-version selection +env_vars: [] +exclude_from_defaults: true +load_script: [] +name: versions +unload_script: [] +version: 2.1rc1 diff --git a/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/modulefile b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/modulefile new file mode 100644 index 0000000..a92b432 --- /dev/null +++ b/tests/samples/06-removed/deploy-tools-output/modules/versions/2.1rc1/modulefile @@ -0,0 +1,13 @@ +#%Module1.0 +## +## versions - Module demonstrating multiple versions and default-version selection +## +module-whatis "Module demonstrating multiple versions and default-version selection" + +if { [module-info mode load] } { + if { [is-loaded versions] } { + module unload versions + } +} + +prepend-path PATH "/tmp/deploy-tools-output/modules/versions/2.1rc1/entrypoints" diff --git a/tests/samples/06-removed/validate.txt b/tests/samples/06-removed/validate.txt new file mode 100644 index 0000000..962cf72 --- /dev/null +++ b/tests/samples/06-removed/validate.txt @@ -0,0 +1,4 @@ +Modules to be removed: +versions/1.0 + +No default version changes diff --git a/tests/samples/deploy-tools-output/deployment.yaml b/tests/samples/deploy-tools-output/deployment.yaml deleted file mode 100644 index 4a0ee82..0000000 --- a/tests/samples/deploy-tools-output/deployment.yaml +++ /dev/null @@ -1,299 +0,0 @@ -releases: - argocd: - v2.14.10: - deprecated: false - module: - allow_updates: false - applications: - - app_type: binary - hash: d1750274a336f0a090abf196a832cee14cb9f1c2fc3d20d80b0dbfeff83550fa - hash_type: sha256 - name: argocd - url: https://github.com/argoproj/argo-cd/releases/download/v2.14.10/argocd-linux-amd64 - dependencies: [] - description: Demonstration of binary download - env_vars: [] - exclude_from_defaults: false - load_script: [] - name: argocd - unload_script: [] - version: v2.14.10 - dls-pmac-control: - '0.1': - deprecated: false - module: - allow_updates: false - applications: - - app_type: apptainer - container: - path: docker://ghcr.io/diamondlightsource/dls-pmac-control - version: 3.2.0b1 - entrypoints: - - command: dls-pmac-control - name: dls-pmac-control - options: - apptainer_args: -e - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - - app_type: shell - name: test-echo-module-file - script: - - echo $EXAMPLE_VALUE - dependencies: [] - description: Demonstration of the deploy-tools process - env_vars: - - name: EXAMPLE_VALUE - value: Test message EXAMPLE_VALUE from example-module-file version 0.1 - exclude_from_defaults: false - load_script: [] - name: dls-pmac-control - unload_script: [] - version: '0.1' - '0.2': - deprecated: false - module: - allow_updates: false - applications: - - app_type: apptainer - container: - path: docker://ghcr.io/diamondlightsource/dls-pmac-control - version: 3.2.0b1 - entrypoints: - - command: dls-pmac-control - name: dls-pmac-control - options: - apptainer_args: -e - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - - app_type: shell - name: test-echo-module-file - script: - - echo $EXAMPLE_VALUE - dependencies: [] - description: Demonstration of the deploy-tools process - env_vars: - - name: EXAMPLE_VALUE - value: Test message EXAMPLE_VALUE from example-module-file version 0.2 - exclude_from_defaults: false - load_script: [] - name: dls-pmac-control - unload_script: [] - version: '0.2' - ec: - i13-1: - deprecated: false - module: - allow_updates: false - applications: [] - dependencies: - - name: edge-containers-cli - version: null - - name: k8s-i13-1 - version: local - description: ec command line tool configured for i13-1 - env_vars: - - name: EC_TARGET - value: i13-1-beamline/i13-1 - - name: EC_SERVICES_REPO - value: https://gitlab.diamond.ac.uk/controls/containers/beamline/i13-1-services.git - exclude_from_defaults: false - load_script: [] - name: ec - unload_script: [] - version: i13-1 - p47: - deprecated: false - module: - allow_updates: false - applications: [] - dependencies: - - name: edge-containers-cli - version: '0.1' - - name: pollux - version: local - description: ec command line tool configured for p47 - env_vars: - - name: EC_TARGET - value: p47-beamline/p47 - - name: EC_SERVICES_REPO - value: https://github.com/epics-containers/p47-services - exclude_from_defaults: false - load_script: [] - name: ec - unload_script: [] - version: p47 - edge-containers-cli: - '0.1': - deprecated: false - module: - allow_updates: false - applications: - - app_type: apptainer - container: - path: docker://ghcr.io/epics-containers/edge-containers-cli - version: 4.4.1 - entrypoints: - - command: ec - name: ec - options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - - command: bash - name: ec-bash - options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: - - argocd - - kubectl - - helm - - kubelogin - - klogout - - kustomize - - kubeseal - - kubectl-oidc_login - mounts: - - /dls/science/users/:/dls/science/users/ - - /scratch:/scratch - - /dls_sw/apps:/dls_sw/apps - - app_type: shell - name: ec-login - script: - - argocd login argocd.diamond.ac.uk --grpc-web --sso - - kubectl version - dependencies: - - name: argocd - version: v2.14.10 - description: ec command line tool for kubernetes IOCs - env_vars: - - name: EC_CLI_BACKEND - value: ARGOCD - - name: EC_LOG_URL - value: https://graylog.diamond.ac.uk/search?rangetype=relative&fields=message%2Csource&width=1489&highlightMessage=&relative=172800&q=pod_name%3A{service_name}* - exclude_from_defaults: false - load_script: [] - name: edge-containers-cli - unload_script: [] - version: '0.1' - example-module-apps: - '0.1': - deprecated: false - module: - allow_updates: false - applications: - - app_type: apptainer - container: - path: docker://ghcr.io/apptainer/lolcow - version: latest - entrypoints: - - command: cowsay - name: cowsay-hello - options: - apptainer_args: '' - command_args: Hello - host_binaries: [] - mounts: [] - - command: ls - name: show-directory - options: - apptainer_args: '' - command_args: -al /dls_sw_test - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: - - /dls_sw:/dls_sw_test:ro - - app_type: shell - name: test-echo-module-folder - script: - - echo $OTHER_VALUE - - app_type: shell - name: test-shell-script - script: - - echo This is the first line of a shell script - - echo and this is the second line. - - echo Your input is ${1} - dependencies: [] - description: Demonstration of a module configuration folder - env_vars: - - name: OTHER_VALUE - value: Test message OTHER_VALUE from example-module-folder - exclude_from_defaults: false - load_script: [] - name: example-module-apps - unload_script: [] - version: '0.1' - example-module-deps: - '0.2': - deprecated: false - module: - allow_updates: false - applications: [] - dependencies: - - name: dls-pmac-control - version: '0.1' - - name: example-module-apps - version: '0.1' - description: Demonstration of deploy-tools dependencies - env_vars: [] - exclude_from_defaults: false - load_script: [] - name: example-module-deps - unload_script: [] - version: '0.2' - phoebus: - '0.1': - deprecated: false - module: - allow_updates: false - applications: - - app_type: apptainer - container: - path: docker://ghcr.io/epics-containers/ec-phoebus - version: 4.7.3ec2 - entrypoints: - - command: java -jar /phoebus/phoebus.jar -server 7010 - name: phoebus - options: - apptainer_args: --env DISPLAY=${DISPLAY} -e - command_args: -server 7010 - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - dependencies: [] - description: Containerised release of CSS Phoebus - env_vars: [] - exclude_from_defaults: false - load_script: [] - name: phoebus - unload_script: [] - version: '0.1' -settings: - default_versions: - dls-pmac-control: '0.1' diff --git a/tests/samples/deploy-tools-output/modulefiles/argocd/v2.14.10 b/tests/samples/deploy-tools-output/modulefiles/argocd/v2.14.10 deleted file mode 120000 index 40d562c..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/argocd/v2.14.10 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/argocd/v2.14.10/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.1 b/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.1 deleted file mode 120000 index 75b7024..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.1 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/dls-pmac-control/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.2 b/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.2 deleted file mode 120000 index 0c56729..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/dls-pmac-control/0.2 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/dls-pmac-control/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/ec/.version b/tests/samples/deploy-tools-output/modulefiles/ec/.version deleted file mode 100644 index 8c1a7aa..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/ec/.version +++ /dev/null @@ -1,2 +0,0 @@ -#%Module1.0 -set ModulesVersion p47 diff --git a/tests/samples/deploy-tools-output/modulefiles/ec/i13-1 b/tests/samples/deploy-tools-output/modulefiles/ec/i13-1 deleted file mode 120000 index b5348c5..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/ec/i13-1 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/ec/i13-1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/ec/p47 b/tests/samples/deploy-tools-output/modulefiles/ec/p47 deleted file mode 120000 index 0c2cf51..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/ec/p47 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/ec/p47/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/edge-containers-cli/0.1 b/tests/samples/deploy-tools-output/modulefiles/edge-containers-cli/0.1 deleted file mode 120000 index 00b90c0..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/edge-containers-cli/0.1 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/edge-containers-cli/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/example-module-apps/0.1 b/tests/samples/deploy-tools-output/modulefiles/example-module-apps/0.1 deleted file mode 120000 index 53b9057..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/example-module-apps/0.1 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/example-module-apps/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/example-module-deps/0.2 b/tests/samples/deploy-tools-output/modulefiles/example-module-deps/0.2 deleted file mode 120000 index cd04ecd..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/example-module-deps/0.2 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/example-module-deps/0.2/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modulefiles/phoebus/0.1 b/tests/samples/deploy-tools-output/modulefiles/phoebus/0.1 deleted file mode 120000 index 5468b29..0000000 --- a/tests/samples/deploy-tools-output/modulefiles/phoebus/0.1 +++ /dev/null @@ -1 +0,0 @@ -/tmp/deploy-tools-output/modules/phoebus/0.1/modulefile \ No newline at end of file diff --git a/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/module.yaml b/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/module.yaml deleted file mode 100644 index 9cb7ad7..0000000 --- a/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/module.yaml +++ /dev/null @@ -1,15 +0,0 @@ -allow_updates: false -applications: -- app_type: binary - hash: d1750274a336f0a090abf196a832cee14cb9f1c2fc3d20d80b0dbfeff83550fa - hash_type: sha256 - name: argocd - url: https://github.com/argoproj/argo-cd/releases/download/v2.14.10/argocd-linux-amd64 -dependencies: [] -description: Demonstration of binary download -env_vars: [] -exclude_from_defaults: false -load_script: [] -name: argocd -unload_script: [] -version: v2.14.10 diff --git a/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/modulefile b/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/modulefile deleted file mode 100644 index a4ef6d6..0000000 --- a/tests/samples/deploy-tools-output/modules/argocd/v2.14.10/modulefile +++ /dev/null @@ -1,13 +0,0 @@ -#%Module1.0 -## -## argocd - Demonstration of binary download -## -module-whatis "Demonstration of binary download" - -if { [module-info mode load] } { - if { [is-loaded argocd] } { - module unload argocd - } -} - -prepend-path PATH "/tmp/deploy-tools-output/modules/argocd/v2.14.10/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/module.yaml b/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/module.yaml deleted file mode 100644 index 0f59a15..0000000 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/module.yaml +++ /dev/null @@ -1,33 +0,0 @@ -allow_updates: false -applications: -- app_type: apptainer - container: - path: docker://ghcr.io/diamondlightsource/dls-pmac-control - version: 3.2.0b1 - entrypoints: - - command: dls-pmac-control - name: dls-pmac-control - options: - apptainer_args: -e - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] -- app_type: shell - name: test-echo-module-file - script: - - echo $EXAMPLE_VALUE -dependencies: [] -description: Demonstration of the deploy-tools process -env_vars: -- name: EXAMPLE_VALUE - value: Test message EXAMPLE_VALUE from example-module-file version 0.1 -exclude_from_defaults: false -load_script: [] -name: dls-pmac-control -unload_script: [] -version: '0.1' diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/modulefile b/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/modulefile deleted file mode 100644 index fb4880c..0000000 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.1/modulefile +++ /dev/null @@ -1,15 +0,0 @@ -#%Module1.0 -## -## dls-pmac-control - Demonstration of the deploy-tools process -## -module-whatis "Demonstration of the deploy-tools process" - -if { [module-info mode load] } { - if { [is-loaded dls-pmac-control] } { - module unload dls-pmac-control - } -} - -setenv EXAMPLE_VALUE "Test message EXAMPLE_VALUE from example-module-file version 0.1" - -prepend-path PATH "/tmp/deploy-tools-output/modules/dls-pmac-control/0.1/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/module.yaml b/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/module.yaml deleted file mode 100644 index d00eb83..0000000 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/module.yaml +++ /dev/null @@ -1,33 +0,0 @@ -allow_updates: false -applications: -- app_type: apptainer - container: - path: docker://ghcr.io/diamondlightsource/dls-pmac-control - version: 3.2.0b1 - entrypoints: - - command: dls-pmac-control - name: dls-pmac-control - options: - apptainer_args: -e - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] -- app_type: shell - name: test-echo-module-file - script: - - echo $EXAMPLE_VALUE -dependencies: [] -description: Demonstration of the deploy-tools process -env_vars: -- name: EXAMPLE_VALUE - value: Test message EXAMPLE_VALUE from example-module-file version 0.2 -exclude_from_defaults: false -load_script: [] -name: dls-pmac-control -unload_script: [] -version: '0.2' diff --git a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/modulefile b/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/modulefile deleted file mode 100644 index 72f3dd9..0000000 --- a/tests/samples/deploy-tools-output/modules/dls-pmac-control/0.2/modulefile +++ /dev/null @@ -1,15 +0,0 @@ -#%Module1.0 -## -## dls-pmac-control - Demonstration of the deploy-tools process -## -module-whatis "Demonstration of the deploy-tools process" - -if { [module-info mode load] } { - if { [is-loaded dls-pmac-control] } { - module unload dls-pmac-control - } -} - -setenv EXAMPLE_VALUE "Test message EXAMPLE_VALUE from example-module-file version 0.2" - -prepend-path PATH "/tmp/deploy-tools-output/modules/dls-pmac-control/0.2/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/ec/i13-1/module.yaml b/tests/samples/deploy-tools-output/modules/ec/i13-1/module.yaml deleted file mode 100644 index 89d7b25..0000000 --- a/tests/samples/deploy-tools-output/modules/ec/i13-1/module.yaml +++ /dev/null @@ -1,18 +0,0 @@ -allow_updates: false -applications: [] -dependencies: -- name: edge-containers-cli - version: null -- name: k8s-i13-1 - version: local -description: ec command line tool configured for i13-1 -env_vars: -- name: EC_TARGET - value: i13-1-beamline/i13-1 -- name: EC_SERVICES_REPO - value: https://gitlab.diamond.ac.uk/controls/containers/beamline/i13-1-services.git -exclude_from_defaults: false -load_script: [] -name: ec -unload_script: [] -version: i13-1 diff --git a/tests/samples/deploy-tools-output/modules/ec/i13-1/modulefile b/tests/samples/deploy-tools-output/modules/ec/i13-1/modulefile deleted file mode 100644 index 1641182..0000000 --- a/tests/samples/deploy-tools-output/modules/ec/i13-1/modulefile +++ /dev/null @@ -1,19 +0,0 @@ -#%Module1.0 -## -## ec - ec command line tool configured for i13-1 -## -module-whatis "ec command line tool configured for i13-1" - -if { [module-info mode load] } { - if { [is-loaded ec] } { - module unload ec - } -} - -module load edge-containers-cli -module load k8s-i13-1/local - -setenv EC_TARGET "i13-1-beamline/i13-1" -setenv EC_SERVICES_REPO "https://gitlab.diamond.ac.uk/controls/containers/beamline/i13-1-services.git" - -prepend-path PATH "/tmp/deploy-tools-output/modules/ec/i13-1/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/ec/p47/module.yaml b/tests/samples/deploy-tools-output/modules/ec/p47/module.yaml deleted file mode 100644 index 73d6a8b..0000000 --- a/tests/samples/deploy-tools-output/modules/ec/p47/module.yaml +++ /dev/null @@ -1,18 +0,0 @@ -allow_updates: false -applications: [] -dependencies: -- name: edge-containers-cli - version: '0.1' -- name: pollux - version: local -description: ec command line tool configured for p47 -env_vars: -- name: EC_TARGET - value: p47-beamline/p47 -- name: EC_SERVICES_REPO - value: https://github.com/epics-containers/p47-services -exclude_from_defaults: false -load_script: [] -name: ec -unload_script: [] -version: p47 diff --git a/tests/samples/deploy-tools-output/modules/ec/p47/modulefile b/tests/samples/deploy-tools-output/modules/ec/p47/modulefile deleted file mode 100644 index 0f17b6b..0000000 --- a/tests/samples/deploy-tools-output/modules/ec/p47/modulefile +++ /dev/null @@ -1,19 +0,0 @@ -#%Module1.0 -## -## ec - ec command line tool configured for p47 -## -module-whatis "ec command line tool configured for p47" - -if { [module-info mode load] } { - if { [is-loaded ec] } { - module unload ec - } -} - -module load edge-containers-cli/0.1 -module load pollux/local - -setenv EC_TARGET "p47-beamline/p47" -setenv EC_SERVICES_REPO "https://github.com/epics-containers/p47-services" - -prepend-path PATH "/tmp/deploy-tools-output/modules/ec/p47/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec b/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec deleted file mode 100755 index 03240d6..0000000 --- a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/bash - -# Arguments: -# ${@} = Remaining args to pass to the command - -# Halt on error -set -e - -# Mounts for container -mounts="/dls/science/users/:/dls/science/users/,/scratch:/scratch,/dls_sw/apps:/dls_sw/apps" -# Additional arguments for apptainer -apptainer_args="" -# Sif file path -sif_file="$(dirname $0)/../sif_files/4b34247055f8388a8877c90302ff30d2.sif" -# Command to run in container -command="ec" -# Options and arguments to pass to command -command_args="" - -# Raise an error if sif file does not exist -if [[ ! -f ${sif_file} ]]; then - echo "ERROR: sif file ${sif_file} does not exist" 1>&2 - exit 1 -fi - -# add mounts of host binaries into /usr/bin -for i in argocd kubectl helm kubelogin klogout kustomize kubeseal kubectl-oidc_login; do - binary=$(which $i) - mounts="${mounts},${binary}:/usr/bin/${i}" -done - -# Set up mounts if any have been configured -if [[ ! -z ${mounts} ]]; then - opts="-B ${mounts}" -fi - -opts=${opts}" --env DISPLAY=${DISPLAY}" -opts=${opts}" ${apptainer_args}" - - -if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then - set -x -fi -apptainer exec ${opts} ${sif_file} ${command} ${command_args} "${@}" diff --git a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-bash b/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-bash deleted file mode 100755 index 4cb4464..0000000 --- a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints/ec-bash +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/bash - -# Arguments: -# ${@} = Remaining args to pass to the command - -# Halt on error -set -e - -# Mounts for container -mounts="/dls/science/users/:/dls/science/users/,/scratch:/scratch,/dls_sw/apps:/dls_sw/apps" -# Additional arguments for apptainer -apptainer_args="" -# Sif file path -sif_file="$(dirname $0)/../sif_files/4b34247055f8388a8877c90302ff30d2.sif" -# Command to run in container -command="bash" -# Options and arguments to pass to command -command_args="" - -# Raise an error if sif file does not exist -if [[ ! -f ${sif_file} ]]; then - echo "ERROR: sif file ${sif_file} does not exist" 1>&2 - exit 1 -fi - -# add mounts of host binaries into /usr/bin -for i in argocd kubectl helm kubelogin klogout kustomize kubeseal kubectl-oidc_login; do - binary=$(which $i) - mounts="${mounts},${binary}:/usr/bin/${i}" -done - -# Set up mounts if any have been configured -if [[ ! -z ${mounts} ]]; then - opts="-B ${mounts}" -fi - -opts=${opts}" --env DISPLAY=${DISPLAY}" -opts=${opts}" ${apptainer_args}" - - -if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then - set -x -fi -apptainer exec ${opts} ${sif_file} ${command} ${command_args} "${@}" diff --git a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/module.yaml b/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/module.yaml deleted file mode 100644 index d61fb20..0000000 --- a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/module.yaml +++ /dev/null @@ -1,56 +0,0 @@ -allow_updates: false -applications: -- app_type: apptainer - container: - path: docker://ghcr.io/epics-containers/edge-containers-cli - version: 4.4.1 - entrypoints: - - command: ec - name: ec - options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - - command: bash - name: ec-bash - options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: - - argocd - - kubectl - - helm - - kubelogin - - klogout - - kustomize - - kubeseal - - kubectl-oidc_login - mounts: - - /dls/science/users/:/dls/science/users/ - - /scratch:/scratch - - /dls_sw/apps:/dls_sw/apps -- app_type: shell - name: ec-login - script: - - argocd login argocd.diamond.ac.uk --grpc-web --sso - - kubectl version -dependencies: -- name: argocd - version: v2.14.10 -description: ec command line tool for kubernetes IOCs -env_vars: -- name: EC_CLI_BACKEND - value: ARGOCD -- name: EC_LOG_URL - value: https://graylog.diamond.ac.uk/search?rangetype=relative&fields=message%2Csource&width=1489&highlightMessage=&relative=172800&q=pod_name%3A{service_name}* -exclude_from_defaults: false -load_script: [] -name: edge-containers-cli -unload_script: [] -version: '0.1' diff --git a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/modulefile b/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/modulefile deleted file mode 100644 index 20a9e15..0000000 --- a/tests/samples/deploy-tools-output/modules/edge-containers-cli/0.1/modulefile +++ /dev/null @@ -1,18 +0,0 @@ -#%Module1.0 -## -## edge-containers-cli - ec command line tool for kubernetes IOCs -## -module-whatis "ec command line tool for kubernetes IOCs" - -if { [module-info mode load] } { - if { [is-loaded edge-containers-cli] } { - module unload edge-containers-cli - } -} - -module load argocd/v2.14.10 - -setenv EC_CLI_BACKEND "ARGOCD" -setenv EC_LOG_URL "https://graylog.diamond.ac.uk/search?rangetype=relative&fields=message%2Csource&width=1489&highlightMessage=&relative=172800&q=pod_name%3A{service_name}*" - -prepend-path PATH "/tmp/deploy-tools-output/modules/edge-containers-cli/0.1/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/modulefile b/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/modulefile deleted file mode 100644 index ae2ca59..0000000 --- a/tests/samples/deploy-tools-output/modules/example-module-apps/0.1/modulefile +++ /dev/null @@ -1,15 +0,0 @@ -#%Module1.0 -## -## example-module-apps - Demonstration of a module configuration folder -## -module-whatis "Demonstration of a module configuration folder" - -if { [module-info mode load] } { - if { [is-loaded example-module-apps] } { - module unload example-module-apps - } -} - -setenv OTHER_VALUE "Test message OTHER_VALUE from example-module-folder" - -prepend-path PATH "/tmp/deploy-tools-output/modules/example-module-apps/0.1/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/example-module-deps/0.2/modulefile b/tests/samples/deploy-tools-output/modules/example-module-deps/0.2/modulefile deleted file mode 100644 index 3368198..0000000 --- a/tests/samples/deploy-tools-output/modules/example-module-deps/0.2/modulefile +++ /dev/null @@ -1,16 +0,0 @@ -#%Module1.0 -## -## example-module-deps - Demonstration of deploy-tools dependencies -## -module-whatis "Demonstration of deploy-tools dependencies" - -if { [module-info mode load] } { - if { [is-loaded example-module-deps] } { - module unload example-module-deps - } -} - -module load dls-pmac-control/0.1 -module load example-module-apps/0.1 - -prepend-path PATH "/tmp/deploy-tools-output/modules/example-module-deps/0.2/entrypoints" diff --git a/tests/samples/deploy-tools-output/modules/phoebus/0.1/entrypoints/phoebus b/tests/samples/deploy-tools-output/modules/phoebus/0.1/entrypoints/phoebus deleted file mode 100755 index 0dc0fef..0000000 --- a/tests/samples/deploy-tools-output/modules/phoebus/0.1/entrypoints/phoebus +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/bash - -# Arguments: -# ${@} = Remaining args to pass to the command - -# Halt on error -set -e - -# Mounts for container -mounts="" -# Additional arguments for apptainer -apptainer_args="--env DISPLAY=${DISPLAY} -e" -# Sif file path -sif_file="$(dirname $0)/../sif_files/433dd7c0f3803fb792bf46b323938691.sif" -# Command to run in container -command="java -jar /phoebus/phoebus.jar -server 7010" -# Options and arguments to pass to command -command_args="-server 7010" - -# Raise an error if sif file does not exist -if [[ ! -f ${sif_file} ]]; then - echo "ERROR: sif file ${sif_file} does not exist" 1>&2 - exit 1 -fi - -# add mounts of host binaries into /usr/bin -for i in ; do - binary=$(which $i) - mounts="${mounts},${binary}:/usr/bin/${i}" -done - -# Set up mounts if any have been configured -if [[ ! -z ${mounts} ]]; then - opts="-B ${mounts}" -fi - -opts=${opts}" --env DISPLAY=${DISPLAY}" -opts=${opts}" ${apptainer_args}" - - -if [[ -n "${DEPLOY_TOOLS_VERBOSE}" ]]; then - set -x -fi -apptainer exec ${opts} ${sif_file} ${command} ${command_args} "${@}" diff --git a/tests/samples/deploy-tools-output/modules/phoebus/0.1/module.yaml b/tests/samples/deploy-tools-output/modules/phoebus/0.1/module.yaml deleted file mode 100644 index 9f9b48a..0000000 --- a/tests/samples/deploy-tools-output/modules/phoebus/0.1/module.yaml +++ /dev/null @@ -1,27 +0,0 @@ -allow_updates: false -applications: -- app_type: apptainer - container: - path: docker://ghcr.io/epics-containers/ec-phoebus - version: 4.7.3ec2 - entrypoints: - - command: java -jar /phoebus/phoebus.jar -server 7010 - name: phoebus - options: - apptainer_args: --env DISPLAY=${DISPLAY} -e - command_args: -server 7010 - host_binaries: [] - mounts: [] - global_options: - apptainer_args: '' - command_args: '' - host_binaries: [] - mounts: [] -dependencies: [] -description: Containerised release of CSS Phoebus -env_vars: [] -exclude_from_defaults: false -load_script: [] -name: phoebus -unload_script: [] -version: '0.1' diff --git a/tests/samples/deploy-tools-output/modules/phoebus/0.1/modulefile b/tests/samples/deploy-tools-output/modules/phoebus/0.1/modulefile deleted file mode 100644 index e3b3ee9..0000000 --- a/tests/samples/deploy-tools-output/modules/phoebus/0.1/modulefile +++ /dev/null @@ -1,13 +0,0 @@ -#%Module1.0 -## -## phoebus - Containerised release of CSS Phoebus -## -module-whatis "Containerised release of CSS Phoebus" - -if { [module-info mode load] } { - if { [is-loaded phoebus] } { - module unload phoebus - } -} - -prepend-path PATH "/tmp/deploy-tools-output/modules/phoebus/0.1/entrypoints" diff --git a/tests/test_cli.py b/tests/test_cli.py index df8efb7..cdbd77b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,60 +1,9 @@ import subprocess import sys -import tempfile -from pathlib import Path -from shutil import rmtree -from conftest import run_cli from deploy_tools import __version__ -PATH_TO_SCHEMAS = ( - Path(__file__).parent.parent / "src" / "deploy_tools" / "models" / "schemas" -) - -def test_cli_version(): +def test_cli_version() -> None: cmd = [sys.executable, "-m", "deploy_tools", "--version"] assert subprocess.check_output(cmd).decode().strip() == __version__ - - -def test_schema(schemas: Path): - with tempfile.TemporaryDirectory() as tmp: - tmp_path = Path(tmp) - - # Generate up to date schema files - run_cli("schema", tmp_path) - - # Compare with the expected schema files - for schema in tmp_path.glob("*.json"): - expected = schemas / schema.name - if schema.read_text() != expected.read_text(): - raise AssertionError(f"Schema file {expected} is out of date.") - - -def test_demo_configuration(samples: Path, demo_config: Path): - # use a fixed path for the demo configuration so that the outputs are consistent - out_folder = "deploy-tools-output" - temp_out = Path("/tmp") / out_folder - expected_out = samples / out_folder - - # make sure the output directory is empty and exists - rmtree(temp_out, ignore_errors=True) - temp_out.mkdir(exist_ok=True) - - # generate the demo configuration output - run_cli("sync", "--from-scratch", str(temp_out), str(demo_config)) - - # compare the output with the expected output - for expected in expected_out.glob("**/*"): - if expected.is_dir(): - continue - # check that the file exists in the output directory - out_file = temp_out / expected.relative_to(expected_out) - assert out_file.exists(), f"File {out_file} does not exist." - - # check that the file contents are the same - assert expected.read_text() == out_file.read_text(), ( - f"File {out_file} is different." - ) - - rmtree(temp_out, ignore_errors=True) diff --git a/tests/test_golden_master.py b/tests/test_golden_master.py new file mode 100644 index 0000000..9085cc1 --- /dev/null +++ b/tests/test_golden_master.py @@ -0,0 +1,160 @@ +from pathlib import Path + +from conftest import run_cli + +# Generated modulefiles embed the absolute deployment path. generate_samples.sh builds +# the committed golden master against this fixed root; the test deploys under a per-test +# tmp_path (parallel-safe, self-cleaning) and normalises this prefix away when diffing. +DEPLOYMENT_DIRNAME = "deploy-tools-output" +SAMPLE_DEPLOY_ROOT = Path("/tmp") / DEPLOYMENT_DIRNAME + + +def _assert_expected_files_match(expected_root: Path, actual_root: Path) -> None: + """Assert every file under ``expected_root`` matches the one in ``actual_root``. + + This is a one-directional check: files present in the deployment area but absent + from the golden master (e.g. ``.sif`` images, the ``.git`` directory) are ignored. + Use ``_assert_absent`` to verify that files have actually been removed. + + The committed master embeds ``SAMPLE_DEPLOY_ROOT`` as the deployment path, in both + file contents and absolute modulefile-link targets; that prefix is normalised to + ``actual_root`` before comparing, so the deployment can happen anywhere. + + Args: + expected_root: Root of the committed golden master tree. + actual_root: Root of the deployment area to check against it. + """ + for expected in expected_root.glob("**/*"): + actual = actual_root / expected.relative_to(expected_root) + + # Modulefiles are symlinks whose absolute target embeds the deployment root; + # compare the normalised target, don't follow the (dangling) committed link. + if expected.is_symlink(): + assert actual.is_symlink(), f"{actual} is not a symlink." + expected_target = str(expected.readlink()).replace( + str(SAMPLE_DEPLOY_ROOT), str(actual_root) + ) + assert expected_target == str(actual.readlink()), ( + f"Symlink {actual} points to the wrong target." + ) + continue + + if expected.is_dir(): + continue + + # check that the file exists in the output directory + assert actual.exists(), f"File {actual} does not exist." + + # compare contents, normalising the embedded deployment-root prefix + expected_text = expected.read_text().replace( + str(SAMPLE_DEPLOY_ROOT), str(actual_root) + ) + assert expected_text == actual.read_text(), f"File {actual} is different." + + +def _assert_absent(root: Path, *relative_paths: str) -> None: + """Assert that none of the given paths exist under ``root``. + + Args: + root: The base directory to resolve paths against. + relative_paths: Paths, relative to ``root``, that must not exist. + """ + for relative_path in relative_paths: + path = root / relative_path + assert not path.exists(), f"Path {path} should not exist." + + +def _assert_validate_matches(expected_dir: Path, *cli_args: str | Path) -> None: + """Assert ``validate``'s printed summary matches the committed golden master. + + ``validate`` is read-only and previews the next sync, so it is run against the + deployment area in its pre-sync state. + + Args: + expected_dir: Stage directory containing the expected ``validate.txt``. + cli_args: Arguments passed to the ``validate`` CLI command. + """ + expected = (expected_dir / "validate.txt").read_text() + assert run_cli("validate", *cli_args) == expected + + +def _run_stage( + samples: Path, + configs: Path, + area: Path, + stage: str, + *, + from_scratch: bool = False, + absent: tuple[str, ...] = (), +) -> None: + """Preview, sync, and verify one lifecycle stage against its golden master. + + Args: + samples: The committed golden-master samples directory. + configs: The ``configs`` fixture (root of the test configurations). + area: The shared deployment area, built up across stages. + stage: The lifecycle stage name, e.g. ``04-deprecated``. + from_scratch: Whether this stage deploys into an empty area. + absent: Paths, relative to ``area``, that must not exist after the sync. + """ + flags = ["--from-scratch"] if from_scratch else [] + stage_config = configs / "golden-master" / stage + _assert_validate_matches(samples / stage, *flags, area, stage_config) + run_cli("sync", *flags, area, stage_config) + _assert_expected_files_match(samples / stage / DEPLOYMENT_DIRNAME, area) + _assert_absent(area, *absent) + + +def test_module_lifecycle( + samples: Path, configs: Path, stub_apptainer_pull: None, tmp_path: Path +) -> None: + # tmp_path is a fresh, empty, per-test directory; the stages below share it as one + # deployment area, each building on the previous state, with no cross-run leakage. + + # Stage 1: deploy apps, deps, updatable/1.0, and versions/1.0 into an empty area. + _run_stage(samples, configs, tmp_path, "01-initial", from_scratch=True) + + # Stage 2: on an incremental sync, add a second version (versions/2.0) and an + # excluded prerelease (versions/2.1rc1). The versions default moves from 1.0 to 2.0. + _run_stage(samples, configs, tmp_path, "02-added") + + # Stage 3: update updatable/1.0 in place (allowed via allow_updates) without bumping + # its version. + _run_stage(samples, configs, tmp_path, "03-updated") + + # Stage 4: deprecate versions/1.0 (en route to removal) and versions/2.1rc1 (to set + # up the restore that follows). Their live modulefile links move into the deprecated + # area; the built modules and versions/2.0 (still the default) stay put. + _run_stage( + samples, + configs, + tmp_path, + "04-deprecated", + absent=( + "modulefiles/versions/1.0", + "modulefiles/versions/2.1rc1", + ), + ) + + # Stage 5: restore versions/2.1rc1 by un-deprecating it. Its modulefile link moves + # back into the live area; versions/1.0 stays deprecated. + _run_stage( + samples, + configs, + tmp_path, + "05-restored", + absent=("deprecated/modulefiles/versions/2.1rc1",), + ) + + # Stage 6: remove the now-deprecated versions/1.0 entirely. Both its modulefile link + # and built module should be gone; versions/2.0 and 2.1rc1 remain. + _run_stage( + samples, + configs, + tmp_path, + "06-removed", + absent=( + "modules/versions/1.0", + "deprecated/modulefiles/versions/1.0", + ), + ) diff --git a/tests/test_schema_gen.py b/tests/test_schema_gen.py new file mode 100644 index 0000000..8cbddfa --- /dev/null +++ b/tests/test_schema_gen.py @@ -0,0 +1,18 @@ +import tempfile +from pathlib import Path + +from conftest import run_cli + + +def test_schema_gen(schemas: Path) -> None: + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + + # Generate up to date schema files + run_cli("schema", tmp_path) + + # Compare with the expected schema files + for schema in tmp_path.glob("*.json"): + expected = schemas / schema.name + if schema.read_text() != expected.read_text(): + raise AssertionError(f"Schema file {expected} is out of date.")