-
Notifications
You must be signed in to change notification settings - Fork 0
Improve golden master tests #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,969
−908
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f54bc5b
Trim down golden master tests
MJGaughran f061f99
Split tests into separate files
MJGaughran 8f987c1
Cover module deprecation and removal in golden master
MJGaughran 1ea0ae0
Cover incremental module creation in golden master tests
MJGaughran 65071d6
Cover module update and restore in golden master tests
MJGaughran 971af9c
Add golden-master tests for the validate command
MJGaughran b20d8f8
Use google docstring format for tests
MJGaughran e3b8131
Use single DeployToolsError as base class for actionable errors
MJGaughran f175bff
Stub the external call to apptainer in tests
MJGaughran 62f9051
Wrap external tool calls to improve error messages and error handling
MJGaughran c3c3176
Add ANN to ruff for consistent type hinting
MJGaughran 11a3474
Use tmp_path for all test builds to make parallel-safe
MJGaughran 9bd07d4
Reorganise golden master test configuration for consistency
MJGaughran 61614a1
Extract common helper for golden master test stages
MJGaughran 9ab34d0
Refactor golden master tests for improved structure and naming
MJGaughran fb387c5
Revert demo configuration to original files
MJGaughran b751132
Remove unused schema paths variable from tests
MJGaughran 591326d
Remove comment in print_updates.py that refers to PYTHONHASHSEED
MJGaughran 22028aa
Rework golden master tests to ensure each stage name is accurate
MJGaughran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
MJGaughran marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # yaml-language-server: $schema=/workspaces/deploy-tools/src/deploy_tools/models/schemas/deployment-settings.json | ||
|
|
||
| default_versions: {} | ||
|
ptsOSL marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: [] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.